From: Egor Date: Tue, 3 May 2022 21:53:24 +0000 (+0300) Subject: add LIST command X-Git-Url: https://git.patchysicp.xyz/?a=commitdiff_plain;h=d510a022e35ef616fe359092f12e3364938c432e;p=patchyircd.git add LIST command --- diff --git a/irc.c b/irc.c index 369e98b..536a432 100644 --- a/irc.c +++ b/irc.c @@ -321,6 +321,21 @@ int processPacket(struct client_data *client) { goto unknown; } } + } else if(strcmp(command, "LIST") == 0) { + copy_strf(&databuf, ":%s 321 %s Channel :Users Name\n", hostname, client->nick); + send_log(client->FD, databuf.buf, databuf.len, 0); + struct trie_find *f = NULL; + if (trie_findfirst(&f, &channel_map) == 1) + do { + struct channel *chan = f->n->value; + //copy_strf(&databuf, ":%s 322 %s %s %d :%s\n", hostname, client->nick, + // channel->name, channel->member_count, channel->topic ? channel->topic : ""); + copy_strf(&databuf, ":%s 322 %s %s 0 :%s\n", hostname, client->nick, + channel->name, channel->topic ? channel->topic : ""); + send_log(client->FD, databuf.buf, databuf.len, 0); + } while(trie_findnext(&f) == 1); + copy_strf(&databuf, ":%s 323 %s :End of /LIST\n", hostname, client->nick); + send_log(client->FD, databuf.buf, databuf.len, 0); } else if(strcmp(command, "NAMES") == 0) { // TODO: actual channel support if (!client->nick) // FIXME: error message