From 899ec1e2d49a3a5051517f86afeb148880cb53cd Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Tue, 28 Apr 2026 04:33:22 +0000 Subject: [PATCH] fix #2393 Add the bot tag to echo messages when applicable --- irc/channel.go | 2 +- irc/handlers.go | 6 +++--- irc/responsebuffer.go | 7 +++---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/irc/channel.go b/irc/channel.go index 57963734..1c7c351f 100644 --- a/irc/channel.go +++ b/irc/channel.go @@ -1368,7 +1368,7 @@ func (channel *Channel) SendSplitMessage(command string, minPrefixMode modes.Mod } // send echo-message - rb.addEchoMessage(clientOnlyTags, details.nickMask, details.accountName, command, chname, message) + rb.addEchoMessage(clientOnlyTags, details.nickMask, details.accountName, command, chname, message, isBot) var cache MessageCache cache.InitializeSplitMessage(channel.server, details.nickMask, details.accountName, isBot, clientOnlyTags, command, chname, message) diff --git a/irc/handlers.go b/irc/handlers.go index 33f9e5d3..58f7aee9 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -2402,10 +2402,11 @@ func dispatchMessageToTarget(client *Client, tags map[string]string, histType hi lowercaseTarget := strings.ToLower(target) service, isService := ErgoServices[lowercaseTarget] _, isZNC := zncHandlers[lowercaseTarget] + isBot := client.HasMode(modes.Bot) if isService || isZNC { details := client.Details() - rb.addEchoMessage(tags, details.nickMask, details.accountName, command, target, message) + rb.addEchoMessage(tags, details.nickMask, details.accountName, command, target, message, isBot) if histType != history.Privmsg { return // NOTICE and TAGMSG to services are ignored } @@ -2466,7 +2467,6 @@ func dispatchMessageToTarget(client *Client, tags map[string]string, histType hi } } - isBot := client.HasMode(modes.Bot) for _, session := range deliverySessions { hasTagsCap := session.capabilities.Has(caps.MessageTags) // don't send TAGMSG at all if they don't have the tags cap @@ -2482,7 +2482,7 @@ func dispatchMessageToTarget(client *Client, tags map[string]string, histType hi } // the originating session may get an echo message: - rb.addEchoMessage(tags, nickMaskString, accountName, command, tnick, message) + rb.addEchoMessage(tags, nickMaskString, accountName, command, tnick, message, isBot) if histType == history.Privmsg { //TODO(dan): possibly implement cooldown of away notifications to users if away, awayMessage := user.Away(); away { diff --git a/irc/responsebuffer.go b/irc/responsebuffer.go index cb59db89..2f01284a 100644 --- a/irc/responsebuffer.go +++ b/irc/responsebuffer.go @@ -148,20 +148,19 @@ func (rb *ResponseBuffer) AddSplitMessageFromClient(fromNickMask string, fromAcc } } -func (rb *ResponseBuffer) addEchoMessage(tags map[string]string, nickMask, accountName, command, target string, message utils.SplitMessage) { - // TODO fix isBot here +func (rb *ResponseBuffer) addEchoMessage(tags map[string]string, nickMask, accountName, command, target string, message utils.SplitMessage, isBot bool) { if rb.session.capabilities.Has(caps.EchoMessage) { hasTagsCap := rb.session.capabilities.Has(caps.MessageTags) if command == "TAGMSG" { if hasTagsCap { - rb.AddFromClient(message.Time, message.Msgid, nickMask, accountName, false, tags, command, target) + rb.AddFromClient(message.Time, message.Msgid, nickMask, accountName, isBot, tags, command, target) } } else { tagsToSend := tags if !hasTagsCap { tagsToSend = nil } - rb.AddSplitMessageFromClient(nickMask, accountName, false, tagsToSend, command, target, message) + rb.AddSplitMessageFromClient(nickMask, accountName, isBot, tagsToSend, command, target, message) } } }