return err_notregistered(client), sendbuf(client), 0;
if (argc == 0) // FIXME: error message
return 0;
- struct client_data *cl = findClient(args[0]);
- // TODO: mask and channel modes
- if (cl) {
- copy_strf(&databuf, ":%s 352 %s * %s %s %s %s %s%s :1 %s\n",
- hostname, client->nick, cl->username, cl->hostname, hostname, cl->nick,
- cl->away ? "G" : "H", cl->umode&UMODE_OPER ? "*" : "", cl->realname);
- sendbuf(client);
+ // TODO: masks
+ if (strchr("#&", args[0][0])) {
+ struct channel *chan = findChannel(args[0]);
+ // TODO: handle chanmode +s, umode +i
+ if (chan) {
+ struct trie_find *f = NULL;
+ if (trie_findfirst(&f, &chan->members) == 1)
+ do {
+ struct client_data *cl = f->n->value;
+ char prefix[2] = {0,0};
+ if (trie_get(&chan->o, cl->key))
+ prefix[0] = '@';
+ else if (trie_get(&chan->v, cl->key))
+ prefix[0] = '+';
+ copy_strf(&databuf, ":%s 352 %s %s %s %s %s %s %s%s%s :1 %s\n",
+ hostname, client->nick, chan->name, cl->username, cl->hostname, hostname, cl->nick,
+ cl->away ? "G" : "H", cl->umode&UMODE_OPER ? "*" : "", prefix, cl->realname);
+ sendbuf(client);
+ } while(trie_findnext(&f) == 1);
+ }
+ } else {
+ struct client_data *cl = findClient(args[0]);
+ if (cl) {
+ copy_strf(&databuf, ":%s 352 %s * %s %s %s %s %s%s :1 %s\n",
+ hostname, client->nick, cl->username, cl->hostname, hostname, cl->nick,
+ cl->away ? "G" : "H", cl->umode&UMODE_OPER ? "*" : "", cl->realname);
+ sendbuf(client);
+ }
}
copy_strf(&databuf, ":%s 315 %s %s :End of WHO list\n", hostname, client->nick, args[0]);
sendbuf(client);