summaryrefslogtreecommitdiff
path: root/src/plugins/trigger/trigger.c
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2020-04-12 09:30:56 +0200
committerSébastien Helleu <flashcode@flashtux.org>2020-04-12 09:30:56 +0200
commit8bdd540df72c3a609e9d51a5c52cf2d65f96d79b (patch)
treef448d1bcda0cdb4769dd87abaa42c5cf06407ced /src/plugins/trigger/trigger.c
parentc9329f6fb1805da4c18cdcb1d4da3077bd434ed9 (diff)
downloadweechat-8bdd540df72c3a609e9d51a5c52cf2d65f96d79b.zip
trigger: evaluate arguments of command when the trigger is created (closes #1472)
Diffstat (limited to 'src/plugins/trigger/trigger.c')
-rw-r--r--src/plugins/trigger/trigger.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/plugins/trigger/trigger.c b/src/plugins/trigger/trigger.c
index b1364c294..7a6efb381 100644
--- a/src/plugins/trigger/trigger.c
+++ b/src/plugins/trigger/trigger.c
@@ -265,6 +265,7 @@ trigger_hook (struct t_trigger *trigger)
{
char **argv, **argv_eol, *buffer_type, *buffer_name, *tags, *message;
char *error1, *error2, *error3;
+ char *eval_desc, *eval_args, *eval_desc_args, *eval_completion;
int i, argc, strip_colors;
long interval, align_second, max_calls;
@@ -400,14 +401,30 @@ trigger_hook (struct t_trigger *trigger)
if (trigger->hooks)
{
trigger->hooks_count = 1;
+ eval_desc = (argc > 1) ? weechat_string_eval_expression (
+ argv[1], NULL, NULL, NULL) : NULL;
+ eval_args = (argc > 2) ? weechat_string_eval_expression (
+ argv[2], NULL, NULL, NULL) : NULL;
+ eval_desc_args = (argc > 3) ? weechat_string_eval_expression (
+ argv[3], NULL, NULL, NULL) : NULL;
+ eval_completion = (argc > 4) ? weechat_string_eval_expression (
+ argv[4], NULL, NULL, NULL) : NULL;
trigger->hooks[0] = weechat_hook_command (
argv[0], /* command */
- (argc > 1) ? argv[1] : "", /* description */
- (argc > 2) ? argv[2] : "", /* arguments */
- (argc > 3) ? argv[3] : "", /* description of args */
- (argc > 4) ? argv[4] : "", /* completion */
+ (eval_desc) ? eval_desc : "",
+ (eval_args) ? eval_args : "",
+ (eval_desc_args) ? eval_desc_args : "",
+ (eval_completion) ? eval_completion : "",
&trigger_callback_command_cb,
trigger, NULL);
+ if (eval_desc)
+ free (eval_desc);
+ if (eval_args)
+ free (eval_args);
+ if (eval_desc_args)
+ free (eval_desc_args);
+ if (eval_completion)
+ free (eval_completion);
}
}
break;