From 83c7d5f26cc3dcc93967a694b6b07447e839d6c1 Mon Sep 17 00:00:00 2001 From: Nakidai Date: Thu, 12 Feb 2026 22:47:39 +0300 Subject: Add LIST command Though it's kinda basic, but still --- handle.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'handle.c') diff --git a/handle.c b/handle.c index 903a4f4..9c4590a 100644 --- a/handle.c +++ b/handle.c @@ -118,6 +118,28 @@ kick(struct Message *msg, struct Peer *peer) return 0; } +static int +list(struct Message *msg, struct Peer *peer) +{ + /* enough to store 2^209, mail me when this become small for a user count */ + static char count[64]; + size_t i; + int one; + + ensure(peer->type, reply(peer, 451), 0); + one = msg->params[0] && *msg->params[0]; + + for (i = 0; i < channels_c; ++i) + if (!one || !strcmp(channels[i].name, msg->params[0])) + { + snprintf(count, sizeof(count), "%zu", channels[i].peers_c); + reply(peer, 322, channels[i].name, count, ""); + } + reply(peer, 323); + + return 0; +} + static int mode_channel(struct Message *msg, struct Peer *peer) { @@ -615,6 +637,7 @@ static struct Handler { { { "join", join }, { "kick", kick }, + { "list", list }, { "mode", mode }, { "names", names }, { "nick", nick }, -- cgit 1.4.1