pythonxmppchatroommultiuserchat

SleekXMPP Muc Room List and Discovering


I'm new to XMPP :) I've been working with Ejabberd and sleekXMPP. My question is How can online rooms are listed with sleekXMPP?

Thank you


Solution

  • I struggled with this for a while as well. Listing rooms is not part of MUC (xep_0045), but is instead a part of Service Discovery (xep_0030).

    Some documentation is here, but it still required some experimentation to find the 'disco_items" array key. Note that the "iterator" parameter only has effect if you also load XEP-0059.

    It works as follows:

    1. Ensure that you have 0030 loaded:

      xmpp.register_plugin('xep_0030')
      
    2. Use it: (in my case this is part of the start() method of the class that extends sleekxmpp.ClientXMPP)

      result = self['xep_0030'].get_items(jid='conference.your.xmpp.server.com', iterator=True)
      
      for room in result['disco_items']:
          print "Found room %s, jid is %s" % (room, room['jid'])