From: Daryl V. H. <dva...@sf...> - 2005-05-13 04:33:13
|
Hi, all! The Jabber chatbot framework is now at a state of some usefulness, you can log-in to a server, listen for messages and send messages. It uses Jivesoft's Smack toolkit (which made the framework code _much_ smaller), so you'll need to download it and point the projects classpath to two of the files, smack.jar and smackx.jar, in order to use the program. Just so you know, the test program logs into jabber.org, so if only one person uses the bot unaltered, it will log into jabber.org with the username "csjavaChatBot," and everyone can chat with it. I probably shouldn't have used threads to listen for messages, but I hadn't been sure of how it works, so I'll probably change it later. To log into a server, just create a new instance of JabberBotFramework, using the host name, username, and password (and optionally, port) that you want to use. The constructor will throw an org.jivesoft.smack.XMPPException if a problem occurrs, so you need to catch it. For examples, look at the file JabberBotTest.java in the same package as the JabberBotFramework, csjava.chatbot.*. To send a message, you just call .sendMessage(msg, to), where msg is the String message to send, and to is the username to send it to. To listen for messages, add a MessageListener to your copy of the JabberBotFramework with .addMessageListener(messageListener). That's basically it. If you want more functionality (it currently only supports text messages), please post saying so. Though I'm not sure how to recieve HTML, etc. messages. Anyway, here it is. Daryl. -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.11.9 - Release Date: 12/05/05 |