diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2014-02-13 18:53:13 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2014-02-13 18:53:13 +0100 |
commit | 7356d1889adfa5420a9566c5287797592bdb7600 (patch) | |
tree | 2997a9339abe24ba4419121636bf4554c54154ec | |
parent | 0ac6ebe5328072e49d1776cecde8e45650c471e4 (diff) | |
download | weechat-7356d1889adfa5420a9566c5287797592bdb7600.zip |
trigger: add "tg_prefix" and "tg_message" in hashtable for modifier "weechat_print"
-rw-r--r-- | src/plugins/trigger/trigger-callback.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/plugins/trigger/trigger-callback.c b/src/plugins/trigger/trigger-callback.c index c114c118d..756ab6d5e 100644 --- a/src/plugins/trigger/trigger-callback.c +++ b/src/plugins/trigger/trigger-callback.c @@ -473,7 +473,7 @@ trigger_callback_modifier_cb (void *data, const char *modifier, struct t_gui_buffer *buffer; const char *ptr_string; char *string_modified, *pos, *pos2, *plugin_name, *buffer_name; - char *buffer_full_name, *str_tags, **tags; + char *buffer_full_name, *str_tags, **tags, *prefix; int length, num_tags; TRIGGER_CALLBACK_CB_INIT(NULL); @@ -508,6 +508,31 @@ trigger_callback_modifier_cb (void *data, const char *modifier, /* add special variables for a WeeChat message */ if (strcmp (modifier, "weechat_print") == 0) { + /* set "tg_prefix" and "tg_message" */ + pos = strchr (string, '\t'); + if (pos) + { + if (pos > string) + { + prefix = weechat_strndup (string, pos - string); + if (prefix) + { + weechat_hashtable_set (extra_vars, "tg_prefix", prefix); + free (prefix); + } + } + pos++; + if (pos[0] == '\t') + pos++; + weechat_hashtable_set (extra_vars, "tg_message", pos); + } + else + weechat_hashtable_set (extra_vars, "tg_message", string); + + /* + * extract buffer/tags from modifier data + * (format: "plugin;buffer_name;tags") + */ pos = strchr (modifier_data, ';'); if (pos) { |