From: Egor Date: Tue, 23 Jan 2024 04:22:25 +0000 (+0200) Subject: add mask support to the WHO command X-Git-Url: https://git.patchysicp.xyz/?a=commitdiff_plain;h=0d90cffd3bfa67cc229dbddb3f8d56a85fb10eb1;p=patchyircd.git add mask support to the WHO command --- diff --git a/src/irc.c b/src/irc.c index de7f133..43a90ef 100644 --- a/src/irc.c +++ b/src/irc.c @@ -1019,7 +1019,6 @@ int processPacket(struct client_data *client, char *source, char *command, int a return err_notregistered(client), sendbuf(client), 0; if (argc == 0) return err_needmoreparams(client, command), sendbuf(client), 0; - // TODO: masks if (strchr("#&", args[0][0])) { struct channel *chan = findChannel(args[0]); // TODO: handle chanmode +s, umode +i @@ -1028,10 +1027,29 @@ int processPacket(struct client_data *client, char *source, char *command, int a map_foreach(&chan->members, 0, &cl) (args[1] ? rpl_whospcrpl(client, cl, chan, args[1]) : rpl_whoreply(client, cl, chan)), sendbuf(client); } - } else { + } else if (!strchr(args[0], '*')) { + // TODO: this probably needs better +i mode handling struct client_data *cl = findClient(args[0]); if (cl) (args[1] ? rpl_whospcrpl(client, cl, 0, args[1]) : rpl_whoreply(client, cl, 0)), sendbuf(client); + } else { + struct client_data *cl; + map_foreach(&client_map, 0, &cl) { + if (!irc_glob(cl->nuh, args[0])) + continue; + int visible = client->umode & UMODE_OPER || !(cl->umode & UMODE_INVISIBLE) || client == cl; + if (!visible) { + struct channel *chan; + map_foreach(&cl->channels, 0, &chan) { + if (map_get(&client->channels, chan->key)) { + visible = 1; + break; + } + } + } + if (visible) + (args[1] ? rpl_whospcrpl(client, cl, 0, args[1]) : rpl_whoreply(client, cl, 0)), sendbuf(client); + } } rpl_endofwho(client, args[0]), sendbuf(client); } else if(strcmp(command, "WHOIS") == 0) {