Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting when a user leaves or enters a channel with hubot

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!

like image 971
Olive Avatar asked May 25 '12 14:05

Olive


1 Answers

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.

like image 151
John Flatness Avatar answered Nov 24 '22 05:11

John Flatness