diff options
| author | Nakidai <nakidai@disroot.org> | 2026-02-12 22:47:39 +0300 |
|---|---|---|
| committer | Nakidai <nakidai@disroot.org> | 2026-02-12 22:47:39 +0300 |
| commit | 83c7d5f26cc3dcc93967a694b6b07447e839d6c1 (patch) | |
| tree | 141d5693b773bc3ab2764c365fbd61afaaeab60e /handle.c | |
| parent | b6f425b803d6dd8ba90a558a0cab58e0ca470e6e (diff) | |
| download | libreircd-83c7d5f26cc3dcc93967a694b6b07447e839d6c1.tar.gz libreircd-83c7d5f26cc3dcc93967a694b6b07447e839d6c1.zip | |
Add LIST command
Though it's kinda basic, but still
Diffstat (limited to 'handle.c')
| -rw-r--r-- | handle.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/handle.c b/handle.c index 903a4f4..9c4590a 100644 --- a/handle.c +++ b/handle.c @@ -119,6 +119,28 @@ kick(struct Message *msg, struct Peer *peer) } 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) { const struct ChannelModeParam *parsed; @@ -615,6 +637,7 @@ static struct Handler { { { "join", join }, { "kick", kick }, + { "list", list }, { "mode", mode }, { "names", names }, { "nick", nick }, |