Detecting when a user leaves or enters a channel with hubot
Asked Answered
R

1

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!

Ruffina answered 25/5, 2012 at 14:7 Comment(0)
S
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.

Sosthenna answered 31/5, 2012 at 2:8 Comment(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... exists.Sosthenna

© 2022 - 2024 — McMap. All rights reserved.