diff options
author | Nathan Fritz <fritzy@netflint.net> | 2009-06-03 22:56:51 +0000 |
---|---|---|
committer | Nathan Fritz <fritzy@netflint.net> | 2009-06-03 22:56:51 +0000 |
commit | 96b103b27599e5af247c1e3b95d62c80c1e32a63 (patch) | |
tree | 0527b1607b16adb020759ee9a944e1b22e3e0e6b /example.py | |
download | slixmpp-96b103b27599e5af247c1e3b95d62c80c1e32a63.tar.gz slixmpp-96b103b27599e5af247c1e3b95d62c80c1e32a63.tar.bz2 slixmpp-96b103b27599e5af247c1e3b95d62c80c1e32a63.tar.xz slixmpp-96b103b27599e5af247c1e3b95d62c80c1e32a63.zip |
moved seesmic branch to trunk
Diffstat (limited to 'example.py')
-rw-r--r-- | example.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/example.py b/example.py new file mode 100644 index 00000000..dc7066ee --- /dev/null +++ b/example.py @@ -0,0 +1,40 @@ +import sleekxmpp.clientxmpp +import logging +from optparse import OptionParser +import time + +class Example(sleekxmpp.clientxmpp.ClientXMPP): + + def __init__(self, jid, password): + sleekxmpp.clientxmpp.ClientXMPP.__init__(self, jid, password) + self.add_event_handler("session_start", self.start) + self.add_event_handler("message", self.message) + + def start(self, event): + self.getRoster() + self.sendPresence() + + def message(self, event): + print("******got a message") + + +if __name__ == '__main__': + #parse command line arguements + optp = OptionParser() + optp.add_option('-q','--quiet', help='set logging to ERROR', action='store_const', dest='loglevel', const=logging.ERROR, default=logging.INFO) + optp.add_option('-d','--debug', help='set logging to DEBUG', action='store_const', dest='loglevel', const=logging.DEBUG, default=logging.INFO) + optp.add_option('-v','--verbose', help='set logging to COMM', action='store_const', dest='loglevel', const=5, default=logging.INFO) + optp.add_option("-c","--config", dest="configfile", default="config.xml", help="set config file to use") + opts,args = optp.parse_args() + + logging.basicConfig(level=opts.loglevel, format='%(levelname)-8s %(message)s') + xmpp = Example('user@gmail.com/sleekxmpp', 'password') + xmpp.registerPlugin('xep_0004') + xmpp.registerPlugin('xep_0030') + xmpp.registerPlugin('xep_0060') + xmpp.registerPlugin('xep_0199') + if xmpp.connect(('talk.google.com', 5222)): + xmpp.process(threaded=False) + print("done") + else: + print("Unable to connect.") |