now works with new api

This commit is contained in:
LordMZTE 2021-03-23 23:11:19 +01:00
parent 8df1e025c2
commit d35ae7586d
2 changed files with 7 additions and 2 deletions

View File

@ -16,6 +16,11 @@ pub struct Message {
#[derive(Deserialize, Debug)]
pub struct MemeResponse {
pub meme: Meme,
}
#[derive(Deserialize, Debug)]
pub struct Meme {
pub link: String,
}

View File

@ -1,5 +1,5 @@
use anyhow::{anyhow, Result};
use api::{Event, Message, MemeResponse};
use api::{Event, Message, MemeResponse, Meme};
use bytes::Bytes;
use pin_project_lite::pin_project;
use reqwest::Client;
@ -108,7 +108,7 @@ async fn process_message(client: &Client, message: Message) -> Result<()> {
// startup and take a random one when needed, so we don't make a request each
// time (which slows the bot down significantly)
let res = client.get("https://data.tilera.xyz/api/jensmemes/random?category=uff").send().await?.text().await?;
let MemeResponse { link } = serde_json::from_str(&res)?;
let MemeResponse { meme: Meme { link } } = serde_json::from_str(&res)?;
let message = Message {
text: link,