about summary refs log tree commit diff
diff options
context:
space:
mode:
-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 },