refraction/src/handlers/event/dms_vcs.rs
KTrain5369 4da708874a
add autoresponse & tag for dm/vc support
Co-Authored-By: maskers <97827489+maskersss@users.noreply.github.com>
Co-Authored-By: Samalando <156577273+Samalando@users.noreply.github.com>
2024-09-04 21:21:45 +10:00

28 lines
791 B
Rust

use std::{sync::OnceLock, time::SystemTime};
use eyre::Result;
use log::trace;
use poise::serenity_prelude::{Context, Message};
use regex::Regex;
fn regex() -> &'static Regex {
static REGEX: OnceLock<Regex> = OnceLock::new();
REGEX.get_or_init(|| Regex::new(r"(?i)\b(?:dms|dm|vc|vcs|voice call|screenshare)\b").unwrap())
}
const MESSAGE: &str = "Please try to keep all support conversations here, run `/tag dm` to learn more.";
pub async fn handle(ctx: &Context, message: &Message) -> Result<()> {
if !regex().is_match(&message.content) {
trace!(
"The message '{}' (probably) doesn't say DMs, VCs",
message.content
);
return Ok(());
}
let response = format!(MESSAGE);
message.reply(ctx, &response).await?;
Ok(())
}