Marshal NOTICE user prefixes and channels

NOTICE messages can be both special messages from the server (with no
prefix nick), or regular PRIVMSG-like messages from users. This commit
adds support for marshaling channel and user prefixes in the latter
case.
This commit is contained in:
delthas 2020-03-26 05:53:13 +01:00 committed by Simon Ser
parent 2966723ab4
commit 8c56e610ff
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48

View File

@ -204,9 +204,24 @@ func (uc *upstreamConn) handleMessage(msg *irc.Message) error {
case "NOTICE":
uc.logger.Print(msg)
uc.forEachDownstream(func(dc *downstreamConn) {
dc.SendMessage(msg)
})
if msg.Prefix.User == "" && msg.Prefix.Host == "" { // server message
uc.forEachDownstream(func(dc *downstreamConn) {
dc.SendMessage(msg)
})
} else { // regular user NOTICE
var nick, text string
if err := parseMessageParams(msg, &nick, &text); err != nil {
return err
}
uc.forEachDownstream(func(dc *downstreamConn) {
dc.SendMessage(&irc.Message{
Prefix: dc.marshalUserPrefix(uc, msg.Prefix),
Command: "NOTICE",
Params: []string{dc.marshalEntity(uc, nick), text},
})
})
}
case "CAP":
var subCmd string
if err := parseMessageParams(msg, nil, &subCmd); err != nil {