1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-26 12:56:37 +02:00

trigger: add variables ${tg_tag_irc_xxx} containing IRC message tags (issue #1680)

This commit is contained in:
Sébastien Helleu
2021-12-30 21:22:37 +01:00
parent b66298d369
commit 532d46bb93
9 changed files with 49 additions and 2 deletions
+24 -2
View File
@@ -150,8 +150,8 @@ trigger_callback_set_tags (struct t_gui_buffer *buffer,
const char **tags, int tags_count,
struct t_hashtable *extra_vars)
{
const char *localvar_type;
char str_temp[128];
const char *localvar_type, *pos;
char str_temp[1024], *key;
int i;
snprintf (str_temp, sizeof (str_temp), "%d", tags_count);
@@ -193,6 +193,28 @@ trigger_callback_set_tags (struct t_gui_buffer *buffer,
{
weechat_hashtable_set (extra_vars, "tg_tag_host", tags[i] + 5);
}
else if (strncmp (tags[i], "irc_tag_", 8) == 0)
{
/*
* example:
* tag: "irc_tag_time_2021-12-30T21:02:50.038Z"
* is added in the hashtable like this:
* key : "tg_tag_irc_time"
* value: "2021-12-30T21:02:50.038Z"
*/
pos = strchr (tags[i] + 8, '_');
if (pos && pos > tags[i] + 8)
{
key = weechat_strndup (tags[i] + 8, pos - tags[i] - 8);
if (key)
{
snprintf (str_temp, sizeof (str_temp),
"tg_tag_irc_%s", key);
weechat_hashtable_set (extra_vars, str_temp, pos + 1);
free (key);
}
}
}
}
return 1;