daily pastebin goal
3%
SHARE
TWEET

Untitled

a guest Jun 5th, 2017 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ## ~-Variables-~ ##
  2. $BotNick = "PerlBot-".(int(rand(10000)));       # Nick
  3. $BotUser = ".";     # Username "indent"
  4. $BotName = "a Perl bot.";   # Real Name
  5. $BotPass = "Password";      # Nickserv Password
  6. $BotOwner = "Caaz";     # Owner of the Bot
  7. $BotPath = "/Users/Caaz/Desktop/Perl/BOT/";     # Path to any files.
  8. $BotVersion = "\[ Perl module : POE::Component::IRC \] ".POE::Component::IRC::Common::MAGENTA."\[ Luka 4.0.0 \]"; # Skeleton.Commands.Wwolf
  9.  
  10. $Server = "irc.purplesurge.com";
  11. $Port = "6667";
  12. ## ~-EndVariables-~ ##
  13.  
  14. ## ~-Commands-~ ##
  15. if(($UserMsg =~ /^!End$/i) && ($UserNick =~ /^$BotOwner$/i)) {
  16.     $irc->yield(quit => "");
  17. }
  18. elsif($_[4] =~ /^!Do (.*)/i) {
  19.     @rray = split / > /, $1;
  20.     if($UserNick =~ /^$BotOwner$/i) {
  21.         $irc->yield(@rray);
  22.     }
  23. }
  24. elsif($_[4] =~ /^!Var \$(.*)/i) {
  25.     $tring = $1;
  26.     if($UserNick =~ /^$BotOwner$/i) {
  27.         Command($Com.${$tring}) if(${$tring} !~ /$BotPass/);
  28.     }
  29. }
  30. elsif($_[4] =~ /^!SetVar \$(.*?) (.*)/i) {
  31.     $tring = $1;
  32.     $tringt = $2;
  33.     if($UserNick =~ /^$BotOwner$/i) {
  34.         ${$tring} = $tringt;
  35.         Command($Com.${$tring});
  36.     }
  37. }
  38. elsif($UserMsg =~ /^!Nick (.*)/i) {
  39.     $tring = $1;
  40.     if($UserNick =~ /^$BotOwner$/i) {
  41.         $BotNick = $tring;
  42.         $irc->yield(nick => $tring);
  43.     }
  44. }
  45. elsif($UserMsg =~ /^!Amsg (.*)/i) {
  46.     $tring = $1;
  47.     open DATA, "<".$BotPath.$Server."-AutoJoin.txt";
  48.     @Channels=<DATA>;
  49.     close DATA;chomp(@Channels);
  50.     $BotChannels = $Channels[0];
  51.     $irc->yield(join => $BotChannels);
  52.     if($UserNick =~ /^$BotOwner$/i) {
  53.         Command("privmsg ".$BotChannels." ".$tring);
  54.     }
  55. }
  56. elsif($UserMsg =~ /^!AJ$/i) {
  57.     open DATA, "<".$BotPath.$Server."-AutoJoin.txt";
  58.     @Channels=<DATA>;
  59.     close DATA;
  60.     if($Channels[0] !~ /$Where,/i) {
  61.         open DATA, ">>".$BotPath.$Server."-AutoJoin.txt"; print DATA "$Where,"; close DATA;
  62.         Command($Com."Channel added to AutoJoin.");
  63.     }
  64.     else {
  65.         Command($Com."Channel already in AutoJoin.");
  66.     }
  67. }
  68. ## ~-EndCommands-~ ##
  69.  
  70. ## ~-Modules-~ ##
  71. use lib '/Users/Caaz/lib';
  72. use POE::Component::IRC;
  73. use POE;
  74. ## ~-EndModules-~ ##
  75.  
  76. ## ~-SubRoutines-~ ##
  77. sub SpamProtect {
  78.     my($Sec, $Min, $Hour, $Day, $mon, $year, $WDay, $YDay) = localtime;
  79.     return (((($YDay * 24) * 60) * 60) + (($Hour * 60) * 60) + ($Min * 60) + $Sec);
  80. }
  81. sub GetTime { # This is just for timestamps, just leave it.
  82.     my($Sec, $Min, $Hour, $Day, $Mon, $Year, $WDay, $YDay) = localtime;
  83.     my $APM = "AM";
  84.     if($Hour > 12) { $Hour -= 12; $APM = "PM"; }
  85.     if($Hour < 10) { $Hour = "0".$Hour; }
  86.     if($Min < 10) { $Min = "0".$Min; }
  87.     if($Sec < 10) { $Sec = "0".$Sec; }
  88.     return "[ $Hour:$Min:$Sec $APM ]    ";
  89. }
  90. ## ~-EndSubRoutines-~ ##
  91.  
  92. ## ~-Files-~ ##
  93. open DATA, "<".$BotPath.$Server."-AutoJoin.txt";
  94. @Channels=<DATA>;
  95. close DATA;chomp(@Channels);
  96. $BotChannels = $Channels[0];
  97. ## ~-EndFiles-~ ##
  98.  
  99. ## ~-Events-~ ##
  100. if($Event =~ /CHANMSG/) { $Com = "privmsg ".$_[3]." "; $UserMsg = $_[4]; $Where = $_[3]; }
  101. elsif($Event =~ /NOTICE/) { $Com = "notice ".$_[1]." "; $UserMsg = $_[4]; $Where = $_[1]; }
  102. elsif($Event =~ /PRIVMSG/) { $Com = "notice ".$_[1]." "; $UserMsg = $_[4]; $Where = $_[1]; }
  103. 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.
  104. elsif($Event =~ /JOIN/) { $Com = "notice ".$_[3]." "; $UserMsg = $_[3]; $Where = $_[1]; }
  105. elsif($Event =~ /NICK/) { if($_[1] =~ /^$BotOwner$/i) { print "Owner changing...\n"; $BotOwner = Nickit($_[3]) } }
  106. ## ~-EndEvents-~ ##
  107.  
  108. ## ~-UserStuff-~ ##
  109. $UserNick = Nickit($_[1]);
  110. $UserHost = $_[2];
  111. $UserMsg = POE::Component::IRC::Common::strip_formatting(POE::Component::IRC::Common::strip_color($UserMsg));
  112. ## ~-EndUserStuff-~ ##
  113.  
  114. ## ~-Fonts-~ ##
  115. elsif($BotNick =~ /(Rin|Len)/i) { $BotFont = "☯"; $irc->yield($ComA => $ComB => POE::Component::IRC::Common::ORANGE.(join " ", @PrivmsgB)." ☯"); }
  116. ## ~-EndFonts-~##
  117.  
  118. ## ~-Other-~ ##
  119. $CurSec = SpamProtect();
  120. ## ~-EndOther-~##
  121.  
  122.  
  123. ## ~-Wolf-~ ##
  124. if(($Where =~ /wwolf/i) || ($UserNick =~ /Wolfbot/i)) {
  125.     if($Event =~ /(CHANMSG|NOTICE|PRIVMSG)/) {
  126.         $WW{"MyType"} = "Wolf" if($WW{"MyType"} =~ /werewolf/);
  127.         if(($UserMsg =~ /^($BotNick|Bots), Join/i) && ($WW{"Will Join"} !~ /No/i)) {
  128.             $irc->yield(privmsg => "#WWolf" => "!Join");
  129.             $WW{"Will Join"} = "No";
  130.             $WW{"MyType"} = "Villager";
  131.         }
  132.         elsif($UserMsg =~ /^$BotNick, Leave/i) {
  133.             $irc->yield(part => "#WWolf" => "Invite me, and I will continue playing.");
  134.             $WW{"Will Join"} = "Yes";
  135.             while ( ($key, $value) = each %WW ) {
  136.                 $WW{$key} = "";
  137.             }
  138.         }
  139.         elsif($UserMsg =~ /^$BotNick won,/i) {
  140.             my $alarm_id = $irc->delay( [ privmsg => "#wwolf" => "Woohoo! I won. :D" ], 1 );
  141.             while ( ($key, $value) = each %WW ) {
  142.                 $WW{$key} = "";
  143.             }
  144.         }
  145.         elsif($UserMsg =~ /^$BotNick lost,/i) {
  146.             my $alarm_id = $irc->delay( [ privmsg => "#wwolf" => ";~; I didn't think I'd lose..." ], 1 );
  147.             while ( ($key, $value) = each %WW ) {
  148.                 $WW{$key} = "";
  149.             }
  150.         }
  151.         elsif($UserMsg =~ /^$BotNick.*?wolf/i) {
  152.             @rray = ($UserNick." is lying.", $UserNick." only wants to make me lose ;~;", "Not uh.", "Jeez, blaming me already...");
  153.             $irc->yield(privmsg => "#wwolf" => $rray[int(rand(@rray))]) if(rand(100) > 50);
  154.             $WW{"Vote"} = $UserNick;
  155.         }
  156.         elsif($UserMsg =~ /^The game is over\.$|^Game cancelled\./i) {
  157.             while ( ($key, $value) = each %WW ) {
  158.                 $WW{$key} = "";
  159.             }
  160.         }
  161.         elsif($UserMsg =~ /^($BotNick|Bots), what are you/i) {
  162.             if($WW{"MyType"} =~ /Wolf|Village Idiot/) {
  163.                 $irc->yield(privmsg => "#WWolf" => "I am a Villager.");
  164.             }
  165.             else {
  166.                 $irc->yield(privmsg => "#WWolf" => "I am a ".$WW{"MyType"}.".");
  167.             }
  168.         }
  169.         elsif($UserMsg =~ /Active Roles: (.*)/i) {
  170.             $WW{"Roles"} = $1;
  171.         }
  172.         elsif($UserMsg =~ /(.*?) (has joined|has started)/i) {
  173.             if($1 =~ /$BotNick/) { return 0; }
  174.             $WW{"Players"} = $WW{"Players"}.$1." ";
  175.             @WWPlayers = split / /, $WW{"Players"};
  176.             print "Updating players...\n".@WWPlayers."\n";
  177.         }
  178.         elsif($UserMsg =~ /^(.*) (has left the game|struggles vainly|was)/i) {
  179.             $WW{"Players"} =~ s/$1 //igs;
  180.             @WWPlayers = split / /, $WW{"Players"};
  181.             print "Updating players...\n".@WWPlayers."\n";
  182.         }
  183.         elsif($UserMsg =~ /has cast their vote for (.*?)!/i) {
  184.             $tring = $1;
  185.             $WW{"Votes".Regexit($tring)}++;
  186.             if(($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.                     $irc->yield(privmsg => "wolfbot" => "kill ".$WWPlayers[int(rand(@WWPlayers))]);
  249.                 }
  250.                 elsif($WW{"MyType"} =~ /Seer/i) {
  251.                     $WW{"Target"} = $WWPlayers[0];
  252.                     $WW{"Players"} =~ s/$WWPlayers[0] //igs;
  253.                     @WWPlayers = split / /, $WW{"Players"};
  254.                     $irc->yield(privmsg => "wolfbot" => "see ".$WW{"Target"});
  255.                 }
  256.                 elsif($WW{"MyType"} =~ /Finder/i) {
  257.                     $WW{"Target"} = $WWPlayers[0];
  258.                     $WW{"Players"} =~ s/$WWPlayers[0] //igs;
  259.                     @WWPlayers = split / /, $WW{"Players"};
  260.                     $irc->yield(privmsg => "wolfbot" => "find ".$WW{"Target"});
  261.                 }
  262.                 if($WW{"MyType"} =~ /Doppleganger/i) {
  263.                     $WW{"Target"} = $WWPlayers[int(rand(@WWPlayers))];
  264.                     $irc->yield(privmsg => "wolfbot" => "dopple ".$WW{"Target"});
  265.                 }
  266.                 if($WW{"MyType"} =~ /Angel/i) {
  267.                     $WW{"Target"} = $WWPlayers[int(rand(@WWPlayers))];
  268.                     $irc->yield(privmsg => "wolfbot" => "shield ".$WW{"Target"});
  269.                 }
  270.             }
  271.             elsif($UserMsg =~ /(.*?) is (a|an) (.*?)!/i) {
  272.                 $tring = $1;
  273.                 $tringt = $3;
  274.                 if($tringt =~ /Wolf/i) {
  275.                     my $alarm_id = $irc->delay( [ privmsg => "#WWolf" => $tring." is Wolf." ], 5 );
  276.                     $WW{"Vote"} = $tring;
  277.                 }
  278.                 elsif($tringt =~ /Idiot/i) {
  279.                     my $alarm_id = $irc->delay( [ privmsg => "#WWolf" => $tring." is Village idiot." ], 5 );
  280.                 }
  281.                 elsif($tringt =~ /villager/i) {
  282.                     my $alarm_id = $irc->delay( [ privmsg => "#WWolf" => $tring." is Villager." ], 5 );
  283.                 }
  284.                 elsif($tringt =~ /Angel/i) {
  285.                     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 );
  286.                 }
  287.                 elsif($tringt =~ /Doppleganger/i) {
  288.                     my $alarm_id = $irc->delay( [ privmsg => $tring => "Dopple me for seer!" ], 2 );
  289.                 }
  290.             }
  291.             elsif($UserMsg =~ /(.*?) targe(t*?)ed (.*?)!/i) {
  292.                 $tring = $1;
  293.                 $tringt = $3;
  294.                 my $alarm_id = $irc->delay( [ privmsg => "#WWolf" => $tring." targetted ".$tringt."." ], 10 );
  295.                 $WW{"Vote"} = $tring;
  296.             }
  297.             elsif($UserMsg =~ /The (wolves|other wolves) are: (.*)/i) {
  298.                 @WWolfs = split /, /, $1;
  299.                 print "Updating players...\n";
  300.                 foreach (@WWolfs) {
  301.                     $WW{"Players"} =~ s/$_ //gs;
  302.                     @WWPlayers = split / /, $WW{"Players"};
  303.                     print "Updating players...\n".@WWPlayers."\n";
  304.                 }
  305.             }
  306.         }
  307.     }
  308. }
  309. ## ~-Wolf-~ ##
  310.  
  311.  
  312.  
  313.  
  314. ## ~-Hooks-~ ##
  315. _start     => sub {
  316.     $irc->yield(register => "all");
  317.     $irc->yield( connect => {
  318.         Nick     => (split / /, $Connect)[2],
  319.         Username => $BotUser,
  320.         Ircname  => $BotName,
  321.         Server   => $Server,
  322.         Port     => $Port,
  323.     });
  324. },
  325. irc_001 => sub {
  326.     $irc->yield(mode => $BotNick." +B");
  327.     $irc->yield(privmsg => "Nickserv" => "id ".$BotPass);
  328.     my $alarm_id = $irc->delay( [ join => $BotChannels ], 2 );
  329. },
  330. irc_error => sub {
  331.     my ($kernel, $IRCWhat) = @_[KERNEL, ARG0];
  332.     print $IRCWhat."\n";
  333. },
  334. irc_ctcp_action => sub {
  335.     my ($kernel, $IRCWho, $where, $IRCWhat) = @_[KERNEL, ARG0, ARG1, ARG2];
  336.     $IRCWhere = $where->[0];
  337.     print GetTime()."$IRCWhere >    * ".(split /!/, $IRCWho)[0]." $IRCWhat\n";
  338.     Bot("ACTION",(split /!/, $IRCWho)[0],(split /!/, $IRCWho)[1],$IRCWhere,$IRCWhat);
  339. },
  340. irc_ctcp_version => sub {
  341.     my ($kernel, $IRCWho, $where, $IRCWhat) = @_[KERNEL, ARG0, ARG1, ARG2];
  342.     $IRCWhere = $where->[0];
  343.     print GetTime()."CTCP > * Got CTCP VERSION from ".(split /!/, $IRCWho)[0]."\n";
  344.     $irc->yield(ctcpreply => (split /!/, $IRCWho)[0] => $BotVersion);
  345. },
  346. irc_join => sub {
  347.     my ($kernel, $IRCWho, $IRCWhere) = @_[KERNEL, ARG0, ARG1];
  348.     print GetTime()."Join       * ".(split /!/, $IRCWho)[0]." joins $IRCWhere\n";
  349.     Bot("JOIN",(split /!/, $IRCWho)[0],(split /!/, $IRCWho)[1],$IRCWhere);
  350. },
  351. irc_invite => sub {
  352.     my ($kernel, $IRCWho, $IRCWhere) = @_[KERNEL, ARG0, ARG1];
  353.     print GetTime()."Invi       * ".(split /!/, $IRCWho)[0]." invites you to $IRCWhere\n";
  354.     Bot("INVITE", (split /!/, $IRCWho)[0],(split /!/, $IRCWho)[1],$IRCWhere);
  355. },
  356. irc_kick => sub {
  357.     my ($kernel, $IRCWho, $IRCWhere, $IRCWhoElse, $IRCWhat) = @_[KERNEL, ARG0, ARG1, ARG2, ARG3];
  358.     print GetTime()."Kick       * ".(split /!/, $IRCWho)[0]." kicks $IRCWhoElse out of $IRCWhere ($IRCWhat)\n";
  359.     Bot("KICK",(split /!/, $IRCWho)[0],(split /!/, $IRCWho)[1],$IRCWhere,$IRCWhoElse,$IRCWhat);
  360. },
  361. irc_msg => sub {
  362.     my ($kernel, $IRCWho, $where, $IRCWhat) = @_[KERNEL, ARG0, ARG1, ARG2];
  363.     $IRCWhere = $where->[0];
  364.     print GetTime()."Priv\a>        <".(split /!/, $IRCWho)[0].">   $IRCWhat\n";
  365.     Bot("PRIVMSG",(split /!/, $IRCWho)[0],(split /!/, $IRCWho)[1],$IRCWhere,$IRCWhat);
  366. },
  367. irc_nick => sub {
  368.     my ($kernel, $IRCWho, $IRCWhoElse) = @_[KERNEL, ARG0, ARG1];
  369.     print GetTime()."Nick       * ".(split /!/, $IRCWho)[0]." changes nick to $IRCWhoElse\n";
  370.     Bot("NICK", (split /!/, $IRCWho)[0],(split /!/, $IRCWho)[1],$IRCWhoElse);
  371. },
  372. irc_notice => sub {
  373.     my ($kernel, $IRCWho, $where, $IRCWhat) = @_[KERNEL, ARG0, ARG1, ARG2];
  374.     $IRCWhere = $where->[0];
  375.     print GetTime()."Noti       <".(split /!/, $IRCWho)[0].">   $IRCWhat\n" if((split /!/, $IRCWho)[0] !~ /WolfBot/i);
  376.     Bot("NOTICE",(split /!/, $IRCWho)[0],(split /!/, $IRCWho)[1],$IRCWhere,$IRCWhat);
  377. },
  378. irc_part => sub {
  379.     my ($kernel, $IRCWho, $IRCWhere, $IRCWhat) = @_[KERNEL, ARG0, ARG1, ARG2];
  380.     print GetTime()."Part       * ".(split /!/, $IRCWho)[0]." left channel $IRCWhere \(".$IRCWhat."\)\n";
  381.     Bot("PART",(split /!/, $IRCWho)[0],(split /!/, $IRCWho)[1],$IRCWhere,$IRCWhat);
  382. },
  383. irc_public => sub {
  384.     my ($kernel, $IRCWho, $where, $IRCWhat) = @_[KERNEL, ARG0, ARG1, ARG2];
  385.     $IRCWhere = $where->[0];
  386.     print GetTime()."$IRCWhere >    <".(split /!/, $IRCWho)[0].">   $IRCWhat\n";
  387.     Bot("CHANMSG",(split /!/, $IRCWho)[0],(split /!/, $IRCWho)[1],$IRCWhere,$IRCWhat);
  388. },
  389. irc_disconnected => sub { print "Disconnected.\n"; exit 1; }, # Ends on disconnect.
  390. ## ~-EndHooks-~ ##
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top