Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client roster support #41

Open
farski opened this issue Jul 23, 2013 · 2 comments
Open

Client roster support #41

farski opened this issue Jul 23, 2013 · 2 comments

Comments

@farski
Copy link

farski commented Jul 23, 2013

One of the primary things we use Hubot for in our office is to support pure XMPP-based staff chat (essentially XMPP broadcast). In order to make that happen, I extended hubot-xmpp to pull down the client's default roster when it connects, which then gets stored in an array on the robot.

This allows for something like...

robot.catchAll (msg) ->
  from = new Xmpp.JID(msg.message.room)
  text = "#{from.user}: #{msg.message.text}"

  for jid in robot.xmppRoster
    if from.user != jid.user
      params =
        to: jid.toString()
        type: 'chat'

      message = new Xmpp.Element('message', params).c('body').t(text)
      robot.xmppClient.send message

...so we get a lightweight broadcast system that relies only on XMPP.

That's a long way of saying, if I cleaned up my implementation and made a pull request, is this something you could see being in the core library? It may be possible to simply do this as a class that extends XmppBot, but I did this a while ago and pretty quick, so I'm not 100% sure. That may be ideal, though, if possible.

@markstory
Copy link
Contributor

I'm guessing this is a way to work around having to use group chat rooms, or is it to solve some other workflow?

@farski
Copy link
Author

farski commented Jul 29, 2013

In our case it was definitely to avoid using chat rooms or XMPP MUCs. We couldn't get the entire staff to consistently keep any chat room open all the time; we needed something that was push and would also store history and push that as well when people were offline and missed messages. XMPP and OpenFire did everything we needed for that. The only weak link was keeping track of the user list. Originally we just added a basic persistence layer with redis, but it was kind of a pain. Just grabbing the XMPP roster made a lot more sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants