aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2021-05-28 01:44:46 +0200
committerPřemysl Eric Janouch <p@janouch.name>2021-05-28 04:59:20 +0200
commitbb451a5050e5083b516d3eebce94deb15a666ddd (patch)
tree65036c1ce3b701373cd3e4983d66c62b68c64049
parent61f15ead8a0d4582c2dfde48f3c0d8a3f66529d2 (diff)
downloadxK-bb451a5050e5083b516d3eebce94deb15a666ddd.tar.gz
xK-bb451a5050e5083b516d3eebce94deb15a666ddd.tar.xz
xK-bb451a5050e5083b516d3eebce94deb15a666ddd.zip
degesch: support CAP DEL, request cap-notify
It doesn't require much effort to cancel capabilities, plus with the newer version we get the respective notification anyway.
-rw-r--r--NEWS2
-rw-r--r--degesch.c23
2 files changed, 19 insertions, 6 deletions
diff --git a/NEWS b/NEWS
index 5ccd44c..8c56d81 100644
--- a/NEWS
+++ b/NEWS
@@ -2,7 +2,7 @@
* degesch: added a /squery command for IRCnet
- * degesch: now supporting IRCv3.2 capability negotiation
+ * degesch: now supporting IRCv3.2 capability negotiation, including CAP DEL
1.1.0 (2020-10-31) "What Do You Mean By 'This Isn't Germany'?"
diff --git a/degesch.c b/degesch.c
index 563da0f..eaf71fa 100644
--- a/degesch.c
+++ b/degesch.c
@@ -2340,7 +2340,7 @@ static struct config_schema g_config_server[] =
.type = CONFIG_ITEM_STRING_ARRAY,
.validate = config_validate_nonjunk_string,
.default_ = "\"multi-prefix,invite-notify,server-time,echo-message,"
- "message-tags,away-notify\"" },
+ "message-tags,away-notify,cap-notify\"" },
{ .name = "tls",
.comment = "Whether to use TLS",
@@ -6577,6 +6577,15 @@ irc_process_cap_ls (struct server *s)
}
static void
+irc_toggle_cap (struct server *s, const char *cap, bool active)
+{
+ if (!strcasecmp_ascii (cap, "echo-message"))
+ s->cap_echo_message = active;
+ if (!strcasecmp_ascii (cap, "away-notify"))
+ s->cap_away_notify = active;
+}
+
+static void
irc_handle_cap (struct server *s, const struct irc_message *msg)
{
if (msg->params.len < 2)
@@ -6601,10 +6610,7 @@ irc_handle_cap (struct server *s, const struct irc_message *msg)
active = false;
cap++;
}
- if (!strcasecmp_ascii (cap, "echo-message"))
- s->cap_echo_message = active;
- if (!strcasecmp_ascii (cap, "away-notify"))
- s->cap_away_notify = active;
+ irc_toggle_cap (s, cap, active);
}
irc_send (s, "CAP END");
}
@@ -6614,6 +6620,13 @@ irc_handle_cap (struct server *s, const struct irc_message *msg)
"#s: #S", "Capabilities not acknowledged", args);
irc_send (s, "CAP END");
}
+ else if (!strcasecmp_ascii (subcommand, "DEL"))
+ {
+ log_server_error (s, s->buffer,
+ "#s: #S", "Capabilities deleted", args);
+ for (size_t i = 0; i < v.len; i++)
+ irc_toggle_cap (s, v.vector[i], false);
+ }
else if (!strcasecmp_ascii (subcommand, "LS"))
{