簡體   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