简体   繁体   English

Hubot-Cleverbot脚本问题层次结构

[英]Hubot-Cleverbot script issue heirarchy

I'm using a cleverbot script to have my bot respond to any type of messages. 我正在使用cleverbot脚本让我的机器人响应任何类型的消息。 The script works but currently requires a user to call for the bot via "hey" 该脚本有效,但当前需要用户通过“嘿”来调用该机器人

For example 例如

"@bot hey what is going on?"
bot: Not too much.

Code: 码:

robot.respond(/hey (.*)/i, function(msg) {
//code for reply
}

What I want to do is have it so I can just ask the question directly to my bot without requiring the "hey" part. 我想要做的是拥有它,因此我可以直接向我的机器人提问,而无需“嘿”部分。 I originally got rid of the "hey" tag but it interferes with my other scripts that are set to respond to certain text. 我最初摆脱了“嘿”标记,但是它干扰了我设置为响应某些文本的其他脚本。 In other words, I get two responses from my bot. 换句话说,我的机器人收到了两个响应。

Any ideas on how to tell my cleverbot script to only respond if all the other scripts have been confirmed first? 关于如何告诉我的cleverbot脚本仅在首先确认所有其他脚本后才做出响应的任何想法? Thank you! 谢谢!

Use @robot.catchAll . 使用@robot.catchAll A CatchAll listener will execute iff no other regex matched the message, but know that means it won't execute if you have any scripts that match all messages (eg robot.hear /.*/ ). 如果没有其他正则表达式与该消息匹配,则CatchAll侦听器将执行,但知道这意味着如果您有匹配所有消息的脚本(例如, robot.hear /.*/将不会执行。

Some documentation (part of a separate PR waiting to be merged, so ignore catchAllAddressed ) -- https://github.com/michaelansel/hubot/blob/issues/683/docs/scripting.md#catch-all 一些文档(一个单独的PR的一部分正在等待合并,因此请忽略catchAllAddressedcatchAllAddressed : //github.com/michaelansel/hubot/blob/issues/683/docs/scripting.md#catch-all

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM