Add "server notice" command
This commit is contained in:
parent
e3b4687ac7
commit
5a2d6246ec
@ -329,6 +329,11 @@ abbreviated form, for instance *network* can be abbreviated as *net* or just
|
|||||||
*server status*
|
*server status*
|
||||||
Show some bouncer statistics. Only admins can query this information.
|
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
|
# AUTHORS
|
||||||
|
|
||||||
Maintained by Simon Ser <contact@emersion.fr>, who is assisted by other
|
Maintained by Simon Ser <contact@emersion.fr>, who is assisted by other
|
||||||
|
24
service.go
24
service.go
@ -294,6 +294,11 @@ func init() {
|
|||||||
handle: handleServiceServerStatus,
|
handle: handleServiceServerStatus,
|
||||||
admin: true,
|
admin: true,
|
||||||
},
|
},
|
||||||
|
"notice": {
|
||||||
|
desc: "broadcast a notice to all connected bouncer users",
|
||||||
|
handle: handleServiceServerNotice,
|
||||||
|
admin: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
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))
|
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
|
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
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user