3
0
mirror of https://github.com/ergochat/ergo.git synced 2026-05-07 07:57:59 +02:00
Add the bot tag to echo messages when applicable
This commit is contained in:
Shivaram Lingamneni 2026-04-28 04:33:22 +00:00
parent 147403ea73
commit 899ec1e2d4
3 changed files with 7 additions and 8 deletions

View File

@ -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)

View File

@ -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 {

View File

@ -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)
}
}
}