The Sixty Minute MUDbot.
I decided to scratch an itch and practice a little bit of the Manifesto of the Cult of Done tonight. So I wrote a clunky and fragile Perl wrapper which ties a chatbot to a MUCK. Here’s the code.
#!/usr/bin/perl # mudbot by Shannon Prickett# connect a pandorabots.com chatbot with a particular TinyMUCK, Pegasus. package mudbot; use Modern::Perl; use Net::Telnet; use Net::AIML; use Expect; use vars qw{$mud_connection $mud_conversation $mud_host $mud_name $mud_pass $mud_port $mud_sent $robot}; $mud_host = 'ginka.armageddon.org'; $mud_port = '4242'; $mud_name = 'Somebot'; $mud_pass = 'YRMEME'; $robot = Net::AIML->new( botid => 'GETTHISNUMBERFROMPANDORABOTS' ); $mud_connection = new Net::Telnet( Host => $mud_host, Port => $mud_port ) or die "Can't connect to $mud_host $mud_port: $!"; $mud_conversation = Expect->exp_init($mud_connection); $mud_conversation->log_group(1); $mud_conversation->log_user(1); $mud_conversation->log_stdout(1); $mud_conversation->log_file("/home/binder/src/mb/logfile", 'w'); $mud_conversation->expect(30, '-re', qr{connect # pretty standard MUCK greeting \s+ guest \s+ guest}msx, sub { my $fh = shift; $fh->send("connect $mud_name $mud_pass\n"); }); $mud_conversation->expect(30, 'Vote to ban the MisInformation SuperHighway', sub { my $fh = shift; $fh->send("\@desc me=Just a Perl toy of Binder's.\n"); }); $mud_conversation->expect(30, 'Description set', sub { my $fh = shift; $fh->send("home\nout\nvillage\n"); }); while (1) { my $command; $mud_conversation->expect(3, '-re', qr{ Somebot }msx, sub { my $fh = shift; $command = $mud_conversation->after(); $command =~ tr{\,\"\.\!}{}d; print "matched: $command\n"; if ($command =~ qr{QUIT}) { $fh->send("QUIT\n"); exit; } else { if (length($command)>3) { my $response = $robot->tell($command); $fh->send("say $response\n"); } } } ); }
