about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2025-10-28 20:13:48 -0400
committerJune McEnroe <june@causal.agency>2025-10-28 20:13:48 -0400
commiteb82baab2571dc46e70b0c0d9ec6069a506bedd5 (patch)
treea6382f60d75f17c2af37be52e54e1d1de67c9e95
parentAdd a testimonial (diff)
downloadcatgirl-eb82baab2571dc46e70b0c0d9ec6069a506bedd5.tar.gz
catgirl-eb82baab2571dc46e70b0c0d9ec6069a506bedd5.zip
Add /motd command
You've gotta be able to see the fun colour charts again.
-rw-r--r--catgirl.14
-rw-r--r--chat.c1
-rw-r--r--chat.h1
-rw-r--r--command.c8
-rw-r--r--handle.c13
5 files changed, 18 insertions, 9 deletions
diff --git a/catgirl.1 b/catgirl.1
index f2a2fbb..67bfdab 100644
--- a/catgirl.1
+++ b/catgirl.1
@@ -1,4 +1,4 @@
-.Dd May 24, 2024
+.Dd October 28, 2025
 .Dt CATGIRL 1
 .Os
 .
@@ -640,6 +640,8 @@ can usually contain glob-style wildcards.
 .It Ic /me Op Ar action
 Send an action message.
 These are used to write messages in third person.
+.It Ic /motd
+Show the server's message of the day again.
 .It Ic /msg Ar nick message
 Send a private message to someone.
 .It Ic /names
diff --git a/chat.c b/chat.c
index bc23c3f..b7743e8 100644
--- a/chat.c
+++ b/chat.c
@@ -399,6 +399,7 @@ int main(int argc, char *argv[]) {
 	ircFormat("CAP LS\r\n");
 	ircFormat("NICK %s\r\n", self.nicks[0]);
 	ircFormat("USER %s 0 * :%s\r\n", user, real);
+	replies[ReplyMOTD]++;
 
 	// Avoid disabling VINTR until main loop.
 	inputInit();
diff --git a/chat.h b/chat.h
index 369747c..32ba74a 100644
--- a/chat.h
+++ b/chat.h
@@ -285,6 +285,7 @@ enum Reply {
 	ReplyJoin,
 	ReplyList,
 	ReplyMode,
+	ReplyMOTD,
 	ReplyNames,
 	ReplyNamesAuto,
 	ReplyTopic,
diff --git a/command.c b/command.c
index 9b2b4eb..35e1d63 100644
--- a/command.c
+++ b/command.c
@@ -361,6 +361,13 @@ static void commandUninvex(uint id, char *params) {
 	channelListMode(id, '-', network.invex, params);
 }
 
+static void commandMOTD(uint id, char *params) {
+	(void)id;
+	(void)params;
+	ircFormat("MOTD\r\n");
+	replies[ReplyMOTD]++;
+}
+
 static void commandList(uint id, char *params) {
 	(void)id;
 	if (params) {
@@ -588,6 +595,7 @@ static const struct Handler {
 	{ "/list", commandList, 0, 0 },
 	{ "/me", commandMe, Multiline, 0 },
 	{ "/mode", commandMode, 0, 0 },
+	{ "/motd", commandMOTD, 0, 0 },
 	{ "/move", commandMove, 0, 0 },
 	{ "/msg", commandMsg, Multiline, 0 },
 	{ "/names", commandNames, 0, 0 },
diff --git a/handle.c b/handle.c
index 0cc7c04..0b01de6 100644
--- a/handle.c
+++ b/handle.c
@@ -343,16 +343,12 @@ static void handleReplyMOTD(struct Message *msg) {
 	char *line = msg->params[1];
 	urlScan(Network, NULL, line);
 	if (!strncmp(line, "- ", 2)) {
-		uiFormat(Network, Cold, tagTime(msg), "\3%d-\3\t%s", Gray, &line[2]);
+		uiFormat(Network, Warm, tagTime(msg), "\3%d-\3\t%s", Gray, &line[2]);
 	} else {
-		uiFormat(Network, Cold, tagTime(msg), "%s", line);
+		uiFormat(Network, Warm, tagTime(msg), "%s", line);
 	}
 }
 
-static void handleErrorNoMOTD(struct Message *msg) {
-	(void)msg;
-}
-
 static void handleReplyHelp(struct Message *msg) {
 	require(msg, false, 3);
 	urlScan(Network, NULL, msg->params[2]);
@@ -1378,10 +1374,11 @@ static const struct Handler {
 	{ "367", +ReplyBan, handleReplyBanList },
 	{ "368", -ReplyBan, NULL },
 	{ "369", -ReplyWhowas, handleReplyEndOfWhowas },
-	{ "372", 0, handleReplyMOTD },
+	{ "372", +ReplyMOTD, handleReplyMOTD },
+	{ "376", -ReplyMOTD, NULL },
 	{ "378", +ReplyWhois, handleReplyWhoisGeneric },
 	{ "379", +ReplyWhois, handleReplyWhoisGeneric },
-	{ "422", 0, handleErrorNoMOTD },
+	{ "422", -ReplyMOTD, NULL },
 	{ "432", 0, handleErrorErroneousNickname },
 	{ "433", 0, handleErrorNicknameInUse },
 	{ "437", 0, handleErrorNicknameInUse },