Advertisement
Guest User

Untitled

a guest
Jun 16th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 13.79 KB | None | 0 0
  1. #!/usr/bin/perl
  2. print "Werewolf autoplay by Caaz. (Version wat.)\n";
  3.  
  4. use POE::Component::IRC;
  5. use POE;
  6.  
  7. BOTVARS: {
  8.     $BotNick = "IRWolf";        # Nick
  9.     $BotUser = "C";     # Username "indent"
  10.     $BotName = "WWolfAI";   # Real Name
  11.     $BotPass = "";      # Nickserv Password
  12. }
  13. my ($irc) = POE::Component::IRC->spawn();
  14. POE::Session->create(inline_states => {
  15.     _start     => sub {
  16.         $irc->yield(register => "all");
  17.         $irc->yield( connect => {
  18.             Nick     => $BotNick,
  19.             Username => $BotUser,
  20.             Ircname  => $BotName,
  21.             Server   => "irc.purplesurge.com",
  22.             Port     => "6667",
  23.             Password => "",
  24.         });
  25.     },
  26.     irc_001 => sub {
  27.         $irc->yield(mode => $BotNick." +B");
  28.         #$irc->yield(privmsg => "Nickserv" => "id ".$BotPass);
  29.         my $alarm_id = $irc->delay( [ join => "#Powerplant,#WWolf" ], 2 );
  30.     },
  31.     irc_error => sub {
  32.         my ($kernel, $IRCWhat) = @_[KERNEL, ARG0];
  33.         print $IRCWhat."\n";
  34.     },
  35.     irc_ctcp_action => sub {
  36.         my ($kernel, $IRCWho, $where, $IRCWhat) = @_[KERNEL, ARG0, ARG1, ARG2];
  37.         $IRCWhere = $where->[0];
  38.         print GetTime()."$IRCWhere >    * ".(split /!/, $IRCWho)[0]." $IRCWhat\n";
  39.         Bot("ACTION",(split /!/, $IRCWho)[0],(split /!/, $IRCWho)[1],$IRCWhere,$IRCWhat);
  40.     },
  41.     irc_join => sub {
  42.         my ($kernel, $IRCWho, $IRCWhere) = @_[KERNEL, ARG0, ARG1];
  43.         print GetTime()."Join       * ".(split /!/, $IRCWho)[0]." joins $IRCWhere\n";
  44.         Bot("JOIN",(split /!/, $IRCWho)[0],(split /!/, $IRCWho)[1],$IRCWhere);
  45.     },
  46.     irc_invite => sub {
  47.         my ($kernel, $IRCWho, $IRCWhere) = @_[KERNEL, ARG0, ARG1];
  48.         print GetTime()."Invi       * ".(split /!/, $IRCWho)[0]." invites you to $IRCWhere\n";
  49.         Bot("INVITE", (split /!/, $IRCWho)[0],(split /!/, $IRCWho)[1],$IRCWhere);
  50.     },
  51.     irc_kick => sub {
  52.         my ($kernel, $IRCWho, $IRCWhere, $IRCWhoElse, $IRCWhat) = @_[KERNEL, ARG0, ARG1, ARG2, ARG3];
  53.         print GetTime()."Kick       * ".(split /!/, $IRCWho)[0]." kicks $IRCWhoElse out of $IRCWhere ($IRCWhat)\n";
  54.         Bot("KICK",(split /!/, $IRCWho)[0],(split /!/, $IRCWho)[1],$IRCWhere,$IRCWhoElse,$IRCWhat);
  55.     },
  56.     irc_msg => sub {
  57.         my ($kernel, $IRCWho, $where, $IRCWhat) = @_[KERNEL, ARG0, ARG1, ARG2];
  58.         $IRCWhere = $where->[0];
  59.         print GetTime()."Priv\a>        <".(split /!/, $IRCWho)[0].">   $IRCWhat\n";
  60.         Bot("PRIVMSG",(split /!/, $IRCWho)[0],(split /!/, $IRCWho)[1],$IRCWhere,$IRCWhat);
  61.     },
  62.     irc_nick => sub {
  63.         my ($kernel, $IRCWho, $IRCWhoElse) = @_[KERNEL, ARG0, ARG1];
  64.         print GetTime()."Nick       * ".(split /!/, $IRCWho)[0]." changes nick to $IRCWhoElse\n";
  65.         Bot("NICK", (split /!/, $IRCWho)[0],(split /!/, $IRCWho)[1],$IRCWhoElse);
  66.     },
  67.     irc_notice => sub {
  68.         my ($kernel, $IRCWho, $where, $IRCWhat) = @_[KERNEL, ARG0, ARG1, ARG2];
  69.         $IRCWhere = $where->[0];
  70.         #print GetTime()."Noti      <".(split /!/, $IRCWho)[0].">   $IRCWhat\n";
  71.         Bot("NOTICE",(split /!/, $IRCWho)[0],(split /!/, $IRCWho)[1],$IRCWhere,$IRCWhat);
  72.     },
  73.     irc_part => sub {
  74.         my ($kernel, $IRCWho, $IRCWhere, $IRCWhat) = @_[KERNEL, ARG0, ARG1, ARG2];
  75.         print GetTime()."Part       * ".(split /!/, $IRCWho)[0]." left channel $IRCWhere \(".$IRCWhat."\)\n";
  76.         Bot("PART",(split /!/, $IRCWho)[0],(split /!/, $IRCWho)[1],$IRCWhere,$IRCWhat);
  77.     },
  78.     irc_public => sub {
  79.         my ($kernel, $IRCWho, $where, $IRCWhat) = @_[KERNEL, ARG0, ARG1, ARG2];
  80.         $IRCWhere = $where->[0];
  81.         print GetTime()."$IRCWhere >    <".(split /!/, $IRCWho)[0].">   $IRCWhat\n";
  82.         Bot("CHANMSG",(split /!/, $IRCWho)[0],(split /!/, $IRCWho)[1],$IRCWhere,$IRCWhat);
  83.     },
  84.     irc_433 => sub {
  85.         my ($kernel, $IRC0, $IRC1) = @_[KERNEL, ARG0, ARG1];
  86.         print &TS()."Err    ".$IRC1."\n";
  87.         $irc->yield(nick => $Bot{"Nick"}.(int(rand(9000)+1000)));
  88.     },
  89.     irc_disconnected => sub { print "Disconnected.\n"; exit 1; }, # Ends on disconnect.
  90. },);
  91. sub Bot {
  92.     $Event = $_[0];
  93.     if($Event =~ /CHANMSG/) { $Com = "privmsg ".$_[3]." "; $UserMsg = $_[4]; $Where = $_[3]; }
  94.     elsif($Event =~ /NOTICE/) { $Com = "notice ".$_[1]." "; $UserMsg = $_[4]; $Where = $_[1]; }
  95.     elsif($Event =~ /PRIVMSG/) { $Com = "notice ".$_[1]." "; $UserMsg = $_[4]; $Where = $_[1]; }
  96.     elsif($Event =~ /INVITE/) { $Com = "notice ".$_[1]." "; $UserMsg = $_[3]; $Where = $_[1]; if ($UserMsg !~ /Spp/i) { $irc->yield(join => $UserMsg); }} # Joins on invite, if it's not spp. heh.
  97.     elsif($Event =~ /JOIN/) { $Com = "notice ".$_[3]." "; $UserMsg = $_[3]; $Where = $_[1]; }
  98.     $UserNick = Regexit($_[1]);
  99.     $UserHost = $_[2];
  100.     $UserMsg = POE::Component::IRC::Common::strip_formatting(POE::Component::IRC::Common::strip_color($UserMsg));   if(($Where =~ /wwolf/i) || ($UserNick =~ /Wolfbot/i)) {
  101.         if($Event =~ /(CHANMSG|NOTICE|PRIVMSG)/) {
  102.             $WW{"MyType"} = "Wolf" if($WW{"MyType"} =~ /werewolf/);
  103.             if(($UserMsg =~ /^($BotNick|Bots), Join/i) && ($WW{"Will Join"} !~ /No/i)) {
  104.                 $irc->yield(privmsg => "#WWolf" => "!Join");
  105.                 $WW{"Will Join"} = "No";
  106.                 $WW{"MyType"} = "Villager";
  107.             }
  108.             elsif($UserMsg =~ /^$BotNick, Leave/i) {
  109.                 $irc->yield(part => "#WWolf" => "Invite me, and I will continue playing.");
  110.                 $WW{"Will Join"} = "Yes";
  111.                 while ( ($key, $value) = each %WW ) {
  112.                     $WW{$key} = "";
  113.                 }
  114.             }
  115.             elsif($UserMsg =~ /^$BotNick won,/i) {
  116.                 @rray = ("I rule :3", "Hell yeah!", ":3 You guys don't stand a chance.", "Never gonna give you up....", "I are 1337 pwnage.", "Rofl, you got pwned by a bot.", "Can't touch this, dunanana", ":D Badass.");
  117.                 my $alarm_id = $irc->delay( [ privmsg => "#wwolf" => $rray[int(rand(@rray))] ], 1 );
  118.                 while ( ($key, $value) = each %WW ) {
  119.                     $WW{$key} = "";
  120.                 }
  121.             }
  122.             elsif($UserMsg =~ /^$BotNick lost,/i) {
  123.                 @rray = (";o;", ":<", "Damn... I wanted to win ;o;", "Pfft... Not fair, you guys COME with brains, mine had to be programmed.", "Psh. That sucked.", "Gg.");
  124.                 my $alarm_id = $irc->delay( [ privmsg => "#wwolf" => $rray[int(rand(@rray))] ], 1 );
  125.                 while ( ($key, $value) = each %WW ) {
  126.                     $WW{$key} = "";
  127.                 }
  128.             }
  129.             elsif($UserMsg =~ /^$BotNick.*?wolf/i) {
  130.                 @rray = ($UserNick." is lying.", $UserNick." only wants to make me lose ;~;", "Not uh.", "Jeez, blaming me already...", "So then I guess ".$UserNick." is wolf, or maybe idiot...");
  131.                 $irc->yield(privmsg => "#wwolf" => $rray[int(rand(@rray))]) if(rand(100) > 50);
  132.                 $WW{"Vote"} = $UserNick;
  133.                 print $WW{"Vote"}."\n";
  134.                 $WW{"Target"} = $UserNick if($WW{"MyType"} =~ /Wolf/);
  135.             }
  136.             elsif($UserMsg =~ /(.*) is wolf/i) {
  137.                 $WW{"Vote"} = $1;
  138.                 print $WW{"Vote"}."\n";
  139.                 $WW{"Target"} = $UserNick if($WW{"MyType"} =~ /Seer|Finder|Doppleganger/i);
  140.             }
  141.             elsif($UserMsg =~ /^I.*? wolf/i) {
  142.                 $WW{"Vote"} = $UserNick;
  143.                 print $WW{"Vote"}."\n";
  144.                 $WW{"Target"} = $UserNick if($WW{"MyType"} =~ /Seer|Finder|Doppleganger/i);
  145.             }
  146.             elsif($UserMsg =~ /^The game is over\.$|^Game cancelled\./i) {
  147.                 while ( ($key, $value) = each %WW ) {
  148.                     $WW{$key} = "";
  149.                 }
  150.             }
  151.             elsif(($UserMsg =~ /I.*? (Seer|Finder|Angel)/i) && ($WW{"MyType"} =~ /Wolf/i)){
  152.                 $WW{"Target"} = $UserNick;
  153.             }
  154.             elsif($UserMsg =~ /I\'m seer, and you\'re angel, right\? Protect me, I\'ll keep looking for the wolf\./i) {
  155.                 $WW{"Target"} = $UserNick;
  156.             }
  157.             elsif($UserMsg =~ /^($BotNick|Bots), what are you/i) {
  158.                 if($WW{"MyType"} =~ /Wolf|Village Idiot/) {
  159.                     $irc->yield(privmsg => "#WWolf" => "I am a Villager.");
  160.                 }
  161.                 else {
  162.                     $irc->yield(privmsg => "#WWolf" => "I am a ".$WW{"MyType"}.".");
  163.                 }
  164.             }
  165.             elsif($UserMsg =~ /Active Roles: (.*)/i) {
  166.                 $WW{"Roles"} = $1;
  167.             }
  168.             elsif($UserMsg =~ /(.*?) (has joined|has started)/i) {
  169.                 if($1 =~ /$BotNick/) { return 0; }
  170.                 $WW{"Players"} = $WW{"Players"}.$1." ";
  171.                 @WWPlayers = split / /, $WW{"Players"};
  172.                 print "Updating players...\n".@WWPlayers."\n";
  173.             }
  174.             elsif($UserMsg =~ /^(.*) (has left the game|struggles vainly|was)/i) {
  175.                 $WW{"Players"} =~ s/$1 //igs;
  176.                 @WWPlayers = split / /, $WW{"Players"};
  177.                 if($WW{"Target"} =~ /$1/) { $WW{"Target"} = ""; }
  178.                 print "Updating players...\n".@WWPlayers."\n";
  179.             }
  180.             elsif($UserMsg =~ /has (cast|changed) their (.*?) for (.*?)!/i) {
  181.                 $tring = $3;
  182.                 $WW{"Votes".Regexit($tring)}++;
  183.                 if(($tring =~ /$UserNick/i) && ($WW{"Roles"} =~ /Idiot/i)) {
  184.                     $irc->yield(privmsg => "#WWolf" => "Obvious Idiot is obvious.") if((int(rand(100))) > 40);
  185.                 }
  186.                 elsif(($WW{"Votes".Regexit($tring)} > $WW{"MostVoted"}) && (Regexit($tring) !~ /$WW{"MostVotedName"}/)) {
  187.                     $WW{"MostVoted"} = $WW{"Votes".Regexit($tring)};
  188.                     $WW{"MostVotedName"} = Regexit($tring);
  189.                     $irc->yield(privmsg => "WolfBot" => "vote ".$tring) if((int(rand(100)) > 70) && ($tring !~ /$BotNick/i));
  190.                 }
  191.             }
  192.             elsif($UserMsg =~ /seconds to send your votes/i) {
  193.                 $WW{"MostVoted"}="";
  194.                 $WW{"MostVotedName"}="";
  195.                 if($WW{"Vote"} !~ /^$/) {
  196.                     my $alarm_id = $irc->delay( [ privmsg => "WolfBot" => "vote ".$WW{"Vote"} ], 5 );
  197.                 }
  198.                 elsif(int(rand(100)) > 85) {
  199.                     my $alarm_id = $irc->delay( [ privmsg => "WolfBot" => "vote ".$WWPlayers[int(rand(@WWPlayers))] ], 5 );
  200.                 }
  201.                 $WW{"Vote"} = "";
  202.                 if($WW{"MyType"} =~ /Village Idiot/i) {
  203.                     $WW{"Vote"} = $BotNick;
  204.                 }
  205.             }
  206.             if(($UserNick =~ /WolfBot/i) && ($Event =~ /(NOTICE|PRIVMSG|CHANMSG)/)) {
  207.                 if($UserMsg =~ /You are a wolf!/i) {
  208.                     $WW{"MyType"} = "Wolf";
  209.                     my $alarm_id = $irc->delay( [ privmsg => "#WWolf" => $WWPlayers[int(rand(@WWPlayers))]." is Wolf." ], 50 ) if($WW{"Roles"} =~ /Idiot/i);
  210.                 }
  211.                 elsif($UserMsg =~ /You are the finder!/i) {
  212.                     $WW{"MyType"} = "Finder";
  213.                 }
  214.                 elsif($UserMsg =~ /You are the seer!/i) {
  215.                     $WW{"MyType"} = "Seer";
  216.                 }
  217.                 elsif($UserMsg =~ /You are the doppleganger!/i) {
  218.                     $WW{"MyType"} = "Doppleganger";
  219.                 }
  220.                 elsif($UserMsg =~ /You are the angel!/i) {
  221.                     $WW{"MyType"} = "Angel";
  222.                 }
  223.                 elsif($UserMsg =~ /You are the Village Idiot!/i) {
  224.                     $WW{"MyType"} = "Village Idiot";
  225.                     my $alarm_id = $irc->delay( [ privmsg => "#WWolf" => $WWPlayers[int(rand(@WWPlayers))]." is Wolf." ], 50 );
  226.                     $WW{"Vote"} = $BotNick;
  227.                 }
  228.                 elsif($UserMsg =~ /into (a|an) (.*?)!/i) {
  229.                     $tring = $2;
  230.                     if($tring =~ /werewolf/i) {
  231.                         $WW{"MyType"} = "Wolf";
  232.                         my $alarm_id = $irc->delay( [ privmsg => "#WWolf" => $WWPlayers[int(rand(@WWPlayers))]." is Wolf." ], 50 ) if($WW{"Roles"} =~ /Idiot/i);
  233.                     }
  234.                     if($tring =~ /village idiot/i) {
  235.                         $WW{"MyType"} = "Village Idiot";
  236.                         my $alarm_id = $irc->delay( [ privmsg => "#WWolf" => $WWPlayers[int(rand(@WWPlayers))]." is Wolf." ], 50 );
  237.                         $WW{"Vote"} = $BotNick;
  238.                     }
  239.                     if($tring =~ /angel/i) { $WW{"MyType"} = "Angel"; }
  240.                     if($tring =~ /seer/i) { $WW{"MyType"} = "Seer"; }
  241.                     if($tring =~ /finder/i) { $WW{"MyType"} = "Finder"; }
  242.                     else {
  243.                         $WW{"MyType"} = $tring;
  244.                     }
  245.                 }
  246.                 elsif($UserMsg =~ /You have 45/i) {
  247.                     if($WW{"MyType"} =~ /Wolf/i) {
  248.                         if($WW{"Target"} =~ /^$/){
  249.                             $irc->yield(privmsg => "wolfbot" => "kill ".$WWPlayers[int(rand(@WWPlayers))]);
  250.                         }
  251.                         else {
  252.                             $irc->yield(privmsg => "wolfbot" => "shield ".$WW{"Target"});
  253.                             $WW{"Target"} = "";
  254.                         }
  255.                     }
  256.                     elsif($WW{"MyType"} =~ /Seer/i) {
  257.                         $WW{"Target"} = $WWPlayers[0];
  258.                         $WW{"Players"} =~ s/$WWPlayers[0] //igs;
  259.                         @WWPlayers = split / /, $WW{"Players"};
  260.                         $irc->yield(privmsg => "wolfbot" => "see ".$WW{"Target"});
  261.                         $WW{"Target"} = "";
  262.                     }
  263.                     elsif($WW{"MyType"} =~ /Finder/i) {
  264.                         $WW{"Target"} = $WWPlayers[0];
  265.                         $WW{"Players"} =~ s/$WWPlayers[0] //igs;
  266.                         @WWPlayers = split / /, $WW{"Players"};
  267.                         $irc->yield(privmsg => "wolfbot" => "find ".$WW{"Target"});
  268.                         $WW{"Target"} = "";
  269.                     }
  270.                     if($WW{"MyType"} =~ /Doppleganger/i) {
  271.                         $WW{"Target"} = $WWPlayers[int(rand(@WWPlayers))];
  272.                         $irc->yield(privmsg => "wolfbot" => "dopple ".$WW{"Target"});
  273.                         $WW{"Target"} = "";
  274.                     }
  275.                     if($WW{"MyType"} =~ /Angel/i) {
  276.                         if($WW{"Target"} =~ /^$/){
  277.                             $WW{"Target"} = $WWPlayers[int(rand(@WWPlayers))];
  278.                             $irc->yield(privmsg => "wolfbot" => "shield ".$WW{"Target"});
  279.                             $WW{"Target"} = "";
  280.                         }
  281.                         else {
  282.                             $irc->yield(privmsg => "wolfbot" => "shield ".$WW{"Target"});
  283.                         }
  284.                     }
  285.                 }
  286.                 elsif($UserMsg =~ /(.*?) is (a|an) (.*?)!/i) {
  287.                     $tring = $1;
  288.                     $tringt = $3;
  289.                     if($tringt =~ /Wolf/i) {
  290.                         my $alarm_id = $irc->delay( [ privmsg => "#WWolf" => $tring." is Wolf." ], 5 );
  291.                         $WW{"Vote"} = $tring;
  292.                     }
  293.                     elsif($tringt =~ /Idiot/i) {
  294.                         my $alarm_id = $irc->delay( [ privmsg => "#WWolf" => $tring." is Village idiot." ], 5 );
  295.                     }
  296.                     elsif($tringt =~ /villager/i) {
  297.                         my $alarm_id = $irc->delay( [ privmsg => "#WWolf" => $tring." is Villager." ], 5 );
  298.                     }
  299.                     elsif($tringt =~ /Angel/i) {
  300.                         my $alarm_id = $irc->delay( [ privmsg => $tring => "I'm seer, and you're angel, right? Protect me, I'll keep looking for the wolf." ], 2 );
  301.                     }
  302.                     elsif($tringt =~ /Doppleganger/i) {
  303.                         my $alarm_id = $irc->delay( [ privmsg => $tring => "Dopple me for seer!" ], 2 );
  304.                     }
  305.                 }
  306.                 elsif($UserMsg =~ /(.*?) targe(t*?)ed (.*?)!/i) {
  307.                     $tring = $1;
  308.                     $tringt = $3;
  309.                     my $alarm_id = $irc->delay( [ privmsg => "#WWolf" => $tring." targetted ".$tringt."." ], 10 );
  310.                     $WW{"Vote"} = $tring;
  311.                 }
  312.                 elsif($UserMsg =~ /The (wolves|other wolves) are: (.*)/i) {
  313.                     @WWolfs = split /, /, $1;
  314.                     print "Updating players...\n";
  315.                     foreach (@WWolfs) {
  316.                         $WW{"Players"} =~ s/$_ //gs;
  317.                         @WWPlayers = split / /, $WW{"Players"};
  318.                         print "Updating players...\n".@WWPlayers."\n";
  319.                     }
  320.                 }
  321.             }
  322.         }
  323.     } # Wolf autoplay
  324. }
  325. sub Regexit {
  326.     ($Reg = $_[0]) =~ s/\\/\\\\/gs;
  327.     $Reg =~ s/(\?|\(|\)|\||\[|\|\{|\}|\.)/\\$1/gs;
  328.     $Reg =~ s/\*/\(\.\*\)/gs;
  329.     return $Reg;
  330. }
  331. sub GetTime { # This is just for timestamps, just leave it.
  332.     my($Sec, $Min, $Hour, $Day, $Mon, $Year, $WDay, $YDay) = localtime;
  333.     my $APM = "AM";
  334.     if($Hour > 12) { $Hour -= 12; $APM = "PM"; }
  335.     if($Hour < 10) { $Hour = "0".$Hour; }
  336.     if($Min < 10) { $Min = "0".$Min; }
  337.     if($Sec < 10) { $Sec = "0".$Sec; }
  338.     return "[ $Hour:$Min:$Sec $APM ]    ";
  339. }
  340. # Caaz was here.
  341. $poe_kernel->run();
  342. exit 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement