summary refs log tree commit diff
path: root/chat.c
diff options
context:
space:
mode:
authorCurtis McEnroe2018-08-03 18:58:19 -0400
committerCurtis McEnroe2018-08-03 18:58:19 -0400
commitc609684d2bb7b3e544225b49b748f9a6fa15b4f0 (patch)
treeabba9a426e1f2277f7a66039dc01b6e7b1be6134 /chat.c
parent3b490562d4b531218510e907e3b4dd18f946d066 (diff)
Send a WHO in response to NAMES to get usernames
Other than this slight hack, I think coloring by username rather than
nick is a much better idea.
Diffstat (limited to 'chat.c')
-rw-r--r--chat.c36
1 files changed, 31 insertions, 5 deletions
diff --git a/chat.c b/chat.c
index 0303004..7058802 100644
--- a/chat.c
+++ b/chat.c
@@ -294,14 +294,38 @@ static void handleTopic(char *prefix, char *params) {
 	uiTopic(topic);
 }
 
-static void handle353(char *prefix, char *params) {
+static void handle366(char *prefix, char *params) {
 	(void)prefix;
 	shift(&params);
+	char *chan = shift(&params);
+	clientFmt("WHO %s\r\n", chan);
+}
+
+static char whoBuf[4096];
+static size_t whoLen;
+static void handle352(char *prefix, char *params) {
+	(void)prefix;
+	shift(&params);
+	shift(&params);
+	char *user = shift(&params);
+	shift(&params);
+	shift(&params);
+	char *nick = shift(&params);
+	whoLen += snprintf(
+		&whoBuf[whoLen], sizeof(whoBuf) - whoLen,
+		"%s\3%d%s\3",
+		(whoLen ? ", " : ""), color(user), nick
+	);
+}
+static void handle315(char *prefix, char *params) {
+	(void)prefix;
 	shift(&params);
 	char *chan = shift(&params);
-	char *names = shift(&params);
-	// TODO: Do a WHO instead to get usernames
-	uiFmt("In %s are %s", chan, names);
+	whoLen = 0;
+	uiFmt(
+		"In \3%d%s\3 are %s",
+		color(chan), chan, whoBuf
+	);
 }
 
 static void handlePrivmsg(char *prefix, char *params) {
@@ -324,8 +348,10 @@ static const struct {
 	Handler handler;
 } HANDLERS[] = {
 	{ "001", handle001 },
+	{ "315", handle315 },
 	{ "332", handle332 },
-	{ "353", handle353 },
+	{ "352", handle352 },
+	{ "366", handle366 },
 	{ "JOIN", handleJoin },
 	{ "NOTICE", handleNotice },
 	{ "PART", handlePart },