weechat icon indicating copy to clipboard operation
weechat copied to clipboard

print trigger post_action executes on any message

Open bialad opened this issue 4 years ago • 1 comments

Bug summary

Adding a "disable" post_action to a print trigger immediately disables the trigger

Steps to reproduce

/trigger addreplace post_action_test print "" "${tg_message} =~ (post_action)" "" "MATCH" /trigger show post_action_test

trigger is enabled

/trigger add post_action_test print_test "" "${tg_message} =~ (post_action)" "" "MATCH" "ok" "disable" /trigger show post_action_test

trigger is disabled

Info

Adding /mute before /trigger add prevents the direct execution, so the post_action is run on the first message it receives.

Expected behaviour for a print trigger would to execute post_action after condtions are met and a command has executed.

  • WeeChat version: 3.1
  • OS, distribution and version: debian buster
  • Terminal: N/A (relay to glowing bear)

bialad avatar Apr 09 '21 19:04 bialad

To add some info, the issue is that the post action is run whenever the trigger callback is called, regardless if the trigger was actually executed or not. So this is not exactly specific to the print trigger, but it's a much bigger issue for such triggers since lines are printed all the time. E.g. for timer triggers without any condition it's not an issue, since the only time the callback is called is when they're actually run.

As far as I can see, the issue is that this code is run unconditionally, while it should only run if the trigger actually executed: https://github.com/weechat/weechat/blob/7c5cbefd51943a4481749d989b7c47a3721095bb/src/plugins/trigger/trigger-callback.h#L78-L92

trygveaa avatar Apr 09 '21 19:04 trygveaa