aboutsummaryrefslogtreecommitdiff
path: root/src/hooks
diff options
context:
space:
mode:
Diffstat (limited to 'src/hooks')
-rw-r--r--src/hooks/mod.rs2
-rw-r--r--src/hooks/nitter.rs29
2 files changed, 31 insertions, 0 deletions
diff --git a/src/hooks/mod.rs b/src/hooks/mod.rs
index d70af9c..39198c1 100644
--- a/src/hooks/mod.rs
+++ b/src/hooks/mod.rs
@@ -7,10 +7,12 @@ use base64::{alphabet, engine, Engine};
use irc::client::prelude::*;
mod intensify;
+mod nitter;
mod pet;
mod shifty_eyes;
pub use intensify::*;
+pub use nitter::*;
pub use pet::*;
pub use shifty_eyes::*;
diff --git a/src/hooks/nitter.rs b/src/hooks/nitter.rs
new file mode 100644
index 0000000..f29e885
--- /dev/null
+++ b/src/hooks/nitter.rs
@@ -0,0 +1,29 @@
+use std::sync::LazyLock;
+
+use anyhow::{Context, Result};
+use irc::client::prelude::*;
+use regex::Regex;
+
+static RE: LazyLock<Regex> =
+ LazyLock::new(|| Regex::new(r"https:\/\/(?:twitter|x)\.com\/(\S+?)(?:\s|$)").unwrap());
+
+const URL: &str = "https://xcancel.com/";
+
+pub fn nitter(bot: &crate::Bot, msg: Message) -> Result<()> {
+ if let Command::PRIVMSG(_, text) = msg.command.clone() {
+ let path = RE
+ .captures(&text)
+ .context("failed to capture twitter url path")?
+ .get(1)
+ .context("failed to get path capture group")?
+ .as_str();
+
+ bot.send_privmsg(
+ msg.response_target()
+ .context("failed to get response target")?,
+ format!("get cancled {URL}{path}").as_str(),
+ )?;
+ }
+
+ Ok(())
+}
b0a89890b6bf52dec7591&follow=1'>add nix build and moduleMax Audron-5/+427 2022-02-19remove jsonnet lock fileMax Audron-36/+0 2022-02-19fix deploy to work with gitlab agentMax Audron-4/+4 2021-10-22write tons of documentation and reorganize some modulesMax Audron-65/+300 2021-10-22remove wolfram alpha url shorteningMax Audron-1/+2 2021-10-20remove failing wolfram alpha test casesMax Audron-105/+55 2021-10-20bump version to 1.6.2Max Audron-3/+2 2021-10-20prepare for release on crates.ioMax Audron-39/+65 2021-10-20add async docs to macro crate and bump versionMax Audron-9/+10 2021-10-20change hook errors to be logged as warningsMax Audron-3/+3 2021-10-20fix configuration not loading correctly on release buildsMax Audron-8/+23 2021-10-19replace sedregex crate8-rework-sedMax Audron-20/+358 2021-10-19add formatting trait for irc codesMax Audron-0/+129 2021-10-17fix links in readmeMax Audron-2/+2