【问题标题】:Having hubot respond when a message does not match当消息不匹配时让hubot响应
【发布时间】:2019-04-02 18:43:58
【问题描述】:

我正在用 javascript 为hubot 编写一个松弛接口,并且我希望在输入无效命令时有一个默认消息。我目前在我的代码中有这个:

robot.respond(!(/command1/, /command2/, /command3/, etc.) function (msg) {
   msg.reply('Returned message')
})

虽然它会响应所有无效消息,但它也会在我输入任何有效命令时发送我的响应。有没有办法解决这个问题?

【问题讨论】:

    标签: javascript hubot


    【解决方案1】:

    我发现有一种更简单的方法可以做我想做的事。在以下父亲处使用 hubot 支持包,它为您提供了一个机器人。全部回复

    https://www.npmjs.com/package/hubot-suggest

    然后我写了以下代码:

    module.exports = function (robot) {
    const text = dedent`
    Command does not exist
    Did you want one of the following commands?
    'handel-codepipeline help'
    'handel-codepipeline [deploy|delete]'
    'canvas-update <sis_section_id> <curriculum_id> <title_code>'
    'new repo' - creates a new githib repository
    For more commands, type 'help'
    `
    robot.catchAll((msg) => {
        msg.reply(text)
    })
    

    }

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-05-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-14
      • 1970-01-01
      相关资源
      最近更新 更多