From: Jonathan H. <vha...@ru...> - 2004-08-03 14:12:28
|
> There are a ton of infobots still running. I'd like to wake the > project up and get as many folks as are interested working on the same > tree. I started off with an infobot, but, as I'm sure everybody has found, it needs fiddling and hacking to get working the way you want it. After a while, I had hacked it around so much, it was barely an infobot any more. However, I began to realise that the infobot architecture is just not well designed enough for the sort of bot that we need. Reviving infobot is like reviving gwbasic or something - it was way cool back in the day, but things have moved on, and there's no point in trying to go back and fix things up. That said, infobots are all over the place, and they are very cool bots, and we can't just stop supporting them. I don't want to be one of those people that says "Rework! Fix! Revamp! Start again!" and never does anything. When I decided that infobot just wasn't able to support what I wanted, I started writing my own bot from scratch. It was originally intended to be an infobot-clone, with all the same commands, the same interface, etc. And, in fact, it was, by about version 0.1. But I've carried on hacking and fiddling, and it's kind of moved on. I scrapped the old infobot-style Berkeley DB interface (although the modules still work if anybody still wants to use them) and moved onto a MySQL database. Most of the other infobot functions still work with maybe a slight behavioural change here and there as users requested/complained about them. I know that I'm blowing my own bot's trumpet on the infobot mailing list, but I had many long hours struggling with infobot, and the thing that bit me the most was the way you had to restart the entire bot just to add some punctuation in a reply. That's the main attraction of my new bot: it is modular, and hotpluggable. My bot is called Knab (recursively, "Knab is Not A Bot"). The architecture looks vaguely like so: Knab::Source <-> Knab::Processor <-> Knab::Modules Knab::Source is a generic API for a "Source", which could be IRC (implemented fully), the Console (implemented fully), a GSM modem, a webpage, Jabber, whatever. There is a certain article of faith of mine: <Vhata> Spinach: rule #1 for bots <Spinach> rule #1 for bots is Speak Only When Spoken To Knab's architecture enforces this. The Source "runs", waiting for input. When it receives input, it passes it to the processor, which processes it, and returns a reply, or replies. These are then returned as output. Thus, the bot can only speak when spoken to. "Processing" is a matter of passing the input to each one of the loaded "Modules" in order of priority. The priority for each module is set as a configuration variable, and the input gets passed to each one in turn. These modules have a "Match" function, which gets passed the input. If the Match function returns False, then the Module is deemed not to care about this input, and processing moves onto the next module. If the Match function returns true, then the input is passed to the Process() function of the module, which can do whatever it wants with the input. If the Process() function sets the 'processed' flag for this input, then no more processing will be done, and the replies (if any) will be output, and the bot will move on. In this way, you can have an Ignore module right at the top of the processing queue - it will always Match input, and it will check the sender of the input - if this sender is in the ignore list, it will set 'processed' to true, and return - no more processing will be done, and the sender will be effectively ignored. The lovely thing about Knab, however, is that these modules are hotpluggable. You can load/unload Modules while the bot is running. You can load a module, test it, fix an error in the code, and reload it, and the changes will take place immediately. This way, you don't need to keep restarting the bot while you're developing it. If you want to play with a Knab, you can download it from http://sourceforge.net/projects/knab/ Or you can join irc.zanet.net, channel # (i.e. # by itself. Nothing else. Not #hash or #foo, just #), and talk to Spinach, my Knab. If you want to play with your own Knab, I'm afraid I'm a bit lax on the documentation. You will need the following perl modules installed: BerkeleyDB Compress::Zlib DBI DB_File Digest::MD5 Digest::SHA1 Fcntl FileHandle Geo::IP HTML::Entities HTML::TableContentParser HTTP::Request::Common IPC::Open2 LWP::UserAgent Math::BaseCalc Math::Trig Net::Dict POSIX Socket Symbol WWW::Search FileHandle Net::IRC A lot of which are installed with perl's base. Here is an example of a Knab running. <Vhata> Spinach: hi <Spinach> sup, Vhata! <Vhata> Spinach: lsmod <Spinach> Vhata: Module list: Strip Auth Ignore Hate Rehash Irc Modules Perl MySQLSee ITime Fortune BaseConv Crypt NickOMeter RoShamBo GoogleCmp Slashdot REBOL MD5 Roxbury RFC Announce Morse Dict Jwhois Google NMBLookup Dvorak DiscDate Babel StonerName EtherCode Exchange TraceRoute Insult Units Greet Ping Divine RUWeather Swear HowFar MySQLSeen Rot13 Urban NSLookup Lotto Karma BashOrg Say MySQLFactoid MySQLFactoidupdate MySQLFactoidforget MySQLFactoidsearch Karma <Vhata> Spinach: modinfo Exchange <Spinach> Vhata: Exchange: Calculate exchange rate. Usage: "currencies for <place>", or "exchange <value> <currency> into <currency>". TLDs and country names can also be used. <Vhata> Spinach: exchange 10 USD for .uk <Spinach> Vhata: 10.00 (United States Dollar (USD)) makes 5.48910 (Pound (GBP)) <Vhata> Spinach: RFC for avian <Spinach> RFC 1149 Standard for the transmission of IP datagrams on avian carriers. D. Waitzman. Apr-01-1990. (Format: TXT=3329 bytes) (Updated by RFC2549) (Status: EXPERIMENTAL) <Spinach> RFC 2549 IP over Avian Carriers with Quality of Service. D. Waitzman. Apr-01-1999. (Format: TXT=9519 bytes) (Updates RFC1149) (Status: INFORMATIONAL) <Vhata> Spinach: itime <Spinach> Vhata: At the sound of the bot, the Internet Time will be 524.99 <Vhata> Spinach: define marmalade <Spinach> Vhata: marmalade n : a preserve made of the pulp and rind of citrus fruits <Vhata> Spinach: google for killing children to benefit canadian pig farmers <Spinach> Vhata: Google found 'Canadian Coalition for Green Health Care', at http://www.greenhealthcare.ca/workshop22-09-00.htm <Vhata> Spinach: modinfo Fortune <Spinach> Vhata: Fortune: Return a fortune cookie. Usage: "fortune". <Vhata> Spinach: nslookup knab.sourceforge.net <Spinach> Vhata: knab.sourceforge.net is 66.35.250.209 <Vhata> Spinach: unload NSLookup <Spinach> Vhata: Module NSLookup unloaded <Vhata> Spinach: nslookup knab.sourceforge.net <Spinach> Vhata: excuse me? <Vhata> Spinach: load NSLookup <Spinach> Vhata: Module NSLookup loaded <Vhata> Spinach: foo is bar <Spinach> Vhata: I already know stuff about what foo is <Vhata> Spinach: literal foo <Spinach> foo =is= baz <Vhata> Spinach: forget foo <Spinach> Vhata: foo is no longer an issue <Vhata> Spinach: foo is bar <Spinach> Vhata: gotcha <Vhata> Spinach: foo is also bing <Spinach> Vhata: gotcha <Vhata> Spinach: foo has nothing on bar <Spinach> Vhata: okay <Vhata> Spinach: literal foo <Spinach> foo =has= nothing on bar; and =is= bar|bing <Vhata> Spinach: foo are also a flock of baz <Spinach> Vhata: sure thing <Vhata> Spinach: literal foo <Spinach> foo =are= a flock of baz; and =has= nothing on bar; and =is= bar|bing <Vhata> Spinach: foo =~ s/flock/herd/ <Spinach> Vhata: gotcha <Vhata> Spinach: literal foo <Spinach> foo =are= a herd of baz; and =has= nothing on bar; and =is= bar|bing You'll notice that there are multiple verbs in factoids ('is', 'has', 'are', etc). Knab has everything that an infobot has (and, indeed, is almost indistinguishable from an infobot), but I really feel that the monolithic design of infobot is not the way forward for a bot. I'd love your comments/flames/patches/input? -Jonathan ----- End forwarded message ----- -- Vhata Vas Hyah... ---------------------------------------------------------------------------- This email is provided "as is" and without warranty. Any express or implied warranties, including, but not limited to, those of merchantability and fitness for a particular purpose are disclaimed. In no event shall the authors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages arising in any way out of the reading of this email ---------------------------------------------------------------------------- |