summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--chat.h5
-rw-r--r--command.c8
-rw-r--r--handle.c23
3 files changed, 35 insertions, 1 deletions
diff --git a/chat.h b/chat.h
index 9daa38c..34e1812 100644
--- a/chat.h
+++ b/chat.h
@@ -114,6 +114,11 @@ void ircSend(const char *ptr, size_t len);
 void ircFormat(const char *format, ...)
 	__attribute__((format(printf, 1, 2)));
 
+extern struct Replies {
+	size_t topic;
+	size_t names;
+} replies;
+
 void handle(struct Message msg);
 void command(size_t id, char *input);
 const char *commandIsPrivmsg(size_t id, const char *input);
diff --git a/command.c b/command.c
index 1d1c756..9879dbe 100644
--- a/command.c
+++ b/command.c
@@ -71,7 +71,15 @@ static void commandMe(size_t id, char *params) {
 }
 
 static void commandJoin(size_t id, char *params) {
+	size_t count = 1;
+	if (params) {
+		for (char *ch = params; *ch && *ch != ' '; ++ch) {
+			if (*ch == ',') count++;
+		}
+	}
 	ircFormat("JOIN %s\r\n", (params ? params : idNames[id]));
+	replies.topic += count;
+	replies.names += count;
 }
 
 static void commandPart(size_t id, char *params) {
diff --git a/handle.c b/handle.c
index 8ebc3b1..0780767 100644
--- a/handle.c
+++ b/handle.c
@@ -25,6 +25,8 @@
 
 #include "chat.h"
 
+struct Replies replies;
+
 static const char *CapNames[] = {
 #define X(name, id) [id##Bit] = name,
 	ENUM_CAP
@@ -156,7 +158,15 @@ static void handleReplyWelcome(struct Message *msg) {
 	require(msg, false, 1);
 	set(&self.nick, msg->params[0]);
 	completeTouch(None, self.nick, Default);
-	if (self.join) ircFormat("JOIN %s\r\n", self.join);
+	if (self.join) {
+		size_t count = 1;
+		for (const char *ch = self.join; *ch && *ch != ' '; ++ch) {
+			if (*ch == ',') count++;
+		}
+		ircFormat("JOIN %s\r\n", self.join);
+		replies.topic += count;
+		replies.names += count;
+	}
 }
 
 static void handleReplyISupport(struct Message *msg) {
@@ -278,6 +288,7 @@ static void handleQuit(struct Message *msg) {
 
 static void handleReplyNames(struct Message *msg) {
 	require(msg, false, 4);
+	if (!replies.names) return;
 	size_t id = idFor(msg->params[2]);
 	char buf[1024];
 	size_t len = 0;
@@ -302,8 +313,15 @@ static void handleReplyNames(struct Message *msg) {
 	);
 }
 
+static void handleReplyEndOfNames(struct Message *msg) {
+	(void)msg;
+	if (replies.names) replies.names--;
+}
+
 static void handleReplyNoTopic(struct Message *msg) {
 	require(msg, false, 2);
+	if (!replies.topic) return;
+	replies.topic--;
 	uiFormat(
 		idFor(msg->params[1]), Cold, tagTime(msg),
 		"There is no sign in \3%02d%s\3",
@@ -313,6 +331,8 @@ static void handleReplyNoTopic(struct Message *msg) {
 
 static void handleReplyTopic(struct Message *msg) {
 	require(msg, false, 3);
+	if (!replies.topic) return;
+	replies.topic--;
 	uiFormat(
 		idFor(msg->params[1]), Cold, tagTime(msg),
 		"The sign in \3%02d%s\3 reads: %s",
@@ -421,6 +441,7 @@ static const struct Handler {
 	{ "331", handleReplyNoTopic },
 	{ "332", handleReplyTopic },
 	{ "353", handleReplyNames },
+	{ "366", handleReplyEndOfNames },
 	{ "372", handleReplyMOTD },
 	{ "432", handleErrorErroneousNickname },
 	{ "433", handleErrorNicknameInUse },
class='logsubject'>Set bot mode on downgradeJune McEnroe 2021-09-15Enter capsicum in downgradeJune McEnroe 2021-09-15Factor out common parts of downgrade messagesJune McEnroe Also bump the message cap to 1024 because that is ostensibly useful for replying to older messages. 2021-09-14Add downgrade IRC botJune McEnroe 2021-09-14Sort by title if authors matchJune McEnroe There are probably better things to sort by but title definitely always exists. 2021-09-13Swap-remove tags as they're foundJune McEnroe This makes it even faster. From ~1s on a sqlite3.c amalgamation to ~0.85s. 2021-09-12Replace htagml regex with strncmpJune McEnroe Since ctags only ever produces regular expressions of the form /^re$/ or /^re/ with no other special characters, instead unescape the pattern and simply use strncmp. Running on a sqlite3.c amalgamation, the regex version takes ~37s while the strncmp version takes ~1s, producing identical output. Big win! 2021-09-11Also defer printing comment for lone close-parensJune McEnroe 2021-09-10Publish "git-comment"June McEnroe 2021-09-10Add git comment --pretty optionJune McEnroe 2021-09-08Defer printing comment if line is blank or closing braceJune McEnroe This fixes badly indented comments. 2021-09-08Up default min-repeat to 30 linesJune McEnroe 2021-09-08Handle dirty lines in git-commentJune McEnroe 2021-09-08Document and install git-commentJune McEnroe 2021-09-08Add repeat and all options to git-commentJune McEnroe 2021-09-08Add group threshold to git-commentJune McEnroe