From 559557f67afc1e9003eaff0ba9d1ba33812ddb8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arsen=20Arsenovi=C4=87?= Date: Mon, 15 Nov 2021 16:07:35 +0100 Subject: [PATCH] irc: translate CTCP ACTION into _%s_ this matches discords behavior on /me --- pkg/sides/irc/irc.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pkg/sides/irc/irc.go b/pkg/sides/irc/irc.go index 1888cd9..48fe4d7 100644 --- a/pkg/sides/irc/irc.go +++ b/pkg/sides/irc/irc.go @@ -470,13 +470,25 @@ func (is *IRCSide) handleEvent(c *girc.Client, e girc.Event) { return } + content := e.Last() + + if ctcp := girc.DecodeCTCP(&e); ctcp != nil { + if ctcp.Reply { + return + } + + if ctcp.Command == girc.CTCP_ACTION { + content = fmt.Sprintf("_%s_", ctcp.Text) + } + } + is.Lock() defer is.Unlock() // this is too many but w/e permittedMentionIDs := make([]string, 10)[:0] - msg := is.highlightsRegex.ReplaceAllStringFunc(e.Last(), + msg := is.highlightsRegex.ReplaceAllStringFunc(content, func(match string) string { id, found := is.nickMap[match] if !found { -- 2.45.2