3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-12-26 04:32:36 +01:00

WHO: Require first param, matching other servers

This commit is contained in:
Daniel Oaks 2017-11-19 10:10:10 +10:00
parent bec050208d
commit 8036df92fc
2 changed files with 8 additions and 7 deletions

View File

@ -285,7 +285,7 @@ var Commands = map[string]Command{
},
"WHO": {
handler: whoHandler,
minParams: 0,
minParams: 1,
},
"WHOIS": {
handler: whoisHandler,

View File

@ -1022,7 +1022,10 @@ func whoChannel(client *Client, channel *Channel, friends ClientSet) {
// WHO [ <mask> [ "o" ] ]
func whoHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
friends := client.Friends()
if msg.Params[0] == "" {
client.Send(nil, server.name, ERR_UNKNOWNERROR, client.nick, "WHO", "First param must be a mask or channel")
return false
}
var mask string
if len(msg.Params) > 0 {
@ -1034,6 +1037,8 @@ func whoHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
mask = casefoldedMask
}
friends := client.Friends()
//TODO(dan): is this used and would I put this param in the Modern doc?
// if not, can we remove it?
//var operatorOnly bool
@ -1041,11 +1046,7 @@ func whoHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
// operatorOnly = true
//}
if mask == "" {
for _, channel := range server.channels.Channels() {
whoChannel(client, channel, friends)
}
} else if mask[0] == '#' {
if mask[0] == '#' {
// TODO implement wildcard matching
//TODO(dan): ^ only for opers
channel := server.channels.Get(mask)