I'm giving Hubot a first try, and I'm making a dialog script for basic conversation. I have completed quite a few possibilities (I have a lot of questions and keywords working,) but when the user asks or says something Hubot doesn't recognize, it's complete silence.
I want to add a default set of answers for Hubot when it can't find an existing command or words (vague replies like " That's interesting " or " Tell me more ".)
Is there a way to do this via script? Something like:
robot.respond / * /, (msg) ->
msg.send ArrayOfVagueReplies
where * is "everything else". "If commands ... else..."?
使用robot.catchAll
子句捕获所有不匹配的对话,您可以参考https://www.npmjs.com/package/hubot-suggest
Since hubot's robot.respond
method takes a regex, you should be able to just supply /.*/
as the regex, and have it match everything.
So you'd have:
module.exports = (robot) ->
robot.respond /.*/i, (msg) ->
doSomething(msg)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.