All pastes #664468 Raw Edit

Perl -D

public text v1 · immutable
#664468 ·published 2007-08-20 15:42 UTC
rendered paste body
#!C:/apache2triad/perl/bin/perl.exe
use LWP;
use URI::Escape;
my $browser;
Xchat::register("Akumibot",1);
Xchat::print("Now loading Akumibot, version 1, by Gary Warman...");
Xchat::hook_server("PRIVMSG",\&genmess);
$BOTNAME="your bot's name here";
$BOTMASTER="your name here";
sub genmess {
if($_[1][0] =~ /\:(.*)\!(.*)\@(.*).*PRIVMSG.*(.*) \:(.*)/)
{
$un = Xchat::get_info("nick");
if($un ne $BOTNAME) { return Xchat::EAT_NONE; }
else {
$user = $1;
$email = $2;
$server = $3;
$room = $4;
$message = $5;
if($message =~ /^\[time\]/) {
@a = localtime(time);
$tijd = $a[2] . ":" . $a[1] . ":" . $a[0] . " (CST)";
Xchat::command("msg $room $tijd");
return Xchat::EAT_NONE;
}
elsif($message =~ /^\[part\]/) { if($user eq $BOTMASTER) { Xchat::command("part \#$room Yes, master..."); } else { Xchat::command("msg $user OI. PRICK."); } }
elsif($message =~ /^\[say (.*)\]/) { Xchat::command("say $1"); return Xchat::EAT_NONE; }
elsif($message =~ /\[j \#(.*)\]/) {
if($user eq $BOTMASTER) {
Xchat::command("join \#$1");
return Xchat::EAT_NONE;
} else { Xchat::command("msg $user Sorry, only $BOTMASTER can use the [j] command."); }
}
elsif($message =~ /\[msg (.*):(.*)\]/) {
if( $user eq $BOTMASTER) {
Xchat::command("msg $1 $2");
}
else { Xchat::command("msg $user Sorry, only $BOTMASTER can use the [msg] command."); }
}
elsif($message =~ /^\?\((.*)\)(\d+)$/) {
$count = 0;
if($2 ne undef) { $max = $2; }
else { $max = 1; }
if($max > 10) { Xchat::command("say Sorry, the max searches must be 10 or smaller."); return Xchat::EAT_NONE; }
($doc,undef,$successful,undef) = do_GET("http://google.com/search?q=".uri_escape($1));
while($doc =~ /<div><a href=\"(.*)\" class=l>(.*)<\/a><table border=0 cellpadding=0 cellspacing=0><tr><td class=j><font size=\-1>/g and $count < $max )
{
$dcount = $count+1;
$title = $2;
$link = $1;
$title =~ s/(<b>|<\/b>)//ig;
$link =~ s/\" class.*\///ig;
Xchat::command("say Result \#".$dcount.": " .$title);
Xchat::command("say Link: ".$link);
$count++;
}
return Xchat::EAT_NONE;
}
else { return Xchat::EAT_NONE; }
}
}
}

sub do_GET {
  # Parameters: the URL,
  #  and then, optionally, any header lines: (key,value, key,value)
  $browser = LWP::UserAgent->new(  ) unless $browser;
  $browser->agent('Mozilla/4.76 [en] (Win98; U)');
  my $resp = $browser->get(@_);
  return ($resp->content, $resp->status_line, $resp->is_success, $resp)
    if wantarray;
  return unless $resp->is_success;
  return $resp->content;
}

sub do_POST {
  # Parameters:
  #  the URL,
  #  an arrayref or hashref for the key/value pairs,
  #  and then, optionally, any header lines: (key,value, key,value)
  $browser = LWP::UserAgent->new(  ) unless $browser;
  my $resp = $browser->post(@_);
  return ($resp->content, $resp->status_line, $resp->is_success, $resp)
    if wantarray;
  return unless $resp->is_success;
  return $resp->content;
}
Xchat::print("Akumibot loaded!");