]> PatchyGit - patchyircd.git/commitdiff
add LIST command
authorEgor <egor@patchysicp.xyz>
Tue, 3 May 2022 21:53:24 +0000 (00:53 +0300)
committerEgor <egor@patchysicp.xyz>
Tue, 3 May 2022 21:53:24 +0000 (00:53 +0300)
irc.c

diff --git a/irc.c b/irc.c
index 369e98b..536a432 100644 (file)
--- 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