繁体   English   中英

Hubot服务台:如果x不存在,请回复错误

[英]Hubot help desk: reply with error if x is not there

我正在给Hubot一个可以与Slack集成的功能,以充当服务台。

到目前为止,脚本(咖啡脚本)会查找关键字,如果关键字不存在,那么我需要Hubot返回类似“抱歉,我找不到您想要的内容”之类的内容。

以下是关键字查询的示例;

module.exports = (robot) ->
  robot.hear /ansible/i, (res) ->
     res.send "Hi, for all ansible related querys, please go to 
     www.github.com/ansible/ansiblehelp"

因此,例如ansible不在问题中,hubot需要回答“对不起,我找不到您想要的东西”。

这可能吗?

谢谢

尝试使用catchAll子句以提供默认响应:

module.exports = (robot) ->
  robot.catchAll (msg) ->
    if msg.message.match /// ^#{robot.name}\s ///
        msg.reply "Sorry I can't find what you are looking for"

答案来源

类似答案

暂无
暂无

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

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