[英]Hubot help desk: reply with error if x is not there
I am giving hubot a go to be integrated with slack to act as a helpdesk. 我正在给Hubot一个可以与Slack集成的功能,以充当服务台。
The script (coffeescript) so far looks out for keywords, if the keywords don't exist then I need the hubot to return something like 'Sorry I can't find what you are looking for'. 到目前为止,脚本(咖啡脚本)会查找关键字,如果关键字不存在,那么我需要Hubot返回类似“抱歉,我找不到您想要的内容”之类的内容。
Below is an example of the keyword query; 以下是关键字查询的示例;
module.exports = (robot) ->
robot.hear /ansible/i, (res) ->
res.send "Hi, for all ansible related querys, please go to
www.github.com/ansible/ansiblehelp"
So for example is ansible is not in the question, the hubot needs to reply with 'Sorry I can't find what you are looking for'. 因此,例如ansible不在问题中,hubot需要回答“对不起,我找不到您想要的东西”。
Is this possible? 这可能吗?
Thanks 谢谢
Try a catchAll
clause to provide a default response: 尝试使用
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.