From f5705ed2961c657266d19578569d0b0b0a111ffd Mon Sep 17 00:00:00 2001 From: Yash Karandikar Date: Tue, 25 Apr 2023 14:12:37 -0500 Subject: [PATCH] Fix pinging unknown users --- src/discord_irc.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/discord_irc.rs b/src/discord_irc.rs index b2bbab2..7557135 100644 --- a/src/discord_irc.rs +++ b/src/discord_irc.rs @@ -272,6 +272,7 @@ async fn discord_to_irc_processing( regex! { static PING_RE_1 = r"<@([0-9]+)>"; static PING_RE_2 = r"<@!([0-9]+)>"; + static PING_RE_3 = r"\{@([0-9]+)\}"; static EMOJI_RE = r"<:(\w+):[0-9]+>"; static CHANNEL_RE = r"<#([0-9]+)>"; static ROLE_RE = r"<@&([0-9]+)>"; @@ -317,6 +318,9 @@ async fn discord_to_irc_processing( ) .into_owned(); + // switch brackets of unknown pings + computed = PING_RE_1.replace_all(&computed, "{@$1}").into_owned(); + computed = { #[allow(clippy::enum_glob_use)] use pulldown_cmark::{Event::*, Tag::*}; @@ -380,5 +384,8 @@ async fn discord_to_irc_processing( new }; + // switch them back + computed = PING_RE_3.replace_all(&computed, "<@$1>").into_owned(); + computed }