我的机器人将用户名存储在数据库中,并且数据库有时会向会话发送一条消息“setname username”。示例铆钉:
+ 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.
问题是当用户处于由 * 退出的“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?
有没有办法在开始块中处理它?我尝试了不同的语法,但没有积极的结果。我想到了类似的东西:
> begin
+ setname *
- <set name=<formal>>
+ request
- {ok}
< begin
一种解决方法是在所有主题中添加相同的触发器,但我需要一个更好的解决方案,因为随着我的 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.
我认为将主题添加到 {ok}{topic=specialtriggers} 会使该主题之外的所有触发器都失败。预处理后,Rivescript 应该回答它是否是特殊触发器,否则搜索正常触发器。