Add support for downstream NICK to a single upstream

Users often have different nicks on different upstreams, and we should
support changing the user nick on a single upstream.

This adds support for a new trivial extension, `NICK nick/network`,
which will change the nick on the specified network, and do nothing for
the other networks.

git-svn-id: file:///srv/svn/repo/suika/trunk@297 f0ae65fe-ee39-954e-97ec-027ff2717ef4
This commit is contained in:
delthas 2020-05-27 21:43:04 +00:00
parent fe27882fd8
commit 4ca2ebb98f

View File

@ -933,9 +933,18 @@ func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error {
return err
}
var upstream *upstreamConn
if dc.upstream() == nil {
uc, unmarshaledNick, err := dc.unmarshalEntity(nick)
if err == nil { // NICK nick/network: NICK only on a specific upstream
upstream = uc
nick = unmarshaledNick
}
}
var err error
dc.forEachNetwork(func(n *network) {
if err != nil {
if err != nil || (upstream != nil && upstream.network != n) {
return
}
n.Nick = nick
@ -946,7 +955,13 @@ func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error {
}
dc.forEachUpstream(func(uc *upstreamConn) {
uc.SendMessage(msg)
if upstream != nil && upstream != uc {
return
}
uc.SendMessage(&irc.Message{
Command: "NICK",
Params: []string{nick},
})
})
if dc.upstream() == nil && dc.nick != nick {