oreilly.comSafari Books Online.Conferences.
Articles Radar Books  

The Command Line of the Future Part 2: Expanding ChatBot's Repertoire

by DJ Adams, author of Programming Jabber
02/08/2002

Editor's Note--In an earlier article, Is Jabber's Chatbot the Command Line of the Future?, we took an introductory look at ChatBot, the Jabber bot written in Perl and a regular occupant in the "jdev" conference room on conference.jabber.org. Having presented ChatBot's standard features, which exist as plug-ins, in this article we will discuss adding a new feature by writing our own plug-in for ChatBot.

Adding a New Feature to ChatBot

Now we know how to get ChatBot up and running, let's look at how we might expand its repertoire of features. Rather than write a silly function that doesn't do much more than say "Hello World," let's look at giving ChatBot a facility that has some use beyond this article. Despite the arrival of the Euro currency in Europe, currency conversion still has its uses, especially for those countries (like my homeland) that have not yet taken the plunge. Another use of currency conversion is it allows for discussion of prices of items essential for everyday life, such as MP3 hardware, between the U.K. and the U.S.

So, let's add a currency conversion feature to ChatBot.

Hey, wait a minute! Currency conversion is useful! So it's likely that it's been done before. Rummaging around in the dark recesses of my brain, and those of Usenet, I remember that infobot, another Perl bot mentioned in the previous article, has this facility. Taking a quick look at infobot's home page, and the CVS repository, I find a script called exchange.pl, written by Bobby Billingsley. (See the "Resources" section later in this article for details.) Hmmm, this looks promising. Looking inside the script (hurrah for open source!) and at infobot's release notes at http://www.infobot.org/guide-0.43.x.html, it seems that this is exactly what we're looking for.

Related Reading

Programming JabberProgramming Jabber
By DJ Adams
Table of Contents
Index
Full Description

The script provides currency-exchange facilities by calling a Web service that does the actual currency conversions. The Web service is at http://www.xe.net, and the script uses the LWP::UserAgent and HTTP::Request::Common modules to make the HTTP calls.

Now, every scripter worth his or her salt knows that laziness, impatience, and hubris are three excellent qualities to have when it comes to coding. Putting all three of these qualities into practice, it turns out that it's easy to get this script to work for us in a ChatBot environment instead of in its native environment, infobot.

Let's go through the steps required to add a plug-in to ChatBot, as described in the PLUGIN_API.txt file in the chatbot/ directory.

Pages: 1, 2, 3

Next Pagearrow





P2P Weblogs

Richard Koman Richard Koman's Weblog
Supreme Court Decides Unanimously Against Grokster
Updating as we go. Supremes have ruled 9-0 in favor of the studios in MGM v Grokster. But does the decision have wider import? Is it a death knell for tech? It's starting to look like the answer is no. (Jun 27, 2005)

> More from O'Reilly Developer Weblogs


More Weblogs
FolderShare remote computer search: better privacy than Google Desktop? [Sid Steward]

Data Condoms: Solutions for Private, Remote Search Indexes [Sid Steward]

Behold! Google the darknet/p2p search engine! [Sid Steward]

Open Source & The Fallacy Of Composition [Spencer Critchley]