discord-kurante/src/passive/best_doctor.rs

31 lines
756 B
Rust
Raw Normal View History

2020-05-01 19:17:53 -07:00
use regex::Regex;
use serenity::async_trait;
use serenity::model::channel::Message;
use serenity::prelude::{Context, EventHandler};
pub(crate) struct BestDoctorResponder {
regex: Regex,
}
impl Default for BestDoctorResponder {
fn default() -> Self {
Self {
regex: Regex::new(r"[iI].*(?:best|genius) doc").unwrap(),
}
}
}
#[async_trait]
impl EventHandler for BestDoctorResponder {
async fn message(&self, ctx: Context, message: Message) {
let content = &message.content_safe(ctx.clone()).await;
if self.regex.is_match(content) {
message
.channel_id
2020-05-01 19:27:40 -07:00
.say(ctx, "smol brain doctor..")
2020-05-01 19:17:53 -07:00
.await
.unwrap();
}
}
}