From 744c6e3f6d9cd4982e06837db7348f8e7d406b6f Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 6 Oct 2021 12:02:49 +0200 Subject: [PATCH] Enable bot mode for BouncerServ See [1] for details. [1]: https://ircv3.net/specs/extensions/bot-mode --- downstream.go | 17 ++++++++++++++++- irc.go | 3 +++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/downstream.go b/downstream.go index 4a90140..fe23fe0 100644 --- a/downstream.go +++ b/downstream.go @@ -1388,6 +1388,8 @@ func (dc *downstreamConn) welcome(ctx context.Context) error { if dc.network != nil { isupport = append(isupport, fmt.Sprintf("BOUNCER_NETID=%v", dc.network.ID)) + } else { + isupport = append(isupport, "BOT=B") } if title := dc.srv.Config().Title; dc.network == nil && title != "" { isupport = append(isupport, "NETWORK="+encodeISUPPORT(title)) @@ -2195,13 +2197,21 @@ func (dc *downstreamConn) handleMessageRegistered(ctx context.Context, msg *irc. return nil } if maskCM == serviceNickCM { + flags := "H*" + if dc.network == nil { + flags += "B" + } else if uc := dc.upstream(); uc != nil { + if v := uc.isupport["BOT"]; v != nil && len(*v) == 1 { + flags += *v + } + } info := whoxInfo{ Token: whoxToken, Username: servicePrefix.User, Hostname: servicePrefix.Host, Server: dc.srv.Config().Hostname, Nickname: serviceNick, - Flags: "H*", + Flags: flags, Account: serviceNick, Realname: serviceRealname, } @@ -2301,6 +2311,11 @@ func (dc *downstreamConn) handleMessageRegistered(ctx context.Context, msg *irc. Command: rpl_whoisaccount, Params: []string{dc.nick, serviceNick, serviceNick, "is logged in as"}, }) + dc.SendMessage(&irc.Message{ + Prefix: dc.srv.prefix(), + Command: rpl_whoisbot, + Params: []string{dc.nick, serviceNick, "is a bot"}, + }) dc.SendMessage(&irc.Message{ Prefix: dc.srv.prefix(), Command: irc.RPL_ENDOFWHOIS, diff --git a/irc.go b/irc.go index 8e72dae..720d3f2 100644 --- a/irc.go +++ b/irc.go @@ -20,6 +20,9 @@ const ( rpl_whospcrpl = "354" rpl_whoisaccount = "330" err_invalidcapcmd = "410" + + // https://ircv3.net/specs/extensions/bot-mode + rpl_whoisbot = "335" ) const (