Changeset 562 in code for trunk/downstream.go


Ignore:
Timestamp:
Jun 23, 2021, 4:17:30 PM (4 years ago)
Author:
contact
Message:

Unify downstream PRIVMSG and NOTICE handling

We were doing some things wrong here, e.g. not sending echo messages
for NOTICE.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/downstream.go

    r560 r562  
    19061906                        Params:  params,
    19071907                })
    1908         case "PRIVMSG":
     1908        case "PRIVMSG", "NOTICE":
    19091909                var targetsStr, text string
    19101910                if err := parseMessageParams(msg, &targetsStr, &text); err != nil {
     
    19191919                        }
    19201920
    1921                         if casemapASCII(name) == serviceNickCM {
     1921                        if msg.Command == "PRIVMSG" && casemapASCII(name) == serviceNickCM {
    19221922                                if dc.caps["echo-message"] {
    19231923                                        echoTags := tags.Copy()
     
    19261926                                                Tags:    echoTags,
    19271927                                                Prefix:  dc.prefix(),
    1928                                                 Command: "PRIVMSG",
     1928                                                Command: msg.Command,
    19291929                                                Params:  []string{name, text},
    19301930                                        })
     
    19391939                        }
    19401940
    1941                         if uc.network.casemap(upstreamName) == "nickserv" {
     1941                        if msg.Command == "PRIVMSG" && uc.network.casemap(upstreamName) == "nickserv" {
    19421942                                dc.handleNickServPRIVMSG(uc, text)
    19431943                        }
     
    19491949                        uc.SendMessageLabeled(dc.id, &irc.Message{
    19501950                                Tags:    tags,
    1951                                 Command: "PRIVMSG",
     1951                                Command: msg.Command,
    19521952                                Params:  []string{upstreamName, unmarshaledText},
    19531953                        })
     
    19641964                                        User: uc.username,
    19651965                                },
    1966                                 Command: "PRIVMSG",
     1966                                Command: msg.Command,
    19671967                                Params:  []string{upstreamName, text},
    19681968                        }
    19691969                        uc.produce(upstreamName, echoMsg, dc)
    1970 
    1971                         uc.updateChannelAutoDetach(upstreamName)
    1972                 }
    1973         case "NOTICE":
    1974                 var targetsStr, text string
    1975                 if err := parseMessageParams(msg, &targetsStr, &text); err != nil {
    1976                         return err
    1977                 }
    1978                 tags := copyClientTags(msg.Tags)
    1979 
    1980                 for _, name := range strings.Split(targetsStr, ",") {
    1981                         uc, upstreamName, err := dc.unmarshalEntity(name)
    1982                         if err != nil {
    1983                                 return err
    1984                         }
    1985 
    1986                         unmarshaledText := text
    1987                         if uc.isChannel(upstreamName) {
    1988                                 unmarshaledText = dc.unmarshalText(uc, text)
    1989                         }
    1990                         uc.SendMessageLabeled(dc.id, &irc.Message{
    1991                                 Tags:    tags,
    1992                                 Command: "NOTICE",
    1993                                 Params:  []string{upstreamName, unmarshaledText},
    1994                         })
    19951970
    19961971                        uc.updateChannelAutoDetach(upstreamName)
Note: See TracChangeset for help on using the changeset viewer.