use Net::AIM; use SOAP::Lite; my $key = ""; # Your Google Dev Kit key my $query = ""; *SOAP::XMLSchema1999::Deserializer::as_boolean = *SOAP::XMLSchemaSOAP1_1::Deserializer::as_boolean = \&SOAP::XMLSchema2001::Deserializer::as_boolean; my $service = SOAP::Lite -> service('file:./GoogleSearch.wsdl'); # Refers to the Google Perl API print "Initializing.. please wait..\n"; $debug = 1; # Whether debug messages are printed $commands = 1; # Whether you can use the non-search commands $screenname = ""; # The AIM screenname to login to $password = ""; # The password to the screenname if (-e "logs" ne 1) { mkdir "logs"; } if (-e "logs/$screenname" ne 1) { mkdir "logs/$screenname"; } if (-e "logs/$screenname/temp" ne 1) { mkdir "logs/$screenname/temp"; } if (-e "logs/$screenname/saidtemp" ne 1) { mkdir "logs/$screenname/saidtemp"; } use NET::AIM; use LWP::Simple; $aim = new Net::AIM; use File::stat; $aim->newconn( Screenname => $screenname, Password => $password ) or die "Can't connect to AIM server.\n"; 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 { my $reply; my ($self, $event) = @_; my ($victim, $friend, $msg) = @{$event->args()}; $victim = $event->from; $victim = lc($victim); $victim =~ s/\s//g; if ($temp ne "") { $victim = "$temp"; } if ($victim eq "") { } else { if ($victim ne "") { $aim->evil($victim, 0); sleep(4); $aim->evil($victim, 0); $aim->add_deny(1, "buddies", $victim); } if (-e "logs/$screenname/idiots.html") { open (DATA, ">>logs/$screenname/idiots.html") || &fatal("$!"); print DATA ",$victim"; close(DATA); } else { open (DATA, ">logs/$screenname/idiots.html") || &fatal("$!"); print DATA "$victim"; close(DATA); } } } sub on_config { my ($self, $event) = @_; print "\nSucessfully started..\n\n"; $aim->set_info("<plug>Visit PerlMonks.Org</plug>"); $aim->send_config(); } sub on_error { } sub on_im { my $reply; my ($self, $event) = @_; my ($victim, $friend, $msg) = @{$event->args()}; $victim = $event->from; $rawvictim = lc($victim); $rawvictim =~ s/\s//g; $rawmsg = $msg; $msg =~ s/<(.|\n)+?>//g; $msg =~ s/[\&\;\`\'\"-\|\*\?\^\(\)\[\]\{\}\$\n\r(\.\.)]//g; $msg = lc($msg); $reply = ""; $i = 0; $cleanmsg = "$msg"; $cleanmsg =~ s/ //g; $cleanmsg =~ s/\n//g; if ($cleanmsg eq "") { @reply = ("At least say something to me","You won't get anything out of me unless you type at least one letter!","At least type one letter when you talk to me.","Please, talk to me, dont just say that!"); $replylen = scalar(@reply); $replynum = int(rand($replylen)); $reply = "$reply[$replynum]"; } if (-e "logs/$screenname/saidtemp/lastsaid$rawvictim.html") { open (FILE, "logs/$screenname/saidtemp/lastsaid$rawvictim.html"); $lastsaid = ; close(FILE); if ($msg eq "$lastsaid") { @reply = ("Please, don't repeat yourself","Stop repeating yourself","Don't repeat yourself","I will not talk to you unless you stop repeating yourself"); $replylen = scalar(@reply); $replynum = int(rand($replylen)); $reply = "$reply[$replynum]"; } } open (DATA, ">logs/$screenname/saidtemp/lastsaid$rawvictim.html"); print DATA "$msg"; close(DATA); $justcreated = ""; if (-e "logs/$screenname/temp/$rawvictim.html" ne 1) { $i++; $justcreated = "$rawvictim.html"; open (DATA, ">logs/$screenname/temp/$rawvictim.html") || &fatal("$!"); print DATA "1"; close(DATA); print "Just created $rawvictim.html because it didn't exist..\n"; } opendir(DIR, "logs/$screenname/temp"); foreach $file (sort(readdir(DIR))) { $i++; $file =~ s/ //g; if ($file eq ".") { $i--; } elsif($file eq "..") { $i--; } elsif($file eq "$justcreated") { if ($debug == 1) { print "\n\nSkipping $file because it was just created\n"; } $i--; } elsif ($file eq "$rawvictim.html") { } else { $full = "logs/$screenname/temp/$file"; $zs=stat($full); $mtime = $zs->mtime; $now = time(); $timetodel = 900; $what = $now - $mtime; if ($what > $timetodel) { unlink "logs/$screenname/temp/$file"; if ($debug == 1) { print "\nUnlinked $file.. because it was $what seconds old\n"; } $i--; } else { if ($debug == 1) { print "\nKept $file beacuse it was $what seconds old, not 900\n"; } } } } closedir(DIR); opendir(DIR, "logs/$screenname/saidtemp"); foreach $file (sort(readdir(DIR))) { $file =~ s/ //g; if ($file eq ".") { } elsif($file eq "..") { } else { $full = "logs/$screenname/saidtemp/$file"; $zs=stat($full); $mtime = $zs->mtime; $now = time(); $timetodel = 900; $what = $now - $mtime; if ($what > $timetodel) { unlink "logs/$screenname/saidtemp/$file"; if ($debug == 1) { print "\nUnlinked $file.. because it was $what seconds old (lastsaid temp file)\n"; } } else { if ($debug == 1) { print "\nKept $file beacuse it was $what seconds old, not 900 (lastsaid temp file)\n"; } } } } closedir(DIR); if ($i == 1) { $temp = "$rawvictim"; if ($debug == 1) { print "\nTemp set to $rawvictim...\n"; } } else { if ($i == 0) { $i == 1; } $temp = ""; if ($debug == 1) { print "\nTemp cleared, not talking to anyone.\n"; } } if ($debug == 1) { print "\nI am currently talking to this many people: $i..\n\n"; } if ($commands == 1) { if ($msg =~ /^!block/) { $what = "$msg"; $what =~ s/\!block//i; $self->add_deny("Buddies", $msg); if (-e "logs/$screenname/idiots.html") { open (DATA, ">>logs/$screenname/idiots.html") || &fatal("$!"); print DATA ",$what"; close(DATA); } else { open (DATA, ">logs/$screenname/idiots.html") || &fatal("$!"); print DATA "$what"; close(DATA); } } if ($msg =~ /^!ad/) { $what = "$msg"; $what =~ s/\!ad //i; $self->send_im($what, "Hello! I am Google Find! I am the latest in instant messaging searching. I can help you search Google just by sending me a message with your search criteria. Enjoy!"); $reply = "Message Sent."; } } if ($reply eq "") { if ($msg eq "bye") { $reply = "Goodbye."; } if ($msg eq "goodbye") { $reply = "Goodbye."; } if ($msg eq "c ya") { $reply = "Goodbye."; } if ($msg eq "cya") { $reply = "Goodbye."; } if ($msg eq "goodnight") { $reply = "Goodnight."; } if ($msg eq "goodnite") { $reply = "Goodnight."; } if ($msg eq "bye bye") { $reply = "Goodbye."; } if ($reply eq "") { my $result = $service -> doGoogleSearch( $key, $msg, 0, 5, SOAP::Data->type(boolean => "false"), "", SOAP::Data->type(boolean => "false"), "", "latin1", "latin1" ); if(defined($result->{resultElements})) { if (defined($result->{resultElements}->[0]->{title})) { $reply = "
1: $result->{resultElements}->[0]->{title}, $result->{resultElements}->[0]->{URL}
"; } if (defined($result->{resultElements}->[1]->{title})) { $reply = $reply . "2: $result->{resultElements}->[1]->{title}, $result->{resultElements}->[1]->{URL}
"; } if (defined($result->{resultElements}->[2]->{title})) { $reply = $reply . "3: $result->{resultElements}->[2]->{title}, $result->{resultElements}->[2]->{URL}
"; } if (defined($result->{resultElements}->[3]->{title})) { $reply = $reply . "4: $result->{resultElements}->[3]->{title}, $result->{resultElements}->[3]->{URL}
"; } if (defined($result->{resultElements}->[4]->{title})) { $reply = $reply . "5: $result->{resultElements}->[4]->{title}, $result->{resultElements}->[4]->{URL}
"; } } else { $reply = "No matching results. Refine your query."; } if ($reply eq "") { $reply = "No matching results. Refine your query."; } } } if (-e "logs/$screenname/idiots.html") { open (FILE, "logs/$screenname/idiots.html") || &fatal("$!"); $idiots = ; close(FILE); @idiots = split(/,/, $idiots); foreach $items (@idiots) { if ($found ne "1") { if ($items eq "$rawvictim") { $idiot = 1; $found = 1; undef $reply; $aim->evil($rawvictim, 0); $aim->add_deny('1', 'buddies', $rawvictim); print "\nThis guy is an idiot, So i warned him\n"; } else { $found = 0; $idiot = 0; } } } } if (-e "logs/$screenname/$victim.html" ne 1) { open (DATA, ">logs/$screenname/$victim.html"); print DATA "
AIM Bot Log for $rawvictim

 
"; close(DATA); open (DATA, ">>logs/$screenname/$victim.html"); print DATA "
$victim: $msg
$screenname: $reply"; close(DATA); } else { open (DATA, ">>logs/$screenname/$victim.html"); print DATA "
$victim: $msg
$screenname: $reply"; close(DATA); } print "$victim: $msg\n"; print "$screenname: $reply\n\n"; if ($idiot ne "1") { if ($found ne "1") { $reply = "$reply"; $reply =~ s/<//g; $reply =~ s/&gt;/>/g; $reply =~ s/'/'/g; sleep(2); $self->send_im($victim, "$reply"); } } else { print "\nWarned $rawvictim\n"; } undef $found; undef $reply; undef $i; undef @idiots; undef $idiots; undef $idiot; } sub fatal { $reason = shift; print "\n Fatal error: $reason\n\n"; exit; }