about summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--catgirl.110
-rw-r--r--chat.h2
-rw-r--r--command.c8
-rw-r--r--handle.c16
4 files changed, 36 insertions, 0 deletions
diff --git a/catgirl.1 b/catgirl.1
index ae7fe52..09536da 100644
--- a/catgirl.1
+++ b/catgirl.1
@@ -328,6 +328,9 @@ command is likely needed
 for command output.
 .It Ic /say Ar message
 Send a regular message.
+.It Ic /setname Ar name
+Update realname
+if supported by the server.
 .It Ic /topic Op Ar topic
 Show or set the topic of the channel.
 Press
@@ -735,6 +738,13 @@ ignore = * [JPQ][OAU][IR][NT] #example
 .Re
 .It
 .Rs
+.%A Janne Mareike Koschinski
+.%T IRCv3 setname Extension
+.%I IRCv3 Working Group
+.%U https://ircv3.net/specs/extensions/setname
+.Re
+.It
+.Rs
 .%A Mantas Mikul\[u0117]nas
 .%T IRCv3.2 userhost-in-names Extension
 .%I IRCv3 Working Group
diff --git a/chat.h b/chat.h
index 19e4eeb..82ffded 100644
--- a/chat.h
+++ b/chat.h
@@ -171,6 +171,7 @@ extern struct Network {
 	X("multi-prefix", CapMultiPrefix) \
 	X("sasl", CapSASL) \
 	X("server-time", CapServerTime) \
+	X("setname", CapSetname) \
 	X("userhost-in-names", CapUserhostInNames)
 
 enum Cap {
@@ -256,6 +257,7 @@ extern struct Replies {
 	uint list;
 	uint mode;
 	uint names;
+	uint setname;
 	uint topic;
 	uint who;
 	uint whois;
diff --git a/command.c b/command.c
index 3af1246..199a561 100644
--- a/command.c
+++ b/command.c
@@ -159,6 +159,13 @@ static void commandAway(uint id, char *params) {
 	replies.away++;
 }
 
+static void commandSetname(uint id, char *params) {
+	(void)id;
+	if (!params) return;
+	ircFormat("SETNAME :%s\r\n", params);
+	replies.setname++;
+}
+
 static void commandTopic(uint id, char *params) {
 	if (params) {
 		ircFormat("TOPIC %s :%s\r\n", idNames[id], params);
@@ -486,6 +493,7 @@ static const struct Handler {
 	{ "/quit", commandQuit, 0 },
 	{ "/quote", commandQuote, Multiline | Restricted },
 	{ "/say", commandPrivmsg, Multiline },
+	{ "/setname", commandSetname, 0 },
 	{ "/topic", commandTopic, 0 },
 	{ "/unban", commandUnban, 0 },
 	{ "/unexcept", commandUnexcept, 0 },
diff --git a/handle.c b/handle.c
index 96c99b7..d8f5f3d 100644
--- a/handle.c
+++ b/handle.c
@@ -97,6 +97,10 @@ typedef void Handler(struct Message *msg);
 
 static void handleStandardReply(struct Message *msg) {
 	require(msg, false, 3);
+	if (!strcmp(msg->params[0], "SETNAME")) {
+		if (!replies.setname) return;
+		replies.setname--;
+	}
 	for (uint i = 2; i < ParamCap - 1; ++i) {
 		if (msg->params[i + 1]) continue;
 		uiFormat(
@@ -1150,6 +1154,17 @@ static void handleReplyNowAway(struct Message *msg) {
 	replies.away--;
 }
 
+static void handleSetname(struct Message *msg) {
+	require(msg, true, 1);
+	if (!replies.setname) return;
+	if (strcmp(msg->nick, self.nick)) return;
+	uiFormat(
+		Network, Warm, tagTime(msg),
+		"You update your name tag: %s", msg->params[0]
+	);
+	replies.setname--;
+}
+
 static bool isAction(struct Message *msg) {
 	if (strncmp(msg->params[1], "\1ACTION ", 8)) return false;
 	msg->params[1] += 8;
@@ -1343,6 +1358,7 @@ static const struct Handler {
 	{ "PING", handlePing },
 	{ "PRIVMSG", handlePrivmsg },
 	{ "QUIT", handleQuit },
+	{ "SETNAME", handleSetname },
 	{ "TOPIC", handleTopic },
 	{ "WARN", handleStandardReply },
 };