summary refs log tree commit diff
path: root/handle.c
diff options
context:
space:
mode:
Diffstat (limited to 'handle.c')
-rw-r--r--handle.c23
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 },