xmppjs / hubot-xmpp

XMPP adapter for Hubot
181 stars 103 forks source link

robot.enter not working as intended #91

Open anupdhml opened 8 years ago

anupdhml commented 8 years ago

Some scripts respond to users entering (or leaving) a room, as in:

robot.enter (msg) ->
  username = msg.message.user.name
  room = msg.message.user.room
  if username isnt robot.name
    robot.logger.info "User #{username} entered the room #{room}"

With hubot-xmpp, this is not working for me when users enter the room for the first time. It works though, when people change their status (eg: available from away), and when hubot joins the room.

Coming from hubot-irc, I expected it to work only when users enter the room for the first time, and not in other cases. Looks like hubot-xmpp is reading presence stanzas and because xmpp sends presence for every person in a room whenever hubot joins the room or when user status changes, robot.enter is being triggered all the time:

https://github.com/markstory/hubot-xmpp/blob/7fbc3a8d25a93defd1b773fb673202e42c82b0e7/src/xmpp.coffee#L343

Even if this was intended, I would still like the functionality to work when people just enter the room (useful for messaging people about the room and its rules, or just general help).

Not a high priority for us right now, but I want to look more into this later. Suggestions are welcome!

markstory commented 8 years ago

Yeah, I don't know how that would work given how XMPP works under the hood.

krutaw commented 7 years ago

Could it be the implementation of XMPP on the server itself? I ask because I'm using this exact same functionality to create a NOC "warroom" where everything is logged (even when people join / disconnect) and it's working flawlessly when used with Cisco Jabber.