summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--catgirl.16
-rw-r--r--chat.h1
-rw-r--r--command.c26
-rw-r--r--handle.c31
4 files changed, 63 insertions, 1 deletions
diff --git a/catgirl.1 b/catgirl.1
index cea9e0a..fd8d40a 100644
--- a/catgirl.1
+++ b/catgirl.1
@@ -1,4 +1,4 @@
-.Dd February 16, 2020
+.Dd February 19, 2020
 .Dt CATGIRL 1
 .Os
 .
@@ -242,6 +242,8 @@ can be typed
 .Bl -tag -width Ds
 .It Ic /away Op Ar message
 Set or clear your away status.
+.It Ic /ban Op Ar mask ...
+List or ban masks from the channel.
 .It Ic /cs Ar command
 Send a command to ChanServ.
 .It Ic /invite Ar nick
@@ -274,6 +276,8 @@ Quit IRC.
 Send a raw IRC command.
 .It Ic /topic Op Ar topic
 Show or set the topic of the channel.
+.It Ic /unban Ar mask ...
+Unban masks from the channel.
 .It Ic /whois Ar nick
 Query information about a user.
 .El
diff --git a/chat.h b/chat.h
index d7f7c5c..e42cf7b 100644
--- a/chat.h
+++ b/chat.h
@@ -175,6 +175,7 @@ static inline void utilPush(struct Util *util, const char *arg) {
 
 extern struct Replies {
 	uint away;
+	uint ban;
 	uint join;
 	uint list;
 	uint names;
diff --git a/command.c b/command.c
index cc650da..c0b2ea2 100644
--- a/command.c
+++ b/command.c
@@ -143,6 +143,30 @@ static void commandKick(uint id, char *params) {
 	}
 }
 
+static void commandBan(uint id, char *params) {
+	if (params) {
+		int count = 1;
+		for (char *ch = params; *ch; ++ch) {
+			if (*ch == ' ') count++;
+		}
+		char b[ParamCap - 2] = "bbbbbbbbbbbbb";
+		ircFormat("MODE %s +%.*s %s\r\n", idNames[id], count, b, params);
+	} else {
+		ircFormat("MODE %s +b\r\n", idNames[id]);
+		replies.ban++;
+	}
+}
+
+static void commandUnban(uint id, char *params) {
+	if (!params) return;
+	int count = 1;
+	for (char *ch = params; *ch; ++ch) {
+		if (*ch == ' ') count++;
+	}
+	char b[ParamCap - 2] = "bbbbbbbbbbbbb";
+	ircFormat("MODE %s -%.*s %s\r\n", idNames[id], count, b, params);
+}
+
 static void commandList(uint id, char *params) {
 	(void)id;
 	if (params) {
@@ -264,6 +288,7 @@ static const struct Handler {
 	bool restricted;
 } Commands[] = {
 	{ "/away", .fn = commandAway },
+	{ "/ban", .fn = commandBan },
 	{ "/close", .fn = commandClose },
 	{ "/copy", .fn = commandCopy, .restricted = true },
 	{ "/cs", .fn = commandCS },
@@ -287,6 +312,7 @@ static const struct Handler {
 	{ "/quit", .fn = commandQuit },
 	{ "/quote", .fn = commandQuote, .restricted = true },
 	{ "/topic", .fn = commandTopic },
+	{ "/unban", .fn = commandUnban },
 	{ "/whois", .fn = commandWhois },
 	{ "/window", .fn = commandWindow },
 };
diff --git a/handle.c b/handle.c
index fd8b25f..4bfeb9f 100644
--- a/handle.c
+++ b/handle.c
@@ -424,6 +424,35 @@ static void handleTopic(struct Message *msg) {
 	}
 }
 
+static void handleReplyBanList(struct Message *msg) {
+	require(msg, false, 3);
+	if (!replies.ban) return;
+	uint id = idFor(msg->params[1]);
+	if (msg->params[3] && msg->params[4]) {
+		char since[sizeof("0000-00-00 00:00:00")];
+		time_t time = strtol(msg->params[4], NULL, 10);
+		strftime(since, sizeof(since), "%F %T", localtime(&time));
+		uiFormat(
+			id, Cold, tagTime(msg),
+			"Banned in \3%02d%s\3 by \3%02d%s\3 since %s: %s",
+			hash(msg->params[1]), msg->params[1],
+			completeColor(id, msg->params[3]), msg->params[3], since,
+			msg->params[2]
+		);
+	} else {
+		uiFormat(
+			id, Cold, tagTime(msg),
+			"Banned in \3%02d%s\3: %s",
+			hash(msg->params[1]), msg->params[1], msg->params[2]
+		);
+	}
+}
+
+static void handleReplyEndOfBanList(struct Message *msg) {
+	(void)msg;
+	if (replies.ban) replies.ban--;
+}
+
 static void handleInvite(struct Message *msg) {
 	require(msg, true, 2);
 	if (!strcmp(msg->params[0], self.nick)) {
@@ -719,6 +748,8 @@ static const struct Handler {
 	{ "332", handleReplyTopic },
 	{ "353", handleReplyNames },
 	{ "366", handleReplyEndOfNames },
+	{ "367", handleReplyBanList },
+	{ "368", handleReplyEndOfBanList },
 	{ "372", handleReplyMOTD },
 	{ "378", handleReplyWhoisGeneric },
 	{ "379", handleReplyWhoisGeneric },
0810b290ed48e617e6fe12&follow=1'>Switch gr alias back to git rebaseJune McEnroe I always type out git reset and sometimes still expect gr to be rebase... Never got used to it I guess. 2020-10-27Allow cd host: to cd to same path over sshJune McEnroe 2020-10-27Use SendEnv for cd host:pathJune McEnroe Works properly for weird paths, etc. 2020-10-27Allow cd host:path over sshJune McEnroe Requires AcceptEnv SSH_CD in the remote sshd_config. 2020-10-07Use mandoc -T utf8 for text.June McEnroe Don't depend on LANG being set. 2020-09-20Add The Awakened KingdomJune McEnroe A cute extra novella. Finally finished this series. 2020-09-12Move /opt/local back, cheat port select to use system manJune McEnroe This is not really how you're supposed to use the select system, I don't think, since the mandoc package actually creates those files, but it does work. This lets me actually use the git installed by MacPorts. 2020-09-12Move /opt/local behind /usr againJune McEnroe The reason I did this with pkgsrc was because I actually don't want the man(1) from mandoc, since it won't follow MANSECT. Same applies to MacPorts. I wish I could disable its man(1) with a variant or whatever. 2020-09-12Enable toc in cgit renderings of man pagesJune McEnroe But keep it disabled for READMEs since they always use non-standard sections and the TOC is just distracting there, I think. Also add the style so its h1 is the same size as the ones inside sections... 2020-09-11Install mandoc on macOSJune McEnroe 2020-09-11Rewrite install script yet againJune McEnroe 2020-09-11Remove NetBSD from install scriptJune McEnroe I never use it. 2020-09-11Use MacPorts rather than pkgsrcJune McEnroe My system is probably such a mess now... 2020-09-11Add debian VM name to sshJune McEnroe 2020-09-11Add influencer tweetJune McEnroe 2020-09-10Add The Kingdom of GodsJune McEnroe Reading has really slowed down :( 2020-09-07Add SunglassesJune McEnroe An IRC find. 2020-09-06Add Between the BreathsJune McEnroe One of those good songs from a soundtrack of a film that probably isn't? The summary sounds a lot more interesting than the title implies, at least. 2020-09-04Open /dev/tty in nudgeJune McEnroe This makes it work even when it's run connected to a pipe, i.e. as the notify command of catgirl... 2020-09-04Add nudgeJune McEnroe 2020-09-03Build fbclock with -lzJune McEnroe I guess this got lost somewhere, long ago... 2020-08-29Add tweets from retweetsJune McEnroe