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 | |
| parent | b6f425b803d6dd8ba90a558a0cab58e0ca470e6e (diff) | |
| download | libreircd-83c7d5f26cc3dcc93967a694b6b07447e839d6c1.tar.gz libreircd-83c7d5f26cc3dcc93967a694b6b07447e839d6c1.zip | |
Add LIST command
Though it's kinda basic, but still
| -rw-r--r-- | handle.c | 23 | ||||
| -rw-r--r-- | reply.c | 13 |
2 files changed, 36 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 }, diff --git a/reply.c b/reply.c index de1d5c7..268e912 100644 --- a/reply.c +++ b/reply.c @@ -133,6 +133,19 @@ vreply(const struct Peer *peer, int number, va_list ap) getnick(peer), nick ), nick, _); + REPLY(322, WRITE( + ":%s 322 %s %s %s :%s", + hostname, + getnick(peer), + channel, + count, + topic + ), channel, count, topic, _); + REPLY(323, WRITE( + ":%s 323 %s :End of LIST", + hostname, + getnick(peer) + ), _); REPLY(324, WRITE( ":%s 324 %s %s +%s", hostname, |