regexp triggers
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
leanlyn |
Fix Committed
|
Undecided
|
Unassigned |
Bug Description
We need a simple one-line way to add triggers. This is possible now, [see basiccommands.
@add_trig('^\w falls down dead', 'loot corpse')
would expand to
def add_trig(re_text, send_text):
sess = engine.sessions[0] # current session
trig = catcher.
def send_text(dummy):
sess.
trig.
sess.
Since commands starting with '@' use the python interactive interpreter we wouldn't have to do any parsing by hand. Also, the syntax is familiar to anyone that knows python (and/or it teaches python to people who don't know it).
to add a trigger REMatch. __init_ _ so for one-shot triggers include count=1, for muffles use muffle=True, etc
@trigger('your regexp here', 'this gets executed as if typed in the entry box', listen=1, no_ansi=True)
the options are passed to the catcher.
added the '#triggers ' command which can be used to list/delete triggers created with the @trigger command.