1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
use crate::HandlerConfig;
use anyhow::{anyhow, Context as _, Result};
use serenity::all::{Context, Message};
use std::ops::ControlFlow;
const TWITTER_URLS: &[&str] = &[
"https://fixupx.com/",
"https://fixvx.com/",
"https://pbs.twimg.com/",
"https://t.co/",
"https://twitter.com/",
"https://x.com/",
];
const REACTS: &[char] = &['🇶', '🇺', '🇮', '🇹', '🐦'];
pub async fn on_message(
_config: &HandlerConfig,
ctx: &Context,
msg: &Message,
) -> Result<ControlFlow<(), ()>> {
let is_twitter = TWITTER_URLS.iter().any(|url| msg.content.contains(url));
if !is_twitter {
return Ok(ControlFlow::Continue(()));
}
for &react in REACTS {
msg.react(&ctx.http, react)
.await
.with_context(|| anyhow!("Failed to react with {react} on a Twitter message"))?;
}
Ok(ControlFlow::Break(()))
}
|