feat: add comic id and title to msg
This commit is contained in:
parent
3790fab0bc
commit
afd5ad906e
2 changed files with 11 additions and 4 deletions
10
src/main.rs
10
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?;
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue