summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2023-06-03 10:01:27 +0200
committerSébastien Helleu <flashcode@flashtux.org>2023-06-03 14:15:49 +0200
commitac9dc3b9c80d0dca56e54c48bd8be6520dda5b06 (patch)
tree5ae676cf0951e13589c8399263b46ae1103ee8f2 /src/plugins
parent911c976f9bd7a9a2da179a1e017af90cf1f40b27 (diff)
downloadweechat-ac9dc3b9c80d0dca56e54c48bd8be6520dda5b06.zip
irc: add infos "irc_server_cap" and "irc_server_cap_value" (issue #1949)
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/irc/irc-info.c86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/plugins/irc/irc-info.c b/src/plugins/irc/irc-info.c
index c2fe9c421..98da456f8 100644
--- a/src/plugins/irc/irc-info.c
+++ b/src/plugins/irc/irc-info.c
@@ -402,6 +402,82 @@ irc_info_info_irc_server_isupport_value_cb (const void *pointer, void *data,
}
/*
+ * Returns IRC info "irc_server_cap".
+ */
+
+char *
+irc_info_info_irc_server_cap_cb (const void *pointer, void *data,
+ const char *info_name,
+ const char *arguments)
+{
+ char *pos_comma, *server;
+ int has_cap;
+ struct t_irc_server *ptr_server;
+
+ /* make C compiler happy */
+ (void) pointer;
+ (void) data;
+ (void) info_name;
+
+ has_cap = 0;
+ pos_comma = strchr (arguments, ',');
+ if (pos_comma)
+ {
+ server = weechat_strndup (arguments, pos_comma - arguments);
+ if (server)
+ {
+ ptr_server = irc_server_search (server);
+ if (ptr_server)
+ {
+ has_cap = weechat_hashtable_has_key (ptr_server->cap_list,
+ pos_comma + 1);
+ }
+ free (server);
+ }
+ }
+
+ return (has_cap) ? strdup ("1") : NULL;
+}
+
+/*
+ * Returns IRC info "irc_server_cap_value".
+ */
+
+char *
+irc_info_info_irc_server_cap_value_cb (const void *pointer, void *data,
+ const char *info_name,
+ const char *arguments)
+{
+ char *pos_comma, *server;
+ const char *cap_value;
+ struct t_irc_server *ptr_server;
+
+ /* make C compiler happy */
+ (void) pointer;
+ (void) data;
+ (void) info_name;
+
+ cap_value = NULL;
+ pos_comma = strchr (arguments, ',');
+ if (pos_comma)
+ {
+ server = weechat_strndup (arguments, pos_comma - arguments);
+ if (server)
+ {
+ ptr_server = irc_server_search (server);
+ if (ptr_server)
+ {
+ cap_value = weechat_hashtable_get (ptr_server->cap_list,
+ pos_comma + 1);
+ }
+ free (server);
+ }
+ }
+
+ return (cap_value) ? strdup (cap_value) : NULL;
+}
+
+/*
* Returns IRC info "irc_is_message_ignored".
*/
@@ -1172,6 +1248,16 @@ irc_info_init ()
N_("server,feature"),
&irc_info_info_irc_server_isupport_value_cb, NULL, NULL);
weechat_hook_info (
+ "irc_server_cap",
+ N_("1 if capability is enabled in server"),
+ N_("server,capability"),
+ &irc_info_info_irc_server_cap_cb, NULL, NULL);
+ weechat_hook_info (
+ "irc_server_cap_value",
+ N_("value of capability, if enabled in server"),
+ N_("server,capability"),
+ &irc_info_info_irc_server_cap_value_cb, NULL, NULL);
+ weechat_hook_info (
"irc_is_message_ignored",
N_("1 if the nick is ignored (message is not displayed)"),
N_("server,message (message is the raw IRC message)"),