hubot icon indicating copy to clipboard operation
hubot copied to clipboard

Hubot Documentation example not working (Dynamic matching of messages)

Open oscarssanchez opened this issue 4 years ago • 0 comments

Hi there,

I am working with Dynamic matching of messages per documentation here https://hubot.github.com/docs/patterns/ however, when I paste this code

module.exports = (robot) ->
  # Dynamically populated list of factoids
  facts =
    fact1: 'stuff'
    fact2: 'other stuff'

  robot.listen(
    # Matcher
    (message) ->
      match = message.match(/^~(.*)$/)
      # Only match if there is a matching factoid
      if match and match[1] in facts
        match[1]
      else
        false
    # Callback
    (response) ->
      fact = response.match
      res.reply "#{fact} is #{facts[fact]}"
  )

I get message.match is not a function, unfortunately i have been trying different approaches but none of them actually get me a response from hubot.

Is there any other documentation that can be shared or can this one be corrected? Unfortunately i was not able to find any other examples.

Thanks!

oscarssanchez avatar Jun 20 '20 17:06 oscarssanchez