mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-25 13:29:27 +01:00
Basic implementation of LUSERS command
This commit is contained in:
parent
2de273462b
commit
4797331962
@ -13,6 +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. 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.
|
||||||
|
@ -116,6 +116,10 @@ var Commands = map[string]Command{
|
|||||||
handler: listHandler,
|
handler: listHandler,
|
||||||
minParams: 0,
|
minParams: 0,
|
||||||
},
|
},
|
||||||
|
"LUSERS": {
|
||||||
|
handler: lusersHandler,
|
||||||
|
minParams: 0,
|
||||||
|
},
|
||||||
"MODE": {
|
"MODE": {
|
||||||
handler: modeHandler,
|
handler: modeHandler,
|
||||||
minParams: 1,
|
minParams: 1,
|
||||||
|
@ -189,6 +189,15 @@ Shows information on the given channels (or if none are given, then on all
|
|||||||
channels). <elistcond>s modify how the channels are selected.`,
|
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": {
|
||||||
|
text: `LUSERS [ <mask> [ <target> ] ]
|
||||||
|
|
||||||
|
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
|
||||||
|
},
|
||||||
"mode": {
|
"mode": {
|
||||||
text: `MODE <target> [<modestring> [<mode arguments>...]]
|
text: `MODE <target> [<modestring> [<mode arguments>...]]
|
||||||
|
|
||||||
|
@ -1677,3 +1677,38 @@ func whowasHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LUSERS [ <mask> [ <target> ] ]
|
||||||
|
func lusersHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
||||||
|
//TODO(vegax87) Fix Unknown connections 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
|
||||||
|
if onlineusers.flags[Invisible] {
|
||||||
|
invisiblecount += 1
|
||||||
|
}
|
||||||
|
if onlineusers.flags[Operator] {
|
||||||
|
opercount += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for chans := range server.channels {
|
||||||
|
//Little hack just to avoid "variable declared but not used" error
|
||||||
|
_ = 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_LUSEROP, client.nick, fmt.Sprintf("%d operators online", opercount))
|
||||||
|
client.Send(nil, server.name, RPL_LUSERUNKNOWN, client.nick, "X unknown connection(s)")
|
||||||
|
client.Send(nil, server.name, RPL_LUSERCHANNELS, client.nick, fmt.Sprintf("%d channels formed", chancount))
|
||||||
|
client.Send(nil, server.name, RPL_LUSERME, client.nick, fmt.Sprintf("I have %d clients and %d servers", totalcount, 1))
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user