summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-08-21 14:49:07 -0400
committerJune McEnroe <june@causal.agency>2021-08-21 14:49:07 -0400
commit0e3cdc19922c6ea0b3b63264b5362e1984e8b466 (patch)
treeb57849e5ea9390a3e308edfea78c951604d83030
parentReplace verbose colors with two types of arrows (diff)
downloadpounce-0e3cdc19922c6ea0b3b63264b5362e1984e8b466.tar.gz
pounce-0e3cdc19922c6ea0b3b63264b5362e1984e8b466.zip
Avoid overwriting manual AWAY messages
Setting an AWAY message then disconnecting will no longer replace
the AWAY message with the default one. Reconnecting continues to
always clear AWAY.
-rw-r--r--bounce.h1
-rw-r--r--client.c2
-rw-r--r--state.c13
3 files changed, 15 insertions, 1 deletions
diff --git a/bounce.h b/bounce.h
index e17f216..3951599 100644
--- a/bounce.h
+++ b/bounce.h
@@ -232,6 +232,7 @@ void clientConsume(struct Client *client);
 
 extern bool stateNoNames;
 extern enum Cap stateCaps;
+extern bool stateAway;
 void stateLogin(
 	const char *pass, enum Cap blind, const char *plain,
 	const char *nick, const char *user, const char *real
diff --git a/client.c b/client.c
index 938ab8b..ed2e0d3 100644
--- a/client.c
+++ b/client.c
@@ -76,7 +76,7 @@ static void clientHandshake(struct Client *client) {
 
 void clientFree(struct Client *client) {
 	if (!client->need) {
-		if (!(client->caps & CapPassive) && !--active) {
+		if (!(client->caps & CapPassive) && !--active && !stateAway) {
 			serverEnqueue("AWAY :%s\r\n", clientAway);
 		}
 	}
diff --git a/state.c b/state.c
index 21669c4..edc4b92 100644
--- a/state.c
+++ b/state.c
@@ -38,6 +38,7 @@
 
 bool stateNoNames;
 enum Cap stateCaps;
+bool stateAway;
 
 typedef void Handler(struct Message *msg);
 
@@ -331,6 +332,16 @@ static void handleReplyTopic(struct Message *msg) {
 	chanTopic(msg->params[1], msg->params[2]);
 }
 
+static void handleReplyUnaway(struct Message *msg) {
+	(void)msg;
+	stateAway = false;
+}
+
+static void handleReplyNowAway(struct Message *msg) {
+	(void)msg;
+	stateAway = true;
+}
+
 static void handleError(struct Message *msg) {
 	require(msg, false, 1);
 	errx(EX_UNAVAILABLE, "%s", msg->params[0]);
@@ -345,6 +356,8 @@ static const struct {
 	{ "003", handleReplyCreated },
 	{ "004", handleReplyMyInfo },
 	{ "005", handleReplyISupport },
+	{ "305", handleReplyUnaway },
+	{ "306", handleReplyNowAway },
 	{ "332", handleReplyTopic },
 	{ "375", handleReplyMOTDStart },
 	{ "422", handleReplyMOTDStart },