有没有办法让Hubot回复所有不存在的命令的消息? [英] Is there a way to make Hubot reply to all messages that are not existing commands?

查看:94
本文介绍了有没有办法让Hubot回复所有不存在的命令的消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将首先尝试Hubot,并且正在制作用于基本对话的对话脚本.我已经完成了很多可能性(我有很多问题和关键字都可以使用),但是当用户问或说Hubot无法识别的内容时,它完全是寂静的.

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.

我想为Hubot添加默认的答案集,因为它找不到现有的命令或单词(模糊的答复,例如"那很有趣"或"告诉我更多".)

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

其中*是其他所有内容". 如果 commands ... else ..."?

where * is "everything else". "If commands... else..."?

推荐答案

由于hubot的robot.respond方法采用了正则表达式,因此您应该只提供/.*/作为正则表达式,并使其与所有内容匹配.

Since hubot's robot.respond method takes a regex, you should be able to just supply /.*/ as the regex, and have it match everything.

因此,您将拥有:

module.exports = (robot) ->
        robot.respond /.*/i, (msg) ->
            doSomething(msg)

这篇关于有没有办法让Hubot回复所有不存在的命令的消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆