simple-xmpp / node-simple-xmpp

Simple High Level NodeJS XMPP Client
302 stars 90 forks source link

How can I list of users present in a MUC? #50

Open soichih opened 10 years ago

soichih commented 10 years ago

I have written a XMPP bot that lives in our MUC chatroom. I am wondering if there is a way to detect who are currently in the XMPP chatroom with simple-xmpp.

Thanks!

mutil commented 9 years ago

I wonder too...

jwoertink commented 9 years ago

You can always just proxy to node-xmpp using xmpp.conn if you wanted. note: this is untested code

var xmpp = require('simple-xmpp');

var stanza = new xmpp.Element('iq', {from: 'me@my.server', to: 'room@chat.server', type: 'get', id: 'muc_id'}).c('query', { xmlns: 'http://jabber.org/protocol/disco#items'});
xmpp.conn.send(stanza);

xmpp.on('stanza', function(stanza) {
  if(stanza.name == 'iq' && stanza.attrs.type == 'result' && stanza.attrs.id == 'muc_id') {
    // stanza.children[0].children should have your users available in the room
  }
});

You can check out the implementation here