#!C:\perl\bin\perl.exe -w #Need to load these for bot use use strict; use Net::AIM; #Especially if you want to reach out and talk to someone my %CONFIG = ( 'cgi_dir' => 'C:/windows/desktop/scripts/bot', #Exact directory of script (w/o trailing slash) 'bot_master' => '', #The owner of the bot 'bot_username' => '', #The bot's username to AIM 'bot_password' => '', #The bot's password to AIM ); #Alright here we go my $AIM = Net::AIM->new(); $AIM->newconn(Screenname => $CONFIG{'bot_username'}, Password => $CONFIG{'bot_password'}); my $connection = $AIM->getconn(); #Now log on to server #Now we need to load the parser sub on_im{ my ($self, $evt, $from, $to) = @_; my $args = $evt->args(); my ($nick, $friend, $msg) = @$args; #Get rid of any HTML in the message, so we can read it as plain text... chomp($msg); my $stripped = $msg; $stripped =~ s/<[^>]+>//g; $stripped =~ s/^\s+//g; #Now we load up the correct plugin for the command specified my($plugin, @lines) = split(/ /, $stripped); my $lines = join(' ',@lines); if(!defined($plugin)) { &send_response('nothing_todo',$nick); } else{ $plugin=lc($plugin); print "$nick requested $plugin - $CONFIG{'cgi_dir'}\n"; if(-e "$CONFIG{'cgi_dir'}/attach/$plugin.lib") { eval { require "$CONFIG{'cgi_dir'}/attach/$plugin.lib"; &main_program($self,$nick,$lines); }; if($@) {$self->send_im($nick,"Fatal Error Occured - $plugin - $@<\/B>");} #FATAL ERROR } else{ $self->send_im($nick,"Hey! I can't do that because I do not know what $plugin is."); } } } sub on_error { my ($self, $evt) = @_; my ($error, @stuff) = @{$evt->args()}; my $errstr = $evt->trans($error); $errstr =~ s/\$(\d+)/$stuff[$1]/ge; print STDERR "ERROR: $errstr\n"; } #This sets the AIM to the subroutines to handle the EVENT $connection->set_handler('error',\&on_error); $connection->set_handler('im_in',\&on_im); print "Starting the BOT\n"; #Start the connection $AIM->start; #### sub main_program{ my($self,$nick,$args) = $_[0]; my $time = localtime(time); $self->send_im($nick,"The current time is: $time."); } 1; #### Use of uninitialized value in substitution (s///) at C:/Perl/site/lib/Net/AIM/Co nnection.pm line 247. Use of uninitialized value in transliteration (tr///) at C:/Perl/site/lib/Net/AI M/Connection.pm line 248. Use of uninitialized value in concatenation (.) or string at C:/Perl/site/lib/Ne t/AIM/Connection.pm line 267.