aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/hooks/wa.rs16
-rw-r--r--src/main.rs5
2 files changed, 21 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 {
diff --git a/src/main.rs b/src/main.rs
index 9ab7f6c..f337613 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -52,5 +52,10 @@ async fn main() {
"Prints some info about this kitty cat",
catinator::hooks::about
),
+ async command(
+ "wa",
+ "Returns Wolfram Alpha results for a query",
+ catinator::hooks::wa::wa
+ ),
];
}
mp;follow=1'>add lmr to channels1.3.1Max Audron-1/+1 2021-06-23rewrite sed regex to work cross channelMax Audron-115/+141 2021-06-23add required metadata for publishing to macros crateMax Audron-5/+12 2021-06-23add ability to use path and dotted syntax for functionsMax Audron-8/+39 2021-06-21publish macros subcrateMax Audron-20/+20 2021-06-13release version 1.2.1Max Audron-2/+2 * fix crash on empty message 2021-06-13fix crash on message only containing whitespaceMax Audron-1/+4 2021-06-11Release version 1.2.01.2.0Max Audron-2/+2 * add pet command 2021-06-06make pet more compactR0flcopt3r/catinator-pet-commandMax Audron-5/+5 2021-06-05feat: adds pet command.R0flcopt3r-0/+90 When petting the cat it will reply with some random action. 2021-06-05feat: send actionR0flcopt3r-1/+9 2021-06-05release version 1.1.0Max Audron-2/+2 2021-06-05document proc macrosMax Audron-4/+97 2021-06-05add intensifyMax Audron-3/+27 2021-06-05add privmsg macroMax Audron-2/+40 2021-06-05fix jb remote urlsMax Audron-4/+4 2021-06-05remove egress gateway configMax Audron-10/+0 2021-06-05update tanka dependenciesMax Audron-8/+8 2021-06-05fix init container nameMax Audron-1/+1 2021-06-05fix tanka dependency pathMax Audron-8/+8 2021-06-05switch to https url for tanka util libMax Audron-2/+2 2021-06-05bump version to 1.0.2Max Audron-2/+2 2021-06-05add tanka ci configurationMax Audron-1/+1 2021-06-05ready tanka deploy for CIMax Audron-32/+69 2021-06-05remove tanka vendoringMax Audron-27651/+0 2021-05-26Release 1.0.1Max Audron-3/+3 2021-05-26fix log breaking once buffer fullMax Audron-2/+33 the log_msg function was poping the newest message and replacing it with the newest message, it should be poping the oldest messages. 2021-05-16add deployment stuffMax Audron-6/+27786 2021-05-15add container buildMax Audron-2/+35