简体   繁体   中英

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.

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'.

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'.

Is this possible?

Thanks

Try a catchAll clause to provide a default response:

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"

Answer source

Similar answer

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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