From 4bcfeae5a6dc994d2393daedcf2a1790edf0add2 Mon Sep 17 00:00:00 2001 From: delthas Date: Sat, 4 Apr 2020 04:57:20 +0200 Subject: [PATCH] Fill all fields of the service user prefix On some IRC clients, NOTICE messages from a user which does not have a user or host in its prefix (and therefore only have a Name, and look like prefixes of servers), are treated as server notices rather than user notices, and are treated differently. (For that matter, soju also considers NOTICE messages from users with only a Name in their prefix as special server messages). On most of these clients, NOTICE messages from a user are formatted differently and stand out from the large flow of incoming misceallenous server messages. This fills the service user with fake User and Host values so that NOTICE messages from it correctly appear as coming from a user. This is particularly useful in the context of connection and disconnect errors NOTICE messages that are broadcast from the service user to all relevant downstreams. --- service.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/service.go b/service.go index 8fb48cb..30e4b8e 100644 --- a/service.go +++ b/service.go @@ -12,6 +12,12 @@ import ( const serviceNick = "BouncerServ" +var servicePrefix = &irc.Prefix{ + Name: serviceNick, + User: serviceNick, + Host: serviceNick, +} + type serviceCommandSet map[string]*serviceCommand type serviceCommand struct { @@ -23,7 +29,7 @@ type serviceCommand struct { func sendServiceNOTICE(dc *downstreamConn, text string) { dc.SendMessage(&irc.Message{ - Prefix: &irc.Prefix{Name: serviceNick}, + Prefix: servicePrefix, Command: "NOTICE", Params: []string{dc.nick, text}, }) @@ -31,7 +37,7 @@ func sendServiceNOTICE(dc *downstreamConn, text string) { func sendServicePRIVMSG(dc *downstreamConn, text string) { dc.SendMessage(&irc.Message{ - Prefix: &irc.Prefix{Name: serviceNick}, + Prefix: servicePrefix, Command: "PRIVMSG", Params: []string{dc.nick, text}, })