diff --git a/downstream.go b/downstream.go index 5782250..7a39423 100644 --- a/downstream.go +++ b/downstream.go @@ -620,6 +620,17 @@ func (dc *downstreamConn) updateSupportedCaps() { } } +func (dc *downstreamConn) updateNick() { + if uc := dc.upstream(); uc != nil && uc.nick != dc.nick { + dc.SendMessage(&irc.Message{ + Prefix: dc.prefix(), + Command: "NICK", + Params: []string{uc.nick}, + }) + dc.nick = uc.nick + } +} + func sanityCheckServer(addr string) error { dialer := net.Dialer{Timeout: 30 * time.Second} conn, err := tls.DialWithDialer(&dialer, "tcp", addr, nil) @@ -777,6 +788,8 @@ func (dc *downstreamConn) welcome() error { Params: []string{dc.nick, "No MOTD"}, }) + dc.updateNick() + dc.forEachUpstream(func(uc *upstreamConn) { for _, ch := range uc.channels { if !ch.complete { @@ -935,6 +948,15 @@ func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error { dc.forEachUpstream(func(uc *upstreamConn) { uc.SendMessage(msg) }) + + if dc.upstream() == nil && dc.nick != nick { + dc.SendMessage(&irc.Message{ + Prefix: dc.prefix(), + Command: "NICK", + Params: []string{nick}, + }) + dc.nick = nick + } case "JOIN": var namesStr string if err := parseMessageParams(msg, &namesStr); err != nil { diff --git a/upstream.go b/upstream.go index efedbea..61d7297 100644 --- a/upstream.go +++ b/upstream.go @@ -656,6 +656,10 @@ func (uc *upstreamConn) handleMessage(msg *irc.Message) error { uc.forEachDownstream(func(dc *downstreamConn) { dc.SendMessage(dc.marshalMessage(msg, uc.network)) }) + } else { + uc.forEachDownstream(func(dc *downstreamConn) { + dc.updateNick() + }) } case "JOIN": if msg.Prefix == nil { diff --git a/user.go b/user.go index 13d51e8..dacf13b 100644 --- a/user.go +++ b/user.go @@ -298,6 +298,8 @@ func (u *user) run() { uc.forEachDownstream(func(dc *downstreamConn) { dc.updateSupportedCaps() sendServiceNOTICE(dc, fmt.Sprintf("connected to %s", uc.network.GetName())) + + dc.updateNick() }) uc.network.lastError = nil case eventUpstreamDisconnected: