diff --git a/bot/src/main.rs b/bot/src/main.rs index 74da3dc..3c5cc4f 100644 --- a/bot/src/main.rs +++ b/bot/src/main.rs @@ -134,9 +134,14 @@ async fn main() -> Result<(), anyhow::Error> { Ok(post) => { // Step1: Upload image to Mastodon let media_response = if post.image.is_some() { - Ok(mastodon_client + let response = mastodon_client .upload_media_by_url(post.image.clone().unwrap().as_str()) - .await?) + .await; + + match response { + Ok(response) => Ok(response), + Err(err) => Err(anyhow!("failed to upload image: {err}")), + } } else { Err(anyhow!("No image exists on post.")) }; diff --git a/bot/src/mastodon/api.rs b/bot/src/mastodon/api.rs index d22946e..8151259 100644 --- a/bot/src/mastodon/api.rs +++ b/bot/src/mastodon/api.rs @@ -38,13 +38,13 @@ impl From for PostStatusRequest { if character_budget > 0 { status.push_str(title.get(0..character_budget).unwrap_or(title.as_str())); character_budget -= title.len() + 2; - status.push_str("\n") + status.push('\n') } // Push the summary if character_budget > 0 { status.push_str(summary.get(0..character_budget).unwrap_or(summary.as_str())); - status.push_str("\n") + status.push('\n') } // Push the link diff --git a/readme.md b/readme.md index 25ae6c4..3c8df60 100644 --- a/readme.md +++ b/readme.md @@ -46,5 +46,24 @@ things simple and due to its powerful features and flexibility[1]. The BlueSky bot reads data from Redis Streams and publishes it to BlueSky. +```shell +Social media posting bot. + +Usage: bot --redis-connection-string --redis-stream-name --redis-consumer-group --redis-consumer-name + +Commands: + bluesky Post on bluesky platform + mastodon Post on Mastodon, the FediVerse + help Print this message or the help of the given subcommand(s) + +Options: + -r, --redis-connection-string Redis host + -t, --redis-stream-name Redis stream name + -c, --redis-consumer-group Redis consumer group name + -n, --redis-consumer-name The current consumer name + -h, --help Print help + -V, --version Print version +``` + [1] - https://redis.io/about/