aboutsummaryrefslogtreecommitdiff
path: root/src/hooks/sed.rs
diff options
context:
space:
mode:
authorMax Audron <audron@cocaine.farm>2021-09-07 13:23:01 +0200
committerMax Audron <audron@cocaine.farm>2021-09-07 13:23:01 +0200
commit3594c067804f1bb236eb5a82242db2f36482f7c2 (patch)
tree3bc896041c6740b157fae5ccc549e4abc1ff07b6 /src/hooks/sed.rs
parentput benchmark behind feature flag we can compile using stable rust (diff)
handle CTCP ACTION in sed module
Diffstat (limited to 'src/hooks/sed.rs')
-rw-r--r--src/hooks/sed.rs18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/hooks/sed.rs b/src/hooks/sed.rs
index d46a9bf..1ee0b20 100644
--- a/src/hooks/sed.rs
+++ b/src/hooks/sed.rs
@@ -24,7 +24,11 @@ impl Sed {
}
fn log_msg(&mut self, msg: Message) -> Result<()> {
- if let Command::PRIVMSG(target, text) = msg.command.clone() {
+ if let Command::PRIVMSG(target, mut text) = msg.command.clone() {
+ if text.starts_with("\x01ACTION") {
+ text = text.replace("\x01ACTION", "\x01\x01");
+ }
+
match self.0.get_mut(&target) {
Some(log) => {
if log.len() >= LOG_MAX_SIZE {
@@ -72,7 +76,17 @@ impl Sed {
.iter()
.rev()
.find(|(_, text)| cmd.expr.is_match(text) && !RE.with(|re| re.is_match(text)))
- .and_then(|(nick, text)| Some(format!("<{}> {}", nick, cmd.execute(text))))
+ .and_then(|(nick, text)| {
+ if text.starts_with("\x01\x01") {
+ Some(format!(
+ "* {}{}",
+ nick,
+ cmd.execute(text.replace("\x01", ""))
+ ))
+ } else {
+ Some(format!("<{}> {}", nick, cmd.execute(text)))
+ }
+ })
.map_or(Err(anyhow!("replace failed")), |v| Ok(v));
}
-12update garage config to 1.0Max Audron-2/+3 2024-08-12update to nixos 24.05Max Audron-27/+21 2024-07-03add acc serverMax Audron-2/+23 2024-03-29add rtmp and laplaceMax Audron-1/+200 2024-03-29add hydra secretsMax Audron-0/+0 2024-03-29add hydra secretsMax Audron-5/+35 2024-03-19extend postgresql hpa for podman ipsMax Audron-1/+1 2024-03-02update authentikMax Audron-8/+6 2024-03-02setup gitea oidcMax Audron-5/+18 2024-02-28add giteaMax Audron-2/+39 2024-02-28remove gitlab moduleMax Audron-25/+0 2024-02-26update d3fus phone wg pubkeyMarcin Maselko-1/+1 2024-02-26added d3fus nass to wg configMarcin Maselko-0/+9 2024-02-21set minecraft memoryMax Audron-0/+1 2024-02-21add minecraft server and move palworld to games moduleMax Audron-3/+56 2024-02-21set network manually for ns serversMax Audron-0/+51 2024-02-20update nixpkgs-unstableMax Audron-3/+3 2024-02-19update d3fus fritzbox wg portMarcin Maselko-1/+1 2024-02-19add xonotic serverMax Audron-1/+10