I was messing around with the ALICE chatbot software, when i learnt about AIML, this is a way for users to easily create there own chatbot personalitys and ten have them interpreted through the ALICE Engine, i then wondered if this could be implemented in perl, turns out somemone has done this already 'program v'. However i found it hard to pick out the ALICE Engine as it was heavily integrated with other stuff.
Thats when i found out about Net::AIML a simple module that integrates into pandorabots, a server hosting ALICE bots, basically it was just sending POST requests to the webpage, nothing to fancy. Anyway for a laugh i built it into a ircbot, to see who would be fooled into believing it was a real person, several people got strung along for a while although the majority soon recognised the hidden AI. Here's the code for it: *Sorry about the single letter variables, i couldn't be bothered to name them*
use Net::IRC; use Net::AIML; use strict; use warnings;
if (!@ARGV) {
print "\nUSAGE: bot.pl [SERVER] [NICK] [CHAN]\nTo talk to the bot simply /msg [NICK] [MESSAGE]\nOr in the channel [NICK], [MESSAGE]. Within your irc client\n"; exit(0); }
my $b = Net::AIML->new(botid => 'ba30d497ce360e23'); my $i = new Net::IRC; my $c = $i->newconn("Server", $ARGV[0], "Nick", $ARGV[1]); my $x;
$c->add_handler(376, \&o); $c->add_handler('msg', \&m); $c->add_handler('public', \&m); $i->start;
sub o { (my $s = shift)->join($ARGV[2]); $x = 1; }
sub m { if ($x == 1) { my ($s, $e) = @_; if ($e->{type} =~ /public/ && $e->{args}[0] =~ /^($ARGV[1]), /i or $e->{type} =~ /msg/) {
my $d = ($e->{type} =~ /public/) ? $e->{to}[0] : $e->{nick}; my $r = $e->{args}[0]; $r =~ s/^($ARGV[1]), //i; my $t = $b->tell($r)."\n";
$t =~ s/^Alice ://i; $t =~ s/<\/?.+?>//g; $s->privmsg($d, $t); } } }