3
0
mirror of https://github.com/ergochat/ergo.git synced 2025-01-03 00:22:34 +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 ARM build (for Raspberry PIs and similar).
* Added automated connection throttling! See the new `connection-throttling` section in the config. * 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 `KLINE` and `UNKLINE` commands. Complementing `DLINE`'s per-IP and per-network bans, this lets you ban masks from the server.
* Added `LUSERS` command (thanks @vegax87!).
* Added LUSERS command. It works for a single server for now (by @vegax87)
### Changed ### Changed
* Changed casemapping from "rfc7700" to "rfc7613", to match new draft spec. * 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 //TODO(dan): Explain <elistcond>s in more specific detail
}, },
"lusers": { "lusers": {
text: `LUSERS [ <mask> [ <target> ] ] text: `LUSERS [<mask> [<server>]]
Returns statistics about the size of the network. Shows statistics about the size of the network. If <mask> is given, only
If called with no arguments, the statistics will reflect the entire network. returns stats for servers matching the given mask. If <server> is given, the
If <mask> is given, it will return only statistics reflecting the masked subset of the network. command is processed by that server.`,
If <target> is given, the command will be forwarded to <server> for evaluation.`,
//TODO(vegax87): Include network statistics and parameters
}, },
"mode": { "mode": {
text: `MODE <target> [<modestring> [<mode arguments>...]] text: `MODE <target> [<modestring> [<mode arguments>...]]

View File

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