11

I am trying to make Hubot detect when a user enters or leaves a channel, but so far I have been unable to actually find ANY information pertaining to this.

Does anyone have any ideas of how to do this? :)

Thanks in advance!

Olive
  • 3,516
  • 7
  • 24
  • 32

1 Answers1

7

Hubot's Robot class has functions enter and leave that will fire a callback you give when any user enters or leaves the room. That callback takes a Response, which has a property message of type Message, which in turn has a property user of type User.

module.exports = (robot) ->
   robot.enter (response) ->
     # at this point you can get the user's name with:
     # response.message.user.name
     # works the same for robot.leave

However, it appears that the IRC adapter for hubot doesn't currently fire the messages needed to get those functions to work.

John Flatness
  • 32,469
  • 5
  • 79
  • 81
  • 1
    For your future reference, I wasn't able to find any documentation about what Robot and the other classes can do, but the [in-code documentation in the hubot repo](https://github.com/github/hubot/tree/master/src)... exists. – John Flatness May 31 '12 at 18:40