better message formatting
This commit is contained in:
parent
a1b1bffce9
commit
07ae653d49
1 changed files with 13 additions and 8 deletions
21
src/lib.rs
21
src/lib.rs
|
|
@ -125,22 +125,27 @@ impl BlogdorTheAggregator {
|
|||
Ok(feed_results)
|
||||
}
|
||||
|
||||
// will also update the successful_runs table if it posts to zulip
|
||||
pub async fn post_entries(&self, posts: &[FeedEntry]) {
|
||||
let FeedEntry {
|
||||
feed_id, received, ..
|
||||
} = posts.last().unwrap();
|
||||
let mut success = true;
|
||||
for post in posts.iter() {
|
||||
let body = post
|
||||
.body
|
||||
.iter()
|
||||
.next()
|
||||
.cloned()
|
||||
.unwrap_or("Blogdor Says: NO BODY!".to_string());
|
||||
let body = post.body.as_deref().unwrap_or("Blogdor Says: NO BODY!");
|
||||
|
||||
let tail = if body.len() < ZULIP_MESSAGE_CUTOFF {
|
||||
""
|
||||
} else {
|
||||
"..."
|
||||
};
|
||||
|
||||
let content = format!(
|
||||
"{body} ...\n\n---\noriginally posted to {}, on {}",
|
||||
post.post_url, post.published
|
||||
"{body}{tail}\n\n---\noriginally published on [{}]({})",
|
||||
post.published.format("%B %e, %Y"),
|
||||
post.post_url
|
||||
);
|
||||
|
||||
let msg = ZulipMessage {
|
||||
to: self.channel_id,
|
||||
typ: "stream",
|
||||
|
|
|
|||
Loading…
Reference in a new issue