Search code examples
coffeescripthubot

How do I find the name of the room Hubot is responding to?


I'm writing a Hubot script to connect with our tracking system at work. It should be triggering a PHP script with various parameters, and then that script will send the response into the room.

How can I tell which room the message that Hubot is responding to came from, so I can send it in my AJAX request?

This is what my script looks like:

module.exports = (robot) ->

robot.hear /RT \d+$/, (msg) ->
    ticket = msg.match[1]

    msg.send "test"

    $.ajax 'YourScriptHere',
          data :
            room : room // This is what I need to find.
            ticket : ticket

Solution

  • This is how you get the room:

    room = msg.message.room