Unify downstream PRIVMSG and NOTICE handling
We were doing some things wrong here, e.g. not sending echo messages for NOTICE.
This commit is contained in:
parent
fb50d70b70
commit
eca4c41223
@ -1905,7 +1905,7 @@ func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error {
|
|||||||
Command: "WHOIS",
|
Command: "WHOIS",
|
||||||
Params: params,
|
Params: params,
|
||||||
})
|
})
|
||||||
case "PRIVMSG":
|
case "PRIVMSG", "NOTICE":
|
||||||
var targetsStr, text string
|
var targetsStr, text string
|
||||||
if err := parseMessageParams(msg, &targetsStr, &text); err != nil {
|
if err := parseMessageParams(msg, &targetsStr, &text); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -1918,14 +1918,14 @@ func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if casemapASCII(name) == serviceNickCM {
|
if msg.Command == "PRIVMSG" && casemapASCII(name) == serviceNickCM {
|
||||||
if dc.caps["echo-message"] {
|
if dc.caps["echo-message"] {
|
||||||
echoTags := tags.Copy()
|
echoTags := tags.Copy()
|
||||||
echoTags["time"] = irc.TagValue(time.Now().UTC().Format(serverTimeLayout))
|
echoTags["time"] = irc.TagValue(time.Now().UTC().Format(serverTimeLayout))
|
||||||
dc.SendMessage(&irc.Message{
|
dc.SendMessage(&irc.Message{
|
||||||
Tags: echoTags,
|
Tags: echoTags,
|
||||||
Prefix: dc.prefix(),
|
Prefix: dc.prefix(),
|
||||||
Command: "PRIVMSG",
|
Command: msg.Command,
|
||||||
Params: []string{name, text},
|
Params: []string{name, text},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -1938,7 +1938,7 @@ func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if uc.network.casemap(upstreamName) == "nickserv" {
|
if msg.Command == "PRIVMSG" && uc.network.casemap(upstreamName) == "nickserv" {
|
||||||
dc.handleNickServPRIVMSG(uc, text)
|
dc.handleNickServPRIVMSG(uc, text)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1948,7 +1948,7 @@ func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error {
|
|||||||
}
|
}
|
||||||
uc.SendMessageLabeled(dc.id, &irc.Message{
|
uc.SendMessageLabeled(dc.id, &irc.Message{
|
||||||
Tags: tags,
|
Tags: tags,
|
||||||
Command: "PRIVMSG",
|
Command: msg.Command,
|
||||||
Params: []string{upstreamName, unmarshaledText},
|
Params: []string{upstreamName, unmarshaledText},
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -1963,36 +1963,11 @@ func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error {
|
|||||||
Name: uc.nick,
|
Name: uc.nick,
|
||||||
User: uc.username,
|
User: uc.username,
|
||||||
},
|
},
|
||||||
Command: "PRIVMSG",
|
Command: msg.Command,
|
||||||
Params: []string{upstreamName, text},
|
Params: []string{upstreamName, text},
|
||||||
}
|
}
|
||||||
uc.produce(upstreamName, echoMsg, dc)
|
uc.produce(upstreamName, echoMsg, dc)
|
||||||
|
|
||||||
uc.updateChannelAutoDetach(upstreamName)
|
|
||||||
}
|
|
||||||
case "NOTICE":
|
|
||||||
var targetsStr, text string
|
|
||||||
if err := parseMessageParams(msg, &targetsStr, &text); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
tags := copyClientTags(msg.Tags)
|
|
||||||
|
|
||||||
for _, name := range strings.Split(targetsStr, ",") {
|
|
||||||
uc, upstreamName, err := dc.unmarshalEntity(name)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
unmarshaledText := text
|
|
||||||
if uc.isChannel(upstreamName) {
|
|
||||||
unmarshaledText = dc.unmarshalText(uc, text)
|
|
||||||
}
|
|
||||||
uc.SendMessageLabeled(dc.id, &irc.Message{
|
|
||||||
Tags: tags,
|
|
||||||
Command: "NOTICE",
|
|
||||||
Params: []string{upstreamName, unmarshaledText},
|
|
||||||
})
|
|
||||||
|
|
||||||
uc.updateChannelAutoDetach(upstreamName)
|
uc.updateChannelAutoDetach(upstreamName)
|
||||||
}
|
}
|
||||||
case "TAGMSG":
|
case "TAGMSG":
|
||||||
|
Loading…
Reference in New Issue
Block a user