3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-10 22:19:31 +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": { "WHO": {
handler: whoHandler, handler: whoHandler,
minParams: 0, minParams: 1,
}, },
"WHOIS": { "WHOIS": {
handler: whoisHandler, handler: whoisHandler,

View File

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