diff --git a/src/main.rs b/src/main.rs index d53f327..c986839 100644 --- a/src/main.rs +++ b/src/main.rs @@ -151,7 +151,7 @@ async fn handler(cfg: &Config, s: &mut State) -> Result<(), reqwest::Error> { async fn send_comic(cfg: Config, ctx: SenderCtx) -> Result<(), reqwest::Error> { let info = cfg .client - .get(ctx.url) + .get(ctx.url.clone()) .send() .await? .error_for_status()? @@ -170,7 +170,13 @@ async fn send_comic(cfg: Config, ctx: SenderCtx) -> Result<(), reqwest::Error> { .unwrap_or("null".to_owned()), ), ("photo", info.img), - ("caption", info.alt), + ( + "caption", + format!( + "*{}. [{}]({})*\n\n{}", + ctx.comic_id, info.title, ctx.url, info.alt, + ), + ), ]) .send() .await?; diff --git a/src/types.rs b/src/types.rs index d0d533b..25bc6d9 100644 --- a/src/types.rs +++ b/src/types.rs @@ -60,8 +60,9 @@ pub struct TgChat { /// XKCD API comic info schema #[derive(Debug, Deserialize)] pub struct XkcdInfo { - #[serde(alias = "text")] // xkcd.ru - pub alt: String, // xkcd.com + pub title: String, #[serde(alias = "image")] // xkcd.ru pub img: String, // xkcd.com + #[serde(alias = "text")] // xkcd.ru + pub alt: String, // xkcd.com }