From d510a022e35ef616fe359092f12e3364938c432e Mon Sep 17 00:00:00 2001 From: Egor Date: Wed, 4 May 2022 00:53:24 +0300 Subject: [PATCH] add LIST command --- irc.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 -- 2.56.0