Add "server notice" command

This commit is contained in:
Simon Ser 2021-10-08 10:52:03 +02:00
parent e3b4687ac7
commit 5a2d6246ec
2 changed files with 29 additions and 0 deletions

View File

@ -329,6 +329,11 @@ abbreviated form, for instance *network* can be abbreviated as *net* or just
*server status*
Show some bouncer statistics. Only admins can query this information.
*server notice* <message>
Broadcast a notice. All currently connected bouncer users will receive the
message from the special _BouncerServ_ service. Only admins can broadcast a
notice.
# AUTHORS
Maintained by Simon Ser <contact@emersion.fr>, who is assisted by other

View File

@ -294,6 +294,11 @@ func init() {
handle: handleServiceServerStatus,
admin: true,
},
"notice": {
desc: "broadcast a notice to all connected bouncer users",
handle: handleServiceServerNotice,
admin: true,
},
},
admin: true,
},
@ -978,3 +983,22 @@ func handleServiceServerStatus(dc *downstreamConn, params []string) error {
sendServicePRIVMSG(dc, fmt.Sprintf("%v/%v users, %v downstreams, %v networks, %v channels", serverStats.Users, dbStats.Users, serverStats.Downstreams, dbStats.Networks, dbStats.Channels))
return nil
}
func handleServiceServerNotice(dc *downstreamConn, params []string) error {
if len(params) != 1 {
return fmt.Errorf("expected exactly one argument")
}
text := params[0]
dc.logger.Printf("broadcasting bouncer-wide NOTICE: %v", text)
broadcastMsg := &irc.Message{
Prefix: servicePrefix,
Command: "NOTICE",
Params: []string{"$" + dc.srv.Hostname, text},
}
dc.srv.forEachUser(func(u *user) {
u.events <- eventBroadcast{broadcastMsg}
})
return nil
}