diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2021-12-30 21:22:37 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2021-12-30 21:22:37 +0100 |
commit | 532d46bb93c1460d464b2f2737d4ea1dc898289c (patch) | |
tree | 015d3d1411dc149d25e99c4a21f8b56b06eb309c /src | |
parent | b66298d369cc72b593368d70abb0a994009eb44e (diff) | |
download | weechat-532d46bb93c1460d464b2f2737d4ea1dc898289c.zip |
trigger: add variables `${tg_tag_irc_xxx}` containing IRC message tags (issue #1680)
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/trigger/trigger-callback.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/plugins/trigger/trigger-callback.c b/src/plugins/trigger/trigger-callback.c index caefc06ca..896d80d6c 100644 --- a/src/plugins/trigger/trigger-callback.c +++ b/src/plugins/trigger/trigger-callback.c @@ -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; |