diff options
Diffstat (limited to 'src/hooks')
| -rw-r--r-- | src/hooks/wa.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/hooks/wa.rs b/src/hooks/wa.rs index 7d087ea..e51aa47 100644 --- a/src/hooks/wa.rs +++ b/src/hooks/wa.rs @@ -1,9 +1,11 @@ use crate::util::web::shorten_url; use anyhow::{Context, Error, Result}; use futures::try_join; +use irc::client::prelude::*; use reqwest::{get, Url}; use serde::{Deserialize, Serialize}; use serde_json::Result as SerdeJsonResult; +use macros::privmsg; #[derive(Serialize, Deserialize, Debug)] struct WaResponse { @@ -103,6 +105,20 @@ async fn wa_query(query_str: &str, base_url: Option<&str>) -> Result<String, Err )) } +pub async fn wa(bot: &crate::Bot, msg: Message) -> Result<()> { + privmsg!(msg, { + let mut chars = text.chars(); + chars.next(); + chars.next_back(); + let content = chars.as_str(); + + bot.send_privmsg( + msg.response_target().context("failed to get response target")?, + &wa_query(content, None).await? + )?; + }) +} + #[cfg(test)] mod tests { |
