#!/usr/bin/perl # John Reiser, newrisedesigns.com # Feel free to modify the code as you feel the need to do so. # Parts of this code were taken from a template found on the Web. That template was # open-source, and so is this program. So there. ## Next versions will have more features, and hopefully will run under use strict; # Change the following variables, $screenname and $password, to reflect # the screenname and password you want to use for your bot. $screenname = "chatterbot"; $password = "password"; use Chatbot::Eliza; $chatterbot = new Chatbot::Eliza { name => "John", debug => 1, prompts_on => 1, memory_on => 0, myrand => sub { my $N = defined $_[0] ? $_[0] : 1; rand($N); }, }; use NET::AIM; $aim = new Net::AIM; $aim->debug(1); $aim->newconn( Screenname => $screenname, Password => $password ) or die "Can't connect to AIM server.\n"; %morons = { }; use vars qw( $bot_version @stuff @ro @recent %bad ); $bot_version = "1.3.1"; my $conn = $aim->getconn(); $conn->set_handler('config', \&on_config); $conn->set_handler('im_in', \&on_im); $conn->set_handler('error', \&on_error); $conn->set_handler('eviled', \&on_evil); $aim->start; sub on_evil { # This is the warning sub, whenever your bot is warned this sub will be run. # I suggest to put code in here that warns/blocks the warner. my ($self, $evt, $from, $to) = @_; my ($level, $culprit) = @{$evt->args}; $culprit = 'An anonymous user' if ($culprit =~ /^\s*$/); open LOG, ">>aimlog.html"; print LOG "
$culprit slapped us! Our evil level is now $level -- chatter\n"; close LOG; $culprit =~ tr/A-Z/a-z/; $culprit =~ s/\s//g; if($culprit =~ /ananonymoususer/i){ $culprit = pop(@recent); $self->evil($culprit, 'anon'); } else{ $self->evil($culprit); $self->evil($culprit); } autoblock($self, $culprit); } sub on_config { my ($self, $event) = @_; #This sets the bots profile. my $myinfo = q[ This is the bot's profile. ]; $aim->set_info($myinfo); # $aim->set_away('i am a robot! =-O'); } sub on_error { # This sub is run whenever an error occurs. # No need to put things here until your final stages of your bot. } sub on_im { # This sub is run whenever the bot is IMed. # This is the main sub, which contains ths random number code. ## ## $victim = incoming user; $reply = user's message; $msg = bot's message ## my $reply; my ($self, $event) = @_; my ($victim, $friend, $msg) = @{$event->args()}; $victim = $event->from; $victim = lc($victim); $victim =~ s/\s//g; $msg =~ s/<(.|\n)+?>//ig; my $fh; my $dt = get_datetime(0); ### check the blocklist... don't want people warning your bot. if(autowarn($self, $victim) eq '1'){ ### Admin. Put screenname-restricted commands in this If block. if($victim eq 'myotherscreenname'){ if($msg =~ /shutdown bot/i){ $self->send_im($victim, "Shutting Down!"); die("Shutting Down!"); } if($msg =~ /^warn (\w*)/i){ cmd_warn($self, $victim, $1); } if($msg =~ /^msg (\w*) (.*)/i){ cmd_msg($self, $victim, $1, $2); sleep(5); } } if(autowarn($self, $IM_user) != 0){ sleep(2); open $fh, ">>chatterbotlog.html"; print $fh "