diff options
Diffstat (limited to 'src/bot.rs')
| -rw-r--r-- | src/bot.rs | 59 |
1 files changed, 45 insertions, 14 deletions
@@ -230,22 +230,53 @@ fn on_err(err: FrameworkError<PoiseData, anyhow::Error>) -> BoxFuture<()> { __non_exhaustive: (), }; - match util::pop_string(msg_content) - .map_err(anyhow::Error::from) - .and_then(|(_rest, s)| s.parse().map_err(anyhow::Error::from)) - { - Ok(u) => { - if let Err(e) = commands::unrecognized(PoiseContext::Prefix(ctx), u).await { - error!("processing audio: {e}"); + let content = msg_content.trim(); + + if content.is_empty() { + if let Err(e) = util::reply(PoiseContext::Prefix(ctx), "what?").await { + error!("responding to empty message: {e}"); + }; + + return; + } + + lazy_static::lazy_static! { + static ref HTTP_REGEX: regex::Regex = regex::Regex::new(r#"^https?://"#).unwrap(); + } + + if HTTP_REGEX.is_match(content) { + match util::pop_string(msg_content) + .map_err(anyhow::Error::from) + .and_then(|(_rest, s)| s.parse().map_err(anyhow::Error::from)) + { + Ok(u) => { + if let Err(e) = + commands::link_unrecognized(PoiseContext::Prefix(ctx), u).await + { + error!("processing audio: {e}"); + "BANIC".to_string() + } else { + return; + } + }, + Err(e) => { + error!("processing unrecognized message: {e}"); "BANIC".to_string() - } else { - return; - } - }, - Err(e) => { - error!("processing unrecognized message: {e}"); + }, + } + } else { + if let Err(e) = commands::meme::invoke::_meme( + PoiseContext::Prefix(ctx), + msg_content, + Default::default(), + ) + .await + { + error!("producing meme for unrecognized: {e}"); "BANIC".to_string() - }, + } else { + return; + } } }, _ => "BANIC".to_string(), |
