Changeset 171 in code for trunk/upstream.go


Ignore:
Timestamp:
Mar 27, 2020, 8:12:16 PM (5 years ago)
Author:
delthas
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/upstream.go

    r165 r171  
    205205                uc.logger.Print(msg)
    206206
    207                 uc.forEachDownstream(func(dc *downstreamConn) {
    208                         dc.SendMessage(msg)
    209                 })
     207                if msg.Prefix.User == "" && msg.Prefix.Host == "" { // server message
     208                        uc.forEachDownstream(func(dc *downstreamConn) {
     209                                dc.SendMessage(msg)
     210                        })
     211                } else { // regular user NOTICE
     212                        var nick, text string
     213                        if err := parseMessageParams(msg, &nick, &text); err != nil {
     214                                return err
     215                        }
     216
     217                        uc.forEachDownstream(func(dc *downstreamConn) {
     218                                dc.SendMessage(&irc.Message{
     219                                        Prefix:  dc.marshalUserPrefix(uc, msg.Prefix),
     220                                        Command: "NOTICE",
     221                                        Params:  []string{dc.marshalEntity(uc, nick), text},
     222                                })
     223                        })
     224                }
    210225        case "CAP":
    211226                var subCmd string
Note: See TracChangeset for help on using the changeset viewer.