about summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--catgirl.12
-rw-r--r--chat.h3
-rw-r--r--command.c11
-rw-r--r--handle.c20
4 files changed, 35 insertions, 1 deletions
diff --git a/catgirl.1 b/catgirl.1
index 518f830..dc5aefb 100644
--- a/catgirl.1
+++ b/catgirl.1
@@ -179,6 +179,8 @@ can be typed
 .Bl -tag -width Ds
 .It Ic /join Ar channel
 Join a channel.
+.It Ic /list Op Ar channel
+List channels.
 .It Ic /me Op Ar action
 Send an action message.
 .It Ic /msg Ar nick message
diff --git a/chat.h b/chat.h
index aa2f87c..6af5ef7 100644
--- a/chat.h
+++ b/chat.h
@@ -133,8 +133,9 @@ void ircFormat(const char *format, ...)
 
 extern struct Replies {
 	size_t join;
-	size_t topic;
+	size_t list;
 	size_t names;
+	size_t topic;
 	size_t whois;
 } replies;
 
diff --git a/command.c b/command.c
index 3505a5e..8166e2b 100644
--- a/command.c
+++ b/command.c
@@ -125,6 +125,16 @@ static void commandNames(size_t id, char *params) {
 	replies.names++;
 }
 
+static void commandList(size_t id, char *params) {
+	(void)id;
+	if (params) {
+		ircFormat("LIST :%s\r\n", params);
+	} else {
+		ircFormat("LIST\r\n");
+	}
+	replies.list++;
+}
+
 static void commandWhois(size_t id, char *params) {
 	(void)id;
 	if (!params) return;
@@ -201,6 +211,7 @@ static const struct Handler {
 	{ "/debug", .fn = commandDebug, .restricted = true },
 	{ "/help", .fn = commandHelp },
 	{ "/join", .fn = commandJoin, .restricted = true },
+	{ "/list", .fn = commandList },
 	{ "/me", .fn = commandMe },
 	{ "/msg", .fn = commandMsg, .restricted = true },
 	{ "/names", .fn = commandNames },
diff --git a/handle.c b/handle.c
index 0db362b..260d43c 100644
--- a/handle.c
+++ b/handle.c
@@ -411,6 +411,24 @@ static void handleTopic(struct Message *msg) {
 	}
 }
 
+static void handleReplyList(struct Message *msg) {
+	require(msg, false, 4);
+	if (!replies.list) return;
+	uiFormat(
+		Network, Warm, tagTime(msg),
+		"In \3%02d%s\3 are %ld under the banner: %s",
+		hash(msg->params[1]), msg->params[1],
+		strtol(msg->params[2], NULL, 10),
+		msg->params[3]
+	);
+}
+
+static void handleReplyListEnd(struct Message *msg) {
+	(void)msg;
+	if (!replies.list) return;
+	replies.list--;
+}
+
 static void handleReplyWhoisUser(struct Message *msg) {
 	require(msg, false, 6);
 	if (!replies.whois) return;
@@ -657,6 +675,8 @@ static const struct Handler {
 	{ "317", handleReplyWhoisIdle },
 	{ "318", handleReplyEndOfWhois },
 	{ "319", handleReplyWhoisChannels },
+	{ "322", handleReplyList },
+	{ "323", handleReplyListEnd },
 	{ "330", handleReplyWhoisGeneric },
 	{ "331", handleReplyNoTopic },
 	{ "332", handleReplyTopic },