Enable bot mode for BouncerServ

See [1] for details.

[1]: https://ircv3.net/specs/extensions/bot-mode
This commit is contained in:
Simon Ser 2021-10-06 12:02:49 +02:00
parent 777adbd5e1
commit 744c6e3f6d
2 changed files with 19 additions and 1 deletions

View File

@ -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,

3
irc.go
View File

@ -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 (