Skip to content

Commit

Permalink
Add handling for IRC actions (/me).
Browse files Browse the repository at this point in the history
  • Loading branch information
Tjzabel authored Aug 18, 2021
1 parent ae77468 commit 8b18592
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 8 additions & 1 deletion internal/handlers/irc/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions internal/handlers/irc/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]",
}

Expand Down

0 comments on commit 8b18592

Please sign in to comment.