Multi-line triggers created through AddTriggerEx() don't work

Posted by Kahenraz on Sun 15 Apr 2018 12:22 AM — 2 posts, 13,576 views.

#0
Examine the following single-line trigger:

Trigger = [[^You poke (?P<thing>.+)\.$]]
Script = [[print("Poke: %<thing>")]]

AddTriggerEx("Test_Trigger", Trigger, Script,
   trigger_flag.Enabled + trigger_flag.RegularExpression + trigger_flag.Replace
   + trigger_flag.KeepEvaluating, -1, 0, "", "", 12, 0)


It works as it should. See the following test:

You poke a rock.


Output:

Poke: a rock.


Now try the same thing with a multi-line trigger:

Trigger = [[^You poke (?P<thing1>.+)\.$\n^You prod (?P<thing2>.+)\.$]]
Script = [[print("Poke: %<thing1>")
print("Prod: %<thing2>")]]

AddTriggerEx("Test_Trigger", Trigger, Script,
   trigger_flag.Enabled + trigger_flag.RegularExpression + trigger_flag.Replace
   + trigger_flag.KeepEvaluating, -1, 0, "", "", 12, 0)

SetTriggerOption("Test_Trigger", "multi_line", "y")
SetTriggerOption("Test_Trigger", "lines_to_match", "2")


With the following test:

You poke a rock.
You prod a rock.


There is no output. It does not match. However, if I open the trigger in the configuration window -do nothing- and click "OK" then it works as expected with the following output:

Poke: a rock
Prod: a rock


So for some reason these triggers aren't being evaluated when added by AddTriggerEx() and subsequently set as a multi-line trigger with SetTriggerOption().
Amended on Sun 15 Apr 2018 12:23 AM by Kahenraz
Australia Forum Administrator #1
You have discovered a bug in the processing of SetTriggerOption. The latest pre-release should fix that.

https://github.com/nickgammon/mushclient/commit/f99ffb2