3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-10 22:19:31 +01:00

LUSERS: Minor cleanups, we don't need to worry about changelog lines for now

This commit is contained in:
Daniel Oaks 2017-01-17 22:49:14 +10:00
parent 750f0ffcb6
commit 298f4907ac
3 changed files with 13 additions and 19 deletions

View File

@ -13,9 +13,7 @@ New release of Oragono!
* Added ARM build (for Raspberry PIs and similar).
* Added automated connection throttling! See the new `connection-throttling` section in the config.
* Added `KLINE` and `UNKLINE` commands. Complementing `DLINE`'s per-IP and per-network bans, this lets you ban masks from the server.
* Added LUSERS command. It works for a single server for now (by @vegax87)
* Added `LUSERS` command (thanks @vegax87!).
### Changed
* Changed casemapping from "rfc7700" to "rfc7613", to match new draft spec.

View File

@ -190,13 +190,11 @@ channels). <elistcond>s modify how the channels are selected.`,
//TODO(dan): Explain <elistcond>s in more specific detail
},
"lusers": {
text: `LUSERS [ <mask> [ <target> ] ]
text: `LUSERS [<mask> [<server>]]
Returns statistics about the size of the network.
If called with no arguments, the statistics will reflect the entire network.
If <mask> is given, it will return only statistics reflecting the masked subset of the network.
If <target> is given, the command will be forwarded to <server> for evaluation.`,
//TODO(vegax87): Include network statistics and parameters
Shows statistics about the size of the network. If <mask> is given, only
returns stats for servers matching the given mask. If <server> is given, the
command is processed by that server.`,
},
"mode": {
text: `MODE <target> [<modestring> [<mode arguments>...]]

View File

@ -1678,30 +1678,28 @@ func whowasHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
return false
}
// LUSERS [ <mask> [ <target> ] ]
// LUSERS [<mask> [<server>]]
func lusersHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
//TODO(vegax87) Fix network statistics and additional parameters
var totalcount int
var invisiblecount int
var opercount int
var chancount int
server.clients.ByNickMutex.RLock()
defer server.clients.ByNickMutex.RUnlock()
for _, onlineusers := range server.clients.ByNick {
totalcount += 1
totalcount++
if onlineusers.flags[Invisible] {
invisiblecount += 1
invisiblecount++
}
if onlineusers.flags[Operator] {
opercount += 1
opercount++
}
}
for chans := range server.channels {
//Little hack just to avoid "variable declared but not used" error
_ = chans
chancount += 1
for range server.channels {
chancount++
}
client.Send(nil, server.name, RPL_LUSERCLIENT, client.nick, fmt.Sprintf("There are %d users and %d invisible on %d server(s)", totalcount, invisiblecount, 1))
client.Send(nil, server.name, RPL_LUSEROP, client.nick, fmt.Sprintf("%d operators online", opercount))