mirror of
https://github.com/weechat/weechat.git
synced 2026-06-27 05:16:38 +02:00
trigger: only return trigger's return code when condition evaluates to true
This commit is contained in:
committed by
Sébastien Helleu
parent
8f6cc60a3f
commit
b14cf0ac3d
@@ -393,9 +393,13 @@ trigger_callback_run_command (struct t_trigger *trigger,
|
||||
* 2. check conditions (if false, exit)
|
||||
* 3. replace text with regex
|
||||
* 4. execute command(s)
|
||||
*
|
||||
* Returns:
|
||||
* 1: conditions were true (or no condition set in trigger)
|
||||
* 0: conditions were false
|
||||
*/
|
||||
|
||||
void
|
||||
int
|
||||
trigger_callback_execute (struct t_trigger *trigger,
|
||||
struct t_gui_buffer *buffer,
|
||||
struct t_hashtable *pointers,
|
||||
@@ -422,7 +426,11 @@ trigger_callback_execute (struct t_trigger *trigger,
|
||||
/* execute command(s) */
|
||||
trigger_callback_run_command (trigger, buffer, pointers, extra_vars,
|
||||
display_monitor);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -529,7 +537,8 @@ trigger_callback_signal_cb (const void *pointer, void *data,
|
||||
weechat_hashtable_set (extra_vars, "tg_signal_data", ptr_signal_data);
|
||||
|
||||
/* execute the trigger (conditions, regex, command) */
|
||||
trigger_callback_execute (trigger, NULL, pointers, extra_vars, NULL);
|
||||
if (!trigger_callback_execute (trigger, NULL, pointers, extra_vars, NULL))
|
||||
trigger_rc = WEECHAT_RC_OK;
|
||||
|
||||
end:
|
||||
TRIGGER_CALLBACK_CB_END(trigger_rc);
|
||||
@@ -577,7 +586,8 @@ trigger_callback_hsignal_cb (const void *pointer, void *data,
|
||||
weechat_hashtable_set (extra_vars, "tg_signal", signal);
|
||||
|
||||
/* execute the trigger (conditions, regex, command) */
|
||||
trigger_callback_execute (trigger, NULL, pointers, extra_vars, NULL);
|
||||
if (!trigger_callback_execute (trigger, NULL, pointers, extra_vars, NULL))
|
||||
trigger_rc = WEECHAT_RC_OK;
|
||||
|
||||
end:
|
||||
TRIGGER_CALLBACK_CB_END(trigger_rc);
|
||||
@@ -989,7 +999,8 @@ trigger_callback_print_cb (const void *pointer, void *data,
|
||||
goto end;
|
||||
|
||||
/* execute the trigger (conditions, regex, command) */
|
||||
trigger_callback_execute (trigger, buffer, pointers, extra_vars, NULL);
|
||||
if (!trigger_callback_execute (trigger, buffer, pointers, extra_vars, NULL))
|
||||
trigger_rc = WEECHAT_RC_OK;
|
||||
|
||||
end:
|
||||
TRIGGER_CALLBACK_CB_END(trigger_rc);
|
||||
@@ -1023,7 +1034,8 @@ trigger_callback_command_cb (const void *pointer, void *data,
|
||||
}
|
||||
|
||||
/* execute the trigger (conditions, regex, command) */
|
||||
trigger_callback_execute (trigger, buffer, pointers, extra_vars, NULL);
|
||||
if (!trigger_callback_execute (trigger, buffer, pointers, extra_vars, NULL))
|
||||
trigger_rc = WEECHAT_RC_OK;
|
||||
|
||||
end:
|
||||
TRIGGER_CALLBACK_CB_END(trigger_rc);
|
||||
@@ -1048,7 +1060,8 @@ trigger_callback_command_run_cb (const void *pointer, void *data,
|
||||
weechat_hashtable_set (extra_vars, "tg_command", command);
|
||||
|
||||
/* execute the trigger (conditions, regex, command) */
|
||||
trigger_callback_execute (trigger, buffer, pointers, extra_vars, NULL);
|
||||
if (!trigger_callback_execute (trigger, buffer, pointers, extra_vars, NULL))
|
||||
trigger_rc = WEECHAT_RC_OK;
|
||||
|
||||
end:
|
||||
TRIGGER_CALLBACK_CB_END(trigger_rc);
|
||||
@@ -1098,7 +1111,8 @@ trigger_callback_timer_cb (const void *pointer, void *data,
|
||||
}
|
||||
|
||||
/* execute the trigger (conditions, regex, command) */
|
||||
trigger_callback_execute (trigger, NULL, pointers, extra_vars, NULL);
|
||||
if (!trigger_callback_execute (trigger, NULL, pointers, extra_vars, NULL))
|
||||
trigger_rc = WEECHAT_RC_OK;
|
||||
|
||||
end:
|
||||
TRIGGER_CALLBACK_CB_END(trigger_rc);
|
||||
@@ -1121,7 +1135,8 @@ trigger_callback_config_cb (const void *pointer, void *data,
|
||||
weechat_hashtable_set (extra_vars, "tg_value", value);
|
||||
|
||||
/* execute the trigger (conditions, regex, command) */
|
||||
trigger_callback_execute (trigger, NULL, pointers, extra_vars, NULL);
|
||||
if (!trigger_callback_execute (trigger, NULL, pointers, extra_vars, NULL))
|
||||
trigger_rc = WEECHAT_RC_OK;
|
||||
|
||||
end:
|
||||
TRIGGER_CALLBACK_CB_END(trigger_rc);
|
||||
|
||||
Reference in New Issue
Block a user