July 4, 2006

Jabber Hackery...

Hi all,

Whenever I dive into a new bit of coding, I look for an example. A simple to use, doesn't do much example. From the example here, which is too complex to show the basics, I derived this simple python xmpp program.

#/usr/bin/python
import xmpp, os, sys

jid=xmpp.protocol.JID("cdibona@jabber.org","apasswordwhichIshallnotshare")
cl=xmpp.Client(jid.getDomain(),debug=[])
cl.connect()
cl.auth("cdibona","aninsecurepassword")
cl.send(xmpp.protocol.Message("cdibona@gmail.com","I am a test message, you sly dog, you."))


Indeed it is missing everything but I was able to im myself without worrying too much about other junk. Instant gratification is -very- important in programming. It doesn't even take responses, but it works well enough. To use it, replace my username and such with yours. Magic!

Yes, I'm writing another bot. Yes, I have some genetic need to write bots for all mediums. (last one was an IRC bot for the game studio I cofounded and augered into the ground) You'll need to apt-get python-xmpp before this will work.

1 comment:

Anonymous said...

Hey Chris,

Just spotted this at freshmeat: http://thpinfo.com/2007/python-jabberbot/

...A "Jabber bot framework for Python".

-A FLOSS Weekly Fan