Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- print "Werewolf autoplay by Caaz. (Version wat.)\n";
- use POE::Component::IRC;
- use POE;
- BOTVARS: {
- $BotNick = "IRWolf"; # Nick
- $BotUser = "C"; # Username "indent"
- $BotName = "WWolfAI"; # Real Name
- $BotPass = ""; # Nickserv Password
- }
- my ($irc) = POE::Component::IRC->spawn();
- POE::Session->create(inline_states => {
- _start => sub {
- $irc->yield(register => "all");
- $irc->yield( connect => {
- Nick => $BotNick,
- Username => $BotUser,
- Ircname => $BotName,
- Server => "irc.purplesurge.com",
- Port => "6667",
- Password => "",
- });
- },
- irc_001 => sub {
- $irc->yield(mode => $BotNick." +B");
- #$irc->yield(privmsg => "Nickserv" => "id ".$BotPass);
- my $alarm_id = $irc->delay( [ join => "#Powerplant,#WWolf" ], 2 );
- },
- irc_error => sub {
- my ($kernel, $IRCWhat) = @_[KERNEL, ARG0];
- print $IRCWhat."\n";
- },
- irc_ctcp_action => sub {
- my ($kernel, $IRCWho, $where, $IRCWhat) = @_[KERNEL, ARG0, ARG1, ARG2];
- $IRCWhere = $where->[0];
- print GetTime()."$IRCWhere > * ".(split /!/, $IRCWho)[0]." $IRCWhat\n";
- Bot("ACTION",(split /!/, $IRCWho)[0],(split /!/, $IRCWho)[1],$IRCWhere,$IRCWhat);
- },
- irc_join => sub {
- my ($kernel, $IRCWho, $IRCWhere) = @_[KERNEL, ARG0, ARG1];
- print GetTime()."Join * ".(split /!/, $IRCWho)[0]." joins $IRCWhere\n";
- Bot("JOIN",(split /!/, $IRCWho)[0],(split /!/, $IRCWho)[1],$IRCWhere);
- },
- irc_invite => sub {
- my ($kernel, $IRCWho, $IRCWhere) = @_[KERNEL, ARG0, ARG1];
- print GetTime()."Invi * ".(split /!/, $IRCWho)[0]." invites you to $IRCWhere\n";
- Bot("INVITE", (split /!/, $IRCWho)[0],(split /!/, $IRCWho)[1],$IRCWhere);
- },
- irc_kick => sub {
- my ($kernel, $IRCWho, $IRCWhere, $IRCWhoElse, $IRCWhat) = @_[KERNEL, ARG0, ARG1, ARG2, ARG3];
- print GetTime()."Kick * ".(split /!/, $IRCWho)[0]." kicks $IRCWhoElse out of $IRCWhere ($IRCWhat)\n";
- Bot("KICK",(split /!/, $IRCWho)[0],(split /!/, $IRCWho)[1],$IRCWhere,$IRCWhoElse,$IRCWhat);
- },
- irc_msg => sub {
- my ($kernel, $IRCWho, $where, $IRCWhat) = @_[KERNEL, ARG0, ARG1, ARG2];
- $IRCWhere = $where->[0];
- print GetTime()."Priv\a> <".(split /!/, $IRCWho)[0]."> $IRCWhat\n";
- Bot("PRIVMSG",(split /!/, $IRCWho)[0],(split /!/, $IRCWho)[1],$IRCWhere,$IRCWhat);
- },
- irc_nick => sub {
- my ($kernel, $IRCWho, $IRCWhoElse) = @_[KERNEL, ARG0, ARG1];
- print GetTime()."Nick * ".(split /!/, $IRCWho)[0]." changes nick to $IRCWhoElse\n";
- Bot("NICK", (split /!/, $IRCWho)[0],(split /!/, $IRCWho)[1],$IRCWhoElse);
- },
- irc_notice => sub {
- my ($kernel, $IRCWho, $where, $IRCWhat) = @_[KERNEL, ARG0, ARG1, ARG2];
- $IRCWhere = $where->[0];
- #print GetTime()."Noti <".(split /!/, $IRCWho)[0]."> $IRCWhat\n";
- Bot("NOTICE",(split /!/, $IRCWho)[0],(split /!/, $IRCWho)[1],$IRCWhere,$IRCWhat);
- },
- irc_part => sub {
- my ($kernel, $IRCWho, $IRCWhere, $IRCWhat) = @_[KERNEL, ARG0, ARG1, ARG2];
- print GetTime()."Part * ".(split /!/, $IRCWho)[0]." left channel $IRCWhere \(".$IRCWhat."\)\n";
- Bot("PART",(split /!/, $IRCWho)[0],(split /!/, $IRCWho)[1],$IRCWhere,$IRCWhat);
- },
- irc_public => sub {
- my ($kernel, $IRCWho, $where, $IRCWhat) = @_[KERNEL, ARG0, ARG1, ARG2];
- $IRCWhere = $where->[0];
- print GetTime()."$IRCWhere > <".(split /!/, $IRCWho)[0]."> $IRCWhat\n";
- Bot("CHANMSG",(split /!/, $IRCWho)[0],(split /!/, $IRCWho)[1],$IRCWhere,$IRCWhat);
- },
- irc_433 => sub {
- my ($kernel, $IRC0, $IRC1) = @_[KERNEL, ARG0, ARG1];
- print &TS()."Err ".$IRC1."\n";
- $irc->yield(nick => $Bot{"Nick"}.(int(rand(9000)+1000)));
- },
- irc_disconnected => sub { print "Disconnected.\n"; exit 1; }, # Ends on disconnect.
- },);
- sub Bot {
- $Event = $_[0];
- if($Event =~ /CHANMSG/) { $Com = "privmsg ".$_[3]." "; $UserMsg = $_[4]; $Where = $_[3]; }
- elsif($Event =~ /NOTICE/) { $Com = "notice ".$_[1]." "; $UserMsg = $_[4]; $Where = $_[1]; }
- elsif($Event =~ /PRIVMSG/) { $Com = "notice ".$_[1]." "; $UserMsg = $_[4]; $Where = $_[1]; }
- 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.
- elsif($Event =~ /JOIN/) { $Com = "notice ".$_[3]." "; $UserMsg = $_[3]; $Where = $_[1]; }
- $UserNick = Regexit($_[1]);
- $UserHost = $_[2];
- $UserMsg = POE::Component::IRC::Common::strip_formatting(POE::Component::IRC::Common::strip_color($UserMsg)); if(($Where =~ /wwolf/i) || ($UserNick =~ /Wolfbot/i)) {
- if($Event =~ /(CHANMSG|NOTICE|PRIVMSG)/) {
- $WW{"MyType"} = "Wolf" if($WW{"MyType"} =~ /werewolf/);
- if(($UserMsg =~ /^($BotNick|Bots), Join/i) && ($WW{"Will Join"} !~ /No/i)) {
- $irc->yield(privmsg => "#WWolf" => "!Join");
- $WW{"Will Join"} = "No";
- $WW{"MyType"} = "Villager";
- }
- elsif($UserMsg =~ /^$BotNick, Leave/i) {
- $irc->yield(part => "#WWolf" => "Invite me, and I will continue playing.");
- $WW{"Will Join"} = "Yes";
- while ( ($key, $value) = each %WW ) {
- $WW{$key} = "";
- }
- }
- elsif($UserMsg =~ /^$BotNick won,/i) {
- @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.");
- my $alarm_id = $irc->delay( [ privmsg => "#wwolf" => $rray[int(rand(@rray))] ], 1 );
- while ( ($key, $value) = each %WW ) {
- $WW{$key} = "";
- }
- }
- elsif($UserMsg =~ /^$BotNick lost,/i) {
- @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.");
- my $alarm_id = $irc->delay( [ privmsg => "#wwolf" => $rray[int(rand(@rray))] ], 1 );
- while ( ($key, $value) = each %WW ) {
- $WW{$key} = "";
- }
- }
- elsif($UserMsg =~ /^$BotNick.*?wolf/i) {
- @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...");
- $irc->yield(privmsg => "#wwolf" => $rray[int(rand(@rray))]) if(rand(100) > 50);
- $WW{"Vote"} = $UserNick;
- print $WW{"Vote"}."\n";
- $WW{"Target"} = $UserNick if($WW{"MyType"} =~ /Wolf/);
- }
- elsif($UserMsg =~ /(.*) is wolf/i) {
- $WW{"Vote"} = $1;
- print $WW{"Vote"}."\n";
- $WW{"Target"} = $UserNick if($WW{"MyType"} =~ /Seer|Finder|Doppleganger/i);
- }
- elsif($UserMsg =~ /^I.*? wolf/i) {
- $WW{"Vote"} = $UserNick;
- print $WW{"Vote"}."\n";
- $WW{"Target"} = $UserNick if($WW{"MyType"} =~ /Seer|Finder|Doppleganger/i);
- }
- elsif($UserMsg =~ /^The game is over\.$|^Game cancelled\./i) {
- while ( ($key, $value) = each %WW ) {
- $WW{$key} = "";
- }
- }
- elsif(($UserMsg =~ /I.*? (Seer|Finder|Angel)/i) && ($WW{"MyType"} =~ /Wolf/i)){
- $WW{"Target"} = $UserNick;
- }
- elsif($UserMsg =~ /I\'m seer, and you\'re angel, right\? Protect me, I\'ll keep looking for the wolf\./i) {
- $WW{"Target"} = $UserNick;
- }
- elsif($UserMsg =~ /^($BotNick|Bots), what are you/i) {
- if($WW{"MyType"} =~ /Wolf|Village Idiot/) {
- $irc->yield(privmsg => "#WWolf" => "I am a Villager.");
- }
- else {
- $irc->yield(privmsg => "#WWolf" => "I am a ".$WW{"MyType"}.".");
- }
- }
- elsif($UserMsg =~ /Active Roles: (.*)/i) {
- $WW{"Roles"} = $1;
- }
- elsif($UserMsg =~ /(.*?) (has joined|has started)/i) {
- if($1 =~ /$BotNick/) { return 0; }
- $WW{"Players"} = $WW{"Players"}.$1." ";
- @WWPlayers = split / /, $WW{"Players"};
- print "Updating players...\n".@WWPlayers."\n";
- }
- elsif($UserMsg =~ /^(.*) (has left the game|struggles vainly|was)/i) {
- $WW{"Players"} =~ s/$1 //igs;
- @WWPlayers = split / /, $WW{"Players"};
- if($WW{"Target"} =~ /$1/) { $WW{"Target"} = ""; }
- print "Updating players...\n".@WWPlayers."\n";
- }
- elsif($UserMsg =~ /has (cast|changed) their (.*?) for (.*?)!/i) {
- $tring = $3;
- $WW{"Votes".Regexit($tring)}++;
- if(($tring =~ /$UserNick/i) && ($WW{"Roles"} =~ /Idiot/i)) {
- $irc->yield(privmsg => "#WWolf" => "Obvious Idiot is obvious.") if((int(rand(100))) > 40);
- }
- elsif(($WW{"Votes".Regexit($tring)} > $WW{"MostVoted"}) && (Regexit($tring) !~ /$WW{"MostVotedName"}/)) {
- $WW{"MostVoted"} = $WW{"Votes".Regexit($tring)};
- $WW{"MostVotedName"} = Regexit($tring);
- $irc->yield(privmsg => "WolfBot" => "vote ".$tring) if((int(rand(100)) > 70) && ($tring !~ /$BotNick/i));
- }
- }
- elsif($UserMsg =~ /seconds to send your votes/i) {
- $WW{"MostVoted"}="";
- $WW{"MostVotedName"}="";
- if($WW{"Vote"} !~ /^$/) {
- my $alarm_id = $irc->delay( [ privmsg => "WolfBot" => "vote ".$WW{"Vote"} ], 5 );
- }
- elsif(int(rand(100)) > 85) {
- my $alarm_id = $irc->delay( [ privmsg => "WolfBot" => "vote ".$WWPlayers[int(rand(@WWPlayers))] ], 5 );
- }
- $WW{"Vote"} = "";
- if($WW{"MyType"} =~ /Village Idiot/i) {
- $WW{"Vote"} = $BotNick;
- }
- }
- if(($UserNick =~ /WolfBot/i) && ($Event =~ /(NOTICE|PRIVMSG|CHANMSG)/)) {
- if($UserMsg =~ /You are a wolf!/i) {
- $WW{"MyType"} = "Wolf";
- my $alarm_id = $irc->delay( [ privmsg => "#WWolf" => $WWPlayers[int(rand(@WWPlayers))]." is Wolf." ], 50 ) if($WW{"Roles"} =~ /Idiot/i);
- }
- elsif($UserMsg =~ /You are the finder!/i) {
- $WW{"MyType"} = "Finder";
- }
- elsif($UserMsg =~ /You are the seer!/i) {
- $WW{"MyType"} = "Seer";
- }
- elsif($UserMsg =~ /You are the doppleganger!/i) {
- $WW{"MyType"} = "Doppleganger";
- }
- elsif($UserMsg =~ /You are the angel!/i) {
- $WW{"MyType"} = "Angel";
- }
- elsif($UserMsg =~ /You are the Village Idiot!/i) {
- $WW{"MyType"} = "Village Idiot";
- my $alarm_id = $irc->delay( [ privmsg => "#WWolf" => $WWPlayers[int(rand(@WWPlayers))]." is Wolf." ], 50 );
- $WW{"Vote"} = $BotNick;
- }
- elsif($UserMsg =~ /into (a|an) (.*?)!/i) {
- $tring = $2;
- if($tring =~ /werewolf/i) {
- $WW{"MyType"} = "Wolf";
- my $alarm_id = $irc->delay( [ privmsg => "#WWolf" => $WWPlayers[int(rand(@WWPlayers))]." is Wolf." ], 50 ) if($WW{"Roles"} =~ /Idiot/i);
- }
- if($tring =~ /village idiot/i) {
- $WW{"MyType"} = "Village Idiot";
- my $alarm_id = $irc->delay( [ privmsg => "#WWolf" => $WWPlayers[int(rand(@WWPlayers))]." is Wolf." ], 50 );
- $WW{"Vote"} = $BotNick;
- }
- if($tring =~ /angel/i) { $WW{"MyType"} = "Angel"; }
- if($tring =~ /seer/i) { $WW{"MyType"} = "Seer"; }
- if($tring =~ /finder/i) { $WW{"MyType"} = "Finder"; }
- else {
- $WW{"MyType"} = $tring;
- }
- }
- elsif($UserMsg =~ /You have 45/i) {
- if($WW{"MyType"} =~ /Wolf/i) {
- if($WW{"Target"} =~ /^$/){
- $irc->yield(privmsg => "wolfbot" => "kill ".$WWPlayers[int(rand(@WWPlayers))]);
- }
- else {
- $irc->yield(privmsg => "wolfbot" => "shield ".$WW{"Target"});
- $WW{"Target"} = "";
- }
- }
- elsif($WW{"MyType"} =~ /Seer/i) {
- $WW{"Target"} = $WWPlayers[0];
- $WW{"Players"} =~ s/$WWPlayers[0] //igs;
- @WWPlayers = split / /, $WW{"Players"};
- $irc->yield(privmsg => "wolfbot" => "see ".$WW{"Target"});
- $WW{"Target"} = "";
- }
- elsif($WW{"MyType"} =~ /Finder/i) {
- $WW{"Target"} = $WWPlayers[0];
- $WW{"Players"} =~ s/$WWPlayers[0] //igs;
- @WWPlayers = split / /, $WW{"Players"};
- $irc->yield(privmsg => "wolfbot" => "find ".$WW{"Target"});
- $WW{"Target"} = "";
- }
- if($WW{"MyType"} =~ /Doppleganger/i) {
- $WW{"Target"} = $WWPlayers[int(rand(@WWPlayers))];
- $irc->yield(privmsg => "wolfbot" => "dopple ".$WW{"Target"});
- $WW{"Target"} = "";
- }
- if($WW{"MyType"} =~ /Angel/i) {
- if($WW{"Target"} =~ /^$/){
- $WW{"Target"} = $WWPlayers[int(rand(@WWPlayers))];
- $irc->yield(privmsg => "wolfbot" => "shield ".$WW{"Target"});
- $WW{"Target"} = "";
- }
- else {
- $irc->yield(privmsg => "wolfbot" => "shield ".$WW{"Target"});
- }
- }
- }
- elsif($UserMsg =~ /(.*?) is (a|an) (.*?)!/i) {
- $tring = $1;
- $tringt = $3;
- if($tringt =~ /Wolf/i) {
- my $alarm_id = $irc->delay( [ privmsg => "#WWolf" => $tring." is Wolf." ], 5 );
- $WW{"Vote"} = $tring;
- }
- elsif($tringt =~ /Idiot/i) {
- my $alarm_id = $irc->delay( [ privmsg => "#WWolf" => $tring." is Village idiot." ], 5 );
- }
- elsif($tringt =~ /villager/i) {
- my $alarm_id = $irc->delay( [ privmsg => "#WWolf" => $tring." is Villager." ], 5 );
- }
- elsif($tringt =~ /Angel/i) {
- 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 );
- }
- elsif($tringt =~ /Doppleganger/i) {
- my $alarm_id = $irc->delay( [ privmsg => $tring => "Dopple me for seer!" ], 2 );
- }
- }
- elsif($UserMsg =~ /(.*?) targe(t*?)ed (.*?)!/i) {
- $tring = $1;
- $tringt = $3;
- my $alarm_id = $irc->delay( [ privmsg => "#WWolf" => $tring." targetted ".$tringt."." ], 10 );
- $WW{"Vote"} = $tring;
- }
- elsif($UserMsg =~ /The (wolves|other wolves) are: (.*)/i) {
- @WWolfs = split /, /, $1;
- print "Updating players...\n";
- foreach (@WWolfs) {
- $WW{"Players"} =~ s/$_ //gs;
- @WWPlayers = split / /, $WW{"Players"};
- print "Updating players...\n".@WWPlayers."\n";
- }
- }
- }
- }
- } # Wolf autoplay
- }
- sub Regexit {
- ($Reg = $_[0]) =~ s/\\/\\\\/gs;
- $Reg =~ s/(\?|\(|\)|\||\[|\|\{|\}|\.)/\\$1/gs;
- $Reg =~ s/\*/\(\.\*\)/gs;
- return $Reg;
- }
- sub GetTime { # This is just for timestamps, just leave it.
- my($Sec, $Min, $Hour, $Day, $Mon, $Year, $WDay, $YDay) = localtime;
- my $APM = "AM";
- if($Hour > 12) { $Hour -= 12; $APM = "PM"; }
- if($Hour < 10) { $Hour = "0".$Hour; }
- if($Min < 10) { $Min = "0".$Min; }
- if($Sec < 10) { $Sec = "0".$Sec; }
- return "[ $Hour:$Min:$Sec $APM ] ";
- }
- # Caaz was here.
- $poe_kernel->run();
- exit 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement