From 8b185924f2f8f8bc8b374e0ab4f8074c21e7ccff Mon Sep 17 00:00:00 2001 From: Tim Zabel Date: Wed, 18 Aug 2021 15:01:55 -0400 Subject: [PATCH] Add handling for IRC actions (/me). --- internal/handlers/irc/handlers.go | 9 ++++++++- internal/handlers/irc/handlers_test.go | 6 +++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/internal/handlers/irc/handlers.go b/internal/handlers/irc/handlers.go index ba5edf67..fdfdb0e3 100644 --- a/internal/handlers/irc/handlers.go +++ b/internal/handlers/irc/handlers.go @@ -82,7 +82,14 @@ func messageHandler(c ClientInterface) func(*girc.Client, girc.Event) { if !(checkBlacklist(c, e.Source.Name)) { if e.IsFromChannel() { - formatted := c.IRCSettings().Prefix + e.Source.Name + c.IRCSettings().Suffix + " " + e.Params[1] + formatted := "" + if e.IsAction() { + msg := e.Last() + // Strips out ACTION word from text + formatted = "* " + e.Source.Name + " " + msg[8:len(msg)-1] + } else { + formatted = c.IRCSettings().Prefix + e.Source.Name + c.IRCSettings().Suffix + " " + e.Params[1] + } if hasNoForwardPrefix(c, e.Params[1]) { return // sender didn't want this forwarded diff --git a/internal/handlers/irc/handlers_test.go b/internal/handlers/irc/handlers_test.go index 28cf7e41..5d9ac267 100644 --- a/internal/handlers/irc/handlers_test.go +++ b/internal/handlers/irc/handlers_test.go @@ -533,9 +533,9 @@ func TestMessageHandlerNoForward(t *testing.T) { defer ctrl.Finish() ircSettings := internal.IRCSettings{ - IRCBlacklist: []string{}, - Prefix: "<<", - Suffix: ">>", + IRCBlacklist: []string{}, + Prefix: "<<", + Suffix: ">>", NoForwardPrefix: "[off]", }