rivescript-python icon indicating copy to clipboard operation
rivescript-python copied to clipboard

make permanent an option in trigger, without writing it on triggers

Open elpimous opened this issue 6 years ago • 4 comments

Hi Noah, hi all, I continue Alfred s' brain (a physical Alive robot) When I communicate with Alfred, I ofter tell "Alfred", at the beginning or end sentence : How could I tell the program : forget alfred word ??

ex :

+ [alfred] power on the tv [alfred]

I'd like rivescript to ignore this word when i speak it. So I will not have to write it everywere !

Sure I could erase it on python with a replace command, but I'd like to do it under a rive file !

elpimous avatar Feb 17 '18 15:02 elpimous

I think you can use default trigger in begin.rive. This trigger is matched before other all triggers.

check this tutorial https://www.rivescript.com/docs/tutorial#the-begin-block

> begin
	+ request // This trigger is tested first.
        - {ok}
< begin

sucream avatar May 16 '18 00:05 sucream

Hi, I tested, and it doesn't work

elpimous avatar Jun 18 '18 21:06 elpimous

Something like this maybe:

+ alfred *{weight=100}
- <@>

+ * alfred{weight=100}
- <@>

The high weight value should ensure the trigger gets tested first (unless you have other triggers with weight >100). If it begins or ends with the word "alfred" it just redirects to a trigger without that word.

It may be possible to combine them into one trigger, but using optionals on either end like your original example might backfire: the first iteration you'd match the [alfred] * [alfred] trigger and it would match whether or not you said the word alfred (because it's optional, you see), and it would redirect to <star> and it would test [alfred] * [alfred] first again, and repeat forever.

kirsle avatar Jun 19 '18 22:06 kirsle

Perfect, Noah. So simple... Thanks

ps : this test failed

+ [alfred] * [alfred]
- <@>

+ bonjour *
- salut

question :  bonjour alfred
[ERR: Deep recursion detected]

This worked :

+ alfred *{weight=100}
- <@>

+ * alfred{weight=100}
- <@>

Hope it will help each other !

elpimous avatar Jun 20 '18 12:06 elpimous