如何在Rivescript-Python中预处理特殊触发器?

sta*_*dev 6 rivescript

我的机器人将用户的名称存储在数据库中,并且数据库有时会向会话发送消息"setname username".样本rivescript:

+ setname *
- <set name=<formal>>

+ (what is my name|who am i)
- You're <get name>, right?

+ didntlike
- {topic=nlike}Why?

> topic nlike

+ *
- {topic=random}Thanks for charing.

< topic

+ *
- I don't have a reply for that.
- Try asking that a different way.
Run Code Online (Sandbox Code Playgroud)

问题是,当用户处于*nlike'之类的主题时,我会发送消息来设置名称,然后会话退出主题.

期待的对话:

Me: hello
Bot: I don't have a reply for that.
Me: didntlike
Bot: Why?
Me: setname John
Bot:
Me: I didn't like because you are ugly.
Bot: Thanks for charing.
Me: Who am I?
Bot: You're John, right?
Run Code Online (Sandbox Code Playgroud)

有没有办法在开始块中对待它?我尝试了不同的语法,但没有积极的结果.我想到了类似的东西:

> begin

+ setname *
- <set name=<formal>>

+ request
- {ok}

< begin
Run Code Online (Sandbox Code Playgroud)

一种解决方法是在所有主题中添加相同的触发器,但我需要一个更好的解决方案,因为当我的rive文件变大时,这种方法容易出错.

====代码尝试基于尼尔森的回答=====

> begin
    + request
    - {ok}{topic=specialtriggers}
< begin

> topic specialtriggers

+ setname *
- <set name=<formal>>

< topic

+ (what is my name|who am i)
- You're <get name>, right?

+ didntlike
- {topic=nlike}Why?

> topic nlike

+ *
- {topic=random}Thanks for charing.

< topic

+ *
- I don't have a reply for that.
- Try asking that a different way.
Run Code Online (Sandbox Code Playgroud)

我想将主题添加到{ok} {topic = specialtriggers}使得此主题之外的所有触发器都失败.在预处理之后,Rivescript应该回答是否是特殊触发器或者搜索正常触发器.

sta*_*dev 0

根据Noah Petherbridgechatbots.org上的回复,一种可行的解决方案是使用主题继承:

> topic specialtriggers
    + setname *{weight=9991234}
    - <set name=<star1>>
< topic

> topic random includes specialtriggers
    // you don't actually need to put anything inside here, since triggers
    // without a topic are in the "random" topic automatically, but this
    // topic declaration line will make "random" include "important"
< topic

// but for your other topics, include the specialtriggers one
> topic nlike includes specialtriggers
    + *
    - {topic=random}Thanks for caring.
< topic
Run Code Online (Sandbox Code Playgroud)