github/hubot — pull request #349 by wingrunr21 (2012-09-13 15:09:16+00:00)
Title: Provide Hubot the ability to react to message types

I needed the ability for hubot to react to topic changes in Campfire as well as the ability to query the Campfire room for information (like the current topic).

I made changes that allow hubot to "see" a message. The function will allow a String, Regex, or actual object name to be specified as what to watch for:

module.exports = (robot) ->
robot.see "TopicChangeMessage", (msg) ->
# do something fun
robot.see /TopicChangeMessage/, (msg) ->
# works for funness as well
robot.see TopicChangeMessage, (msg) ->
# just remember to require TopicChangeMessage...

The enter and leave events have been updated to use this common way of reacting to message types.

I also added an info utility function to the Campfire adaptor. It is possible I missed something more obvious for using it, but here is what I am currently using:

robot.respond /topic/, (msg) ->
user = msg.message.user
room = user.room

robot.adapter.bot.Room(room).info (err, data) ->
topic = data.room.topic

I'm working on an example script for this stuff to commit to [hubot-scripts](https://github.com/github/hubot-scripts)