diff --git a/CHANGELOG.md b/CHANGELOG.md index 1cf500d3..b336608e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/irc/help.go b/irc/help.go index 3dce40df..e0d726c8 100644 --- a/irc/help.go +++ b/irc/help.go @@ -190,13 +190,11 @@ channels). s modify how the channels are selected.`, //TODO(dan): Explain s in more specific detail }, "lusers": { - text: `LUSERS [ [ ] ] + text: `LUSERS [ []] -Returns statistics about the size of the network. -If called with no arguments, the statistics will reflect the entire network. -If is given, it will return only statistics reflecting the masked subset of the network. -If is given, the command will be forwarded to for evaluation.`, - //TODO(vegax87): Include network statistics and parameters +Shows statistics about the size of the network. If is given, only +returns stats for servers matching the given mask. If is given, the +command is processed by that server.`, }, "mode": { text: `MODE [ [...]] diff --git a/irc/server.go b/irc/server.go index 9c8b62fb..f2db47b0 100644 --- a/irc/server.go +++ b/irc/server.go @@ -1678,30 +1678,28 @@ func whowasHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool { return false } -// LUSERS [ [ ] ] +// LUSERS [ []] 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))