@@ -0,0 +1,2203 @@
+import logging%0A%0Afrom slixmpp import ClientXMPP%0Afrom slixmpp.exceptions import XMPPError, IqError, IqTimeout%0A%0A%0Alog = logging.getLogger(__name__)%0A%0A%0Aclass _BusClient(ClientXMPP):%0A%0A    def __init__(self, jid, password, port=5222, host=None):%0A        super().__init__(self, jid, password)%0A        try:%0A            host = host or jid.split('@')%5B1%5D%0A        except IndexError:%0A            raise XMPPError(%22Missing argument: host%22)%0A        self._address = (host, port)%0A%0A        self.register_plugin('xep_0045')  # Multi-user chat%0A        self.register_plugin('xep_0133')  # Service administration%0A        self.register_plugin('xep_0077')  # In-band registration%0A%0A        self.use_ipv6 = False%0A%0A    def connect(self, **kwargs):%0A        return super().connect(address=self._address, **kwargs)%0A%0A%0Aclass Bus(object):%0A%0A    def __init__(self, jid, password, port=None, host=None):%0A        self.client = _BusClient(jid, password, port, host)%0A        self.client.add_event_handler('register', self._on_register)%0A        self.client.add_event_handler('session_start', self._on_start)%0A        self.client.add_event_handler('message', self._on_message)%0A        self.client.add_event_handler('disconnected', self._on_disconnect)%0A%0A    def _on_register(self, event):%0A        resp = self.client.Iq()%0A        resp%5B'type'%5D = 'set'%0A        resp%5B'register'%5D%5B'username'%5D = self.client.boundjid.user%0A        resp%5B'register'%5D%5B'password'%5D = self.client.password%0A%0A        try:%0A            resp.send()%0A        except IqError as exc:%0A            error = exc.iq%5B'error'%5D%5B'text'%5D%0A            log.warning(%22Could not register account: %7B%7D%22.format(error))%0A        except IqTimeout:%0A            log.error(%22No response from the server%22)%0A            self.disconnect()%0A        else:%0A            log.info(%22Account %7B%7D created%22.format(self.client.boundjid))%0A%0A    def _on_start(self, event):%0A        self.client.send_presence()%0A        self.client.get_roster()%0A%0A    def _on_message(self, event):%0A        pass%0A%0A    def _on_disconnect(self, event):%0A        pass%0A%0A    def connect(self, block=False):%0A        self.client.connect()%0A        self.client.process(forever=block)%0A%0A    def disconnect(self, timeout=5):%0A        self.client.disconnect(wait=timeout)%0A

Add a bus client using Slixmpp.