Browse Source

WHO: Require first param, matching other servers

tags/v0.10.3
Daniel Oaks 6 years ago
parent
commit
8036df92fc
2 changed files with 8 additions and 7 deletions
  1. 1
    1
      irc/commands.go
  2. 7
    6
      irc/server.go

+ 1
- 1
irc/commands.go View File

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

+ 7
- 6
irc/server.go View File

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

Loading…
Cancel
Save