From d7b5f5d12c9bccab6aa51b1582a90156780476e8 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 30 Mar 2022 14:15:39 +0200 Subject: [PATCH] downstream: set realname for network-less connections Send the user-wide realname config. We still need to handle SETNAME properly. --- downstream.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/downstream.go b/downstream.go index 49f6807..95e7f57 100644 --- a/downstream.go +++ b/downstream.go @@ -1175,13 +1175,26 @@ func (dc *downstreamConn) updateHost() { } func (dc *downstreamConn) updateRealname() { - if uc := dc.upstream(); uc != nil && uc.realname != dc.realname && dc.caps.IsEnabled("setname") { + if !dc.caps.IsEnabled("setname") { + return + } + + var realname string + if uc := dc.upstream(); uc != nil { + realname = uc.realname + } else if dc.network != nil { + realname = GetRealname(&dc.user.User, &dc.network.Network) + } else { + realname = GetRealname(&dc.user.User, nil) + } + + if realname != dc.realname { dc.SendMessage(&irc.Message{ Prefix: dc.prefix(), Command: "SETNAME", - Params: []string{uc.realname}, + Params: []string{realname}, }) - dc.realname = uc.realname + dc.realname = realname } }