From 0e3cdc19922c6ea0b3b63264b5362e1984e8b466 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Sat, 21 Aug 2021 14:49:07 -0400 Subject: 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. --- bounce.h | 1 + client.c | 2 +- state.c | 13 +++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) 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 }, -- cgit 1.4.1