now works with new api
This commit is contained in:
parent
8df1e025c2
commit
d35ae7586d
|
@ -16,6 +16,11 @@ pub struct Message {
|
||||||
|
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
pub struct MemeResponse {
|
pub struct MemeResponse {
|
||||||
|
pub meme: Meme,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Debug)]
|
||||||
|
pub struct Meme {
|
||||||
pub link: String,
|
pub link: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use api::{Event, Message, MemeResponse};
|
use api::{Event, Message, MemeResponse, Meme};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use pin_project_lite::pin_project;
|
use pin_project_lite::pin_project;
|
||||||
use reqwest::Client;
|
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
|
// startup and take a random one when needed, so we don't make a request each
|
||||||
// time (which slows the bot down significantly)
|
// 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 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 {
|
let message = Message {
|
||||||
text: link,
|
text: link,
|
||||||
|
|
Loading…
Reference in a new issue