Skip to content

Instantly share code, notes, and snippets.

@lehrblogger
Created May 11, 2012 05:39
Show Gist options
  • Save lehrblogger/2657728 to your computer and use it in GitHub Desktop.
Save lehrblogger/2657728 to your computer and use it in GitHub Desktop.
GUI/sleekxmpp interaction
import logging
from sleekxmpp import ClientXMPP
from sleekxmpp.exceptions import IqError, IqTimeout
class GUIMessageBot(ClientXMPP):
def __init__(self, jid, password, gui_function):
ClientXMPP.__init__(self, jid, password)
self.add_event_handler("session_start", self.session_start)
self.add_event_handler("message", gui_function)
def session_start(self, event):
self.send_presence()
self.get_roster()
if __name__ == '__main__':
# Ideally use optparse or argparse to get JID,
# password, and log level.
logging.basicConfig(level=logging.DEBUG,
format='%(levelname)-8s %(message)s')
xmpp = EchoBot('[email protected]', 'use_getpass')
xmpp.connect()
xmpp.process(block=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment