Advertisement
Guest User

Untitled

a guest
Jun 5th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 25.88 KB | None | 0 0
  1. #!/usr/bin/perl
  2. print "POE IRC Bot. Skeleton by Caaz.\n";
  3. print "SERVER \(Optional PORT NICK\)\n";
  4. chomp($Connect = <STDIN>);
  5.  
  6. use POE::Component::IRC;
  7. use POE;
  8.  
  9. BOTVARS: {
  10.     $BotNick = "DuskBot";               # Nick
  11.     $BotUser = "Dusk";              # Username "indent"
  12.     $BotName = "DuskBot 2.0";           # Real Name
  13.     $CmdPrefix = "!";               # Command Prefix
  14.     $BotPass = "Password";          # Nickserv Password
  15.     $BotOwner = "Solareon";             # Owner of the Bot
  16.     $BotPath = "/home/solareon/Desktop/DuskBot";    # Path to any files.
  17.     $BotVersion = "DuskBot 2.0 (Perl)";
  18. }
  19. FILES: {
  20.     open DATA, "<".$BotPath."DBUsers.txt";
  21.     @DB = <DATA>;
  22.     chomp($DBUsers = $DB[0]);
  23.     close DATA;
  24. }
  25. open DATA, "<".$BotPath.(split / /, $Connect)[0]."-AutoJoin.txt";
  26. @Channels=<DATA>;
  27. close DATA;chomp(@Channels);
  28. $BotChannels = $Channels[0];
  29. $Connect = $Connect." ".$BotNick;
  30. $BotNick = (split / /, $Connect)[2];
  31. my ($irc) = POE::Component::IRC->spawn();
  32. POE::Session->create(inline_states => {
  33.     _start     => sub {
  34.         $irc->yield(register => "all");
  35.         $irc->yield( connect => {
  36.             Nick     => (split / /, $Connect)[2],
  37.             Username => $BotUser,
  38.             Ircname  => $BotName,
  39.             Server   => (split / /, $Connect)[0],
  40.             Port     => (split / /, $Connect)[1],
  41.         });
  42.     },
  43.     irc_001 => sub {
  44.         $TDstat = "OFF";
  45.         $DefCon = "5";
  46.         $GTNstat = "OFF";
  47.         $irc->yield(mode => $BotNick." +B");
  48.         $irc->yield(privmsg => "Nickserv" => "id ".$BotPass);
  49.         my $alarm_id = $irc->delay( [ join => $BotChannels ], 2 );
  50.     },
  51.     irc_error => sub {
  52.         my ($kernel, $IRCWhat) = @_[KERNEL, ARG0];
  53.         print $IRCWhat."\n";
  54.     },
  55.     irc_ctcp_action => sub {
  56.         my ($kernel, $IRCWho, $where, $IRCWhat) = @_[KERNEL, ARG0, ARG1, ARG2];
  57.         $IRCWhere = $where->[0];
  58.         print GetTime()."$IRCWhere >    * ".(split /!/, $IRCWho)[0]." $IRCWhat\n";
  59.         Bot("ACTION",(split /!/, $IRCWho)[0],(split /!/, $IRCWho)[1],$IRCWhere,$IRCWhat);
  60.     },
  61.     irc_ctcp_version => sub {
  62.         my ($kernel, $IRCWho, $where, $IRCWhat) = @_[KERNEL, ARG0, ARG1, ARG2];
  63.         $IRCWhere = $where->[0];
  64.         print GetTime()."CTCP > * Got CTCP VERSION from ".(split /!/, $IRCWho)[0]."\n";
  65.         $irc->yield(ctcpreply => (split /!/, $IRCWho)[0] => $BotVersion);
  66.     },
  67.     irc_join => sub {
  68.         my ($kernel, $IRCWho, $IRCWhere) = @_[KERNEL, ARG0, ARG1];
  69.         print GetTime()."Join       * ".(split /!/, $IRCWho)[0]." joins $IRCWhere\n";
  70.         Bot("JOIN",(split /!/, $IRCWho)[0],(split /!/, $IRCWho)[1],$IRCWhere);
  71.     },
  72.     irc_invite => sub {
  73.         my ($kernel, $IRCWho, $IRCWhere) = @_[KERNEL, ARG0, ARG1];
  74.         print GetTime()."Invi       * ".(split /!/, $IRCWho)[0]." invites you to $IRCWhere\n";
  75.         Bot("INVITE", (split /!/, $IRCWho)[0],(split /!/, $IRCWho)[1],$IRCWhere);
  76.     },
  77.     irc_kick => sub {
  78.         my ($kernel, $IRCWho, $IRCWhere, $IRCWhoElse, $IRCWhat) = @_[KERNEL, ARG0, ARG1, ARG2, ARG3];
  79.         print GetTime()."Kick       * ".(split /!/, $IRCWho)[0]." kicks $IRCWhoElse out of $IRCWhere ($IRCWhat)\n";
  80.         Bot("KICK",(split /!/, $IRCWho)[0],(split /!/, $IRCWho)[1],$IRCWhere,$IRCWhoElse,$IRCWhat);
  81.     },
  82.     irc_msg => sub {
  83.         my ($kernel, $IRCWho, $where, $IRCWhat) = @_[KERNEL, ARG0, ARG1, ARG2];
  84.         $IRCWhere = $where->[0];
  85.         print GetTime()."Priv\a>        <".(split /!/, $IRCWho)[0].">   $IRCWhat\n";
  86.         Bot("PRIVMSG",(split /!/, $IRCWho)[0],(split /!/, $IRCWho)[1],$IRCWhere,$IRCWhat);
  87.     },
  88.     irc_nick => sub {
  89.         my ($kernel, $IRCWho, $IRCWhoElse) = @_[KERNEL, ARG0, ARG1];
  90.         print GetTime()."Nick       * ".(split /!/, $IRCWho)[0]." changes nick to $IRCWhoElse\n";
  91.         Bot("NICK", (split /!/, $IRCWho)[0],(split /!/, $IRCWho)[1],$IRCWhoElse);
  92.     },
  93.     irc_notice => sub {
  94.         my ($kernel, $IRCWho, $where, $IRCWhat) = @_[KERNEL, ARG0, ARG1, ARG2];
  95.         $IRCWhere = $where->[0];
  96.         print GetTime()."Noti       <".(split /!/, $IRCWho)[0].">   $IRCWhat\n" if((split /!/, $IRCWho)[0] !~ /WolfBot/i);
  97.         Bot("NOTICE",(split /!/, $IRCWho)[0],(split /!/, $IRCWho)[1],$IRCWhere,$IRCWhat);
  98.     },
  99.     irc_part => sub {
  100.         my ($kernel, $IRCWho, $IRCWhere, $IRCWhat) = @_[KERNEL, ARG0, ARG1, ARG2];
  101.         print GetTime()."Part       * ".(split /!/, $IRCWho)[0]." left channel $IRCWhere \(".$IRCWhat."\)\n";
  102.         Bot("PART",(split /!/, $IRCWho)[0],(split /!/, $IRCWho)[1],$IRCWhere,$IRCWhat);
  103.     },
  104.     irc_public => sub {
  105.         my ($kernel, $IRCWho, $where, $IRCWhat) = @_[KERNEL, ARG0, ARG1, ARG2];
  106.         $IRCWhere = $where->[0];
  107.         print GetTime()."$IRCWhere >    <".(split /!/, $IRCWho)[0].">   $IRCWhat\n";
  108.         Bot("CHANMSG",(split /!/, $IRCWho)[0],(split /!/, $IRCWho)[1],$IRCWhere,$IRCWhat);
  109.     },
  110.     irc_disconnected => sub { print "Disconnected.\n"; exit 1; }, # Ends on disconnect.
  111. },);
  112.  
  113.  
  114.  
  115. sub Bot {
  116.     $Event = $_[0];
  117.     if($Event =~ /CHANMSG/) { $Com = "privmsg ".$_[3]." "; $UserMsg = $_[4]; $Where = $_[3]; }
  118.     elsif($Event =~ /NOTICE/) { $Com = "notice ".$_[1]." "; $UserMsg = $_[4]; $Where = $_[1]; }
  119.     elsif($Event =~ /PRIVMSG/) { $Com = "notice ".$_[1]." "; $UserMsg = $_[4]; $Where = $_[1]; }
  120.     elsif($Event =~ /INVITE/) { $Com = "notice ".$_[1]." "; $UserMsg = $_[3]; $Where = $_[1]; if ($UserMsg !~ /sex/i) { $irc->yield(join => $UserMsg); } }
  121.     elsif($Event =~ /JOIN/) { $Com = "notice ".$_[3]." "; $UserMsg = $_[3]; $Where = $_[1]; }
  122.     elsif($Event =~ /NICK/) { if($_[1] =~ /^$BotOwner$/i) { print "Owner changing...\n"; $BotOwner = Regexit($_[3]) } }
  123.     $UserNick = Regexit($_[1]);
  124.     $UserHost = $_[2];
  125.     $UserMsg = POE::Component::IRC::Common::strip_formatting(POE::Component::IRC::Common::strip_color($UserMsg));
  126.     $CurSec = SpamProtect();
  127.     &CREATEUser($UserNick);
  128.     if($DBUsers =~ /(.*)<$UserNick :(.*?)\[Access (.*?)\](.*?)>(.*)/i) {
  129.         $Access = $3;
  130.         if($Access <= 0) {
  131.             return 0;
  132.         }
  133.     }
  134.     ##########
  135.     #WereWolf#
  136.     ##########
  137.     if(($Where =~ /wwolf/i) || ($UserNick =~ /Wolfbot/i)) {
  138.         if($Event =~ /(CHANMSG|NOTICE|PRIVMSG)/) {
  139.             $WW{"MyType"} = "Wolf" if($WW{"MyType"} =~ /werewolf/);
  140.             if(($UserMsg =~ /^($BotNick|Bots), Join/i) && ($WW{"Will Join"} !~ /No/i)) {
  141.                 $irc->yield(privmsg => "#WWolf" => "!Join");
  142.                 $WW{"Will Join"} = "No";
  143.                 $WW{"MyType"} = "Villager";
  144.             }
  145.             elsif($UserMsg =~ /^$BotNick, Leave/i) {
  146.                 $irc->yield(part => "#WWolf" => "Invite me, and I will continue playing.");
  147.                 $WW{"Will Join"} = "Yes";
  148.                 while ( ($key, $value) = each %WW ) {
  149.                     $WW{$key} = "";
  150.                 }
  151.             }
  152.             elsif($UserMsg =~ /^$BotNick won,/i) {
  153.                 my $alarm_id = $irc->delay( [ privmsg => "#wwolf" => "Woohoo! I won. :D" ], 1 );
  154.                 while ( ($key, $value) = each %WW ) {
  155.                     $WW{$key} = "";
  156.                 }
  157.             }
  158.             elsif($UserMsg =~ /^$BotNick lost,/i) {
  159.                 my $alarm_id = $irc->delay( [ privmsg => "#wwolf" => ";~; I didn't think I'd lose..." ], 1 );
  160.                 while ( ($key, $value) = each %WW ) {
  161.                     $WW{$key} = "";
  162.                 }
  163.             }
  164.             elsif($UserMsg =~ /^$BotNick.*?wolf/i) {
  165.                 @rray = ($UserNick." is lying.", $UserNick." only wants to make me lose ;~;", "Not uh.", "Jeez, blaming me already...");
  166.                 $irc->yield(privmsg => "#wwolf" => $rray[int(rand(@rray))]) if(rand(100) > 50);
  167.             }
  168.             elsif($UserMsg =~ /^The game is over\.$|^Game cancelled\./i) {
  169.                 while ( ($key, $value) = each %WW ) {
  170.                     $WW{$key} = "";
  171.                 }
  172.             }
  173.             elsif($UserMsg =~ /^($BotNick|Bots), what are you/i) {
  174.                 if($WW{"MyType"} =~ /Wolf|Village Idiot/) {
  175.                     $irc->yield(privmsg => "#WWolf" => "I am a Villager.");
  176.                 }
  177.                 else {
  178.                     $irc->yield(privmsg => "#WWolf" => "I am a ".$WW{"MyType"}.".");
  179.                 }
  180.             }
  181.             elsif($UserMsg =~ /Active Roles: (.*)/i) {
  182.                 $WW{"Roles"} = $1;
  183.             }
  184.             elsif($UserMsg =~ /(.*?) (has joined|has started)/i) {
  185.                 if($1 =~ /$BotNick/) { return 0; }
  186.                 $WW{"Players"} = $WW{"Players"}.$1." ";
  187.                 @WWPlayers = split / /, $WW{"Players"};
  188.                 print "Updating players...\n".@WWPlayers."\n";
  189.             }
  190.             elsif($UserMsg =~ /^(.*) (has left the game|struggles vainly|was)/i) {
  191.                 $WW{"Players"} =~ s/$1 //igs;
  192.                 @WWPlayers = split / /, $WW{"Players"};
  193.                 print "Updating players...\n".@WWPlayers."\n";
  194.             }
  195.             elsif($UserMsg =~ /has cast their vote for (.*?)!/i) {
  196.                 $tring = $1;
  197.                 $WW{"Votes".Regexit($tring)}++;
  198.                 if(($WW{"Votes".Regexit($tring)} > $WW{"MostVoted"}) && (Regexit($tring) !~ /$WW{"MostVotedName"}/)) {
  199.                     $WW{"MostVoted"} = $WW{"Votes".Regexit($tring)};
  200.                     $WW{"MostVotedName"} = Regexit($tring);
  201.                     $irc->yield(privmsg => "WolfBot" => "vote ".$tring) if((int(rand(100)) > 80) && ($tring !~ /$BotNick/i));
  202.                 }
  203.             }
  204.             elsif($UserMsg =~ /seconds to send your votes/i) {
  205.                 $WW{"MostVoted"}="";
  206.                 $WW{"MostVotedName"}="";
  207.                 if($WW{"Vote"} !~ /^$/) {
  208.                     my $alarm_id = $irc->delay( [ privmsg => "WolfBot" => "vote ".$WW{"Vote"} ], 5 );
  209.                 }
  210.                 elsif(int(rand(100)) > 70) {
  211.                     my $alarm_id = $irc->delay( [ privmsg => "WolfBot" => "vote ".$WWPlayers[int(rand(@WWPlayers))] ], 5 );
  212.                 }
  213.                 $WW{"Vote"} = "";
  214.                 if($WW{"MyType"} =~ /Village Idiot/i) {
  215.                     $WW{"Vote"} = $BotNick;
  216.                 }
  217.             }
  218.             if(($UserNick =~ /WolfBot/i) && ($Event =~ /(NOTICE|PRIVMSG|CHANMSG)/)) {
  219.                 if($UserMsg =~ /You are a wolf!/i) {
  220.                     $WW{"MyType"} = "Wolf";
  221.                     my $alarm_id = $irc->delay( [ privmsg => "#WWolf" => $WWPlayers[int(rand(@WWPlayers))]." is Wolf." ], 50 ) if($WW{"Roles"} =~ /Idiot/i);
  222.                     $WW{"Vote"} = $BotNick;
  223.                 }
  224.                 elsif($UserMsg =~ /You are the finder!/i) {
  225.                     $WW{"MyType"} = "Finder";
  226.                 }
  227.                 elsif($UserMsg =~ /You are the seer!/i) {
  228.                     $WW{"MyType"} = "Seer";
  229.                 }
  230.                 elsif($UserMsg =~ /You are the doppleganger!/i) {
  231.                     $WW{"MyType"} = "Doppleganger";
  232.                 }
  233.                 elsif($UserMsg =~ /You are the angel!/i) {
  234.                     $WW{"MyType"} = "Angel";
  235.                 }
  236.                 elsif($UserMsg =~ /You are the Village Idiot!/i) {
  237.                     $WW{"MyType"} = "Village Idiot";
  238.                     my $alarm_id = $irc->delay( [ privmsg => "#WWolf" => $WWPlayers[int(rand(@WWPlayers))]." is Wolf." ], 50 );
  239.                     $WW{"Vote"} = $BotNick;
  240.                 }
  241.                 elsif($UserMsg =~ /into (a|an) (.*?)!/i) {
  242.                     $tring = $2;
  243.                     if($tring =~ /werewolf/i) {
  244.                         $WW{"MyType"} = "Wolf";
  245.                         my $alarm_id = $irc->delay( [ privmsg => "#WWolf" => $WWPlayers[int(rand(@WWPlayers))]." is Wolf." ], 50 ) if($WW{"Roles"} =~ /Idiot/i);
  246.                         $WW{"Vote"} = $BotNick;
  247.                     }
  248.                     if($tring =~ /village idiot/i) {
  249.                         $WW{"MyType"} = "Village Idiot";
  250.                         my $alarm_id = $irc->delay( [ privmsg => "#WWolf" => $WWPlayers[int(rand(@WWPlayers))]." is Wolf." ], 50 );
  251.                         $WW{"Vote"} = $BotNick;
  252.                     }
  253.                     if($tring =~ /angel/i) { $WW{"MyType"} = "Angel"; }
  254.                     if($tring =~ /seer/i) { $WW{"MyType"} = "Seer"; }
  255.                     if($tring =~ /finder/i) { $WW{"MyType"} = "Finder"; }
  256.                     else {
  257.                         $WW{"MyType"} = $tring;
  258.                     }
  259.                 }
  260.                 elsif($UserMsg =~ /You have 45/i) {
  261.                     if($WW{"MyType"} =~ /Wolf/i) {
  262.                         $irc->yield(privmsg => "wolfbot" => "kill ".$WWPlayers[int(rand(@WWPlayers))]);
  263.                     }
  264.                     elsif($WW{"MyType"} =~ /Seer/i) {
  265.                         $WW{"Target"} = $WWPlayers[0];
  266.                         $WW{"Players"} =~ s/$WWPlayers[0] //igs;
  267.                         @WWPlayers = split / /, $WW{"Players"};
  268.                         $irc->yield(privmsg => "wolfbot" => "see ".$WW{"Target"});
  269.                     }
  270.                     elsif($WW{"MyType"} =~ /Finder/i) {
  271.                         $WW{"Target"} = $WWPlayers[0];
  272.                         $WW{"Players"} =~ s/$WWPlayers[0] //igs;
  273.                         @WWPlayers = split / /, $WW{"Players"};
  274.                         $irc->yield(privmsg => "wolfbot" => "find ".$WW{"Target"});
  275.                     }
  276.                     if($WW{"MyType"} =~ /Doppleganger/i) {
  277.                         $WW{"Target"} = $WWPlayers[int(rand(@WWPlayers))];
  278.                         $irc->yield(privmsg => "wolfbot" => "dopple ".$WW{"Target"});
  279.                     }
  280.                     if($WW{"MyType"} =~ /Angel/i) {
  281.                         $WW{"Target"} = $WWPlayers[int(rand(@WWPlayers))];
  282.                         $irc->yield(privmsg => "wolfbot" => "shield ".$WW{"Target"});
  283.                     }
  284.                 }
  285.                 elsif($UserMsg =~ /(.*?) is (a|an) (.*?)!/i) {
  286.                     $tring = $1;
  287.                     $tringt = $3;
  288.                     if($tringt =~ /Wolf/i) {
  289.                         my $alarm_id = $irc->delay( [ privmsg => "#WWolf" => $tring." is Wolf." ], 5 );
  290.                         $WW{"Vote"} = $tring;
  291.                     }
  292.                     elsif($tringt =~ /Idiot/i) {
  293.                         my $alarm_id = $irc->delay( [ privmsg => "#WWolf" => $tring." is Village idiot." ], 5 );
  294.                     }
  295.                     elsif($tringt =~ /villager/i) {
  296.                         my $alarm_id = $irc->delay( [ privmsg => "#WWolf" => $tring." is Villager." ], 5 );
  297.                     }
  298.                     elsif($tringt =~ /Angel/i) {
  299.                         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 );
  300.                     }
  301.                     elsif($tringt =~ /Doppleganger/i) {
  302.                         my $alarm_id = $irc->delay( [ privmsg => $tring => "Dopple me for seer!" ], 2 );
  303.                     }
  304.                 }
  305.                 elsif($UserMsg =~ /(.*?) targe(t*?)ed (.*?)!/i) {
  306.                     $tring = $1;
  307.                     $tringt = $3;
  308.                     my $alarm_id = $irc->delay( [ privmsg => "#WWolf" => $tring." targetted ".$tringt."." ], 5 );
  309.                     $WW{"Vote"} = $tring;
  310.                 }
  311.                 elsif($UserMsg =~ /The (wolves|other wolves) are: (.*)/i) {
  312.                     @WWolfs = split /, /, $1;
  313.                     print "Updating players...\n";
  314.                     foreach (@WWolfs) {
  315.                         $WW{"Players"} =~ s/$_ //gs;
  316.                         @WWPlayers = split / /, $WW{"Players"};
  317.                         print "Updating players...\n".@WWPlayers."\n";
  318.                     }
  319.                 }
  320.             }
  321.         }
  322.     }
  323.     elsif($Event =~ /(CHANMSG|NOTICE|PRIVMSG)/) {
  324.         ################
  325.         #Owner commands#
  326.         ################
  327.         if($_[4] =~ /^${CmdPrefix}Do (.*)/i) {
  328.             @rray = split / /, $1;
  329.             if($UserNick =~ /^$BotOwner$/i) {
  330.                 $irc->yield(@rray);
  331.             }
  332.         }
  333.         elsif($_[4] =~ /^${CmdPrefix}Setv \$(.*?) (.*)/i) {
  334.             $tring = $1;
  335.             $tringt = $2;
  336.             if($UserNick =~ /^$BotOwner$/i) {
  337.                 ${$tring} = $tringt;
  338.                 Command($Com."$tring set to $tringt");
  339.             }
  340.         }
  341.         elsif($UserMsg =~ /^${CmdPrefix}Vars \$(.*)/i) {
  342.             $tring = $1;
  343.             if($UserNick =~ /^$BotOwner$/i) {
  344.                 Command($Com."${$tring}") if(${$tring} !~ /$BotPass/);
  345.             }
  346.         }
  347.         elsif($UserMsg =~ /^${CmdPrefix}DefCon (.*)/i) {
  348.             $tring = $1;
  349.             if($UserNick =~ /^$BotOwner$/i) {
  350.                 if($tring !~ /\D/) {
  351.                     @rray = split /\s/, $tring;
  352.                     $DefCon = $rray[0];
  353.                     Command($Com."DefCon setting changed to $rray[0]");
  354.                 }
  355.                 elsif($tring =~ /Current/i) {
  356.                     Command($Com."Current DefCon setting is $DefCon");
  357.                 }
  358.             }
  359.         }
  360.         elsif($UserMsg =~ /^${CmdPrefix}Nick (.*)/i) {
  361.             $tring = $1;
  362.             if($UserNick =~ /^$BotOwner$/i) {
  363.                 $BotNick = $tring;
  364.                 $irc->yield(nick => $tring);
  365.             }
  366.         }
  367.         elsif($UserMsg =~ /^${CmdPrefix}Amsg (.*)/i) {
  368.             $tring = $1;
  369.             open DATA, "<".$BotPath.(split / /, $Connect)[0]."-AutoJoin.txt";
  370.             @Channels=<DATA>;
  371.             close DATA;chomp(@Channels);
  372.             $BotChannels = $Channels[0];
  373.             $irc->yield(join => $BotChannels);
  374.             if($UserNick =~ /^$BotOwner$/i) {
  375.                 $irc->yield(privmsg => $BotChannels => $tring);
  376.             }
  377.         }
  378.         ######
  379.         #Coin#
  380.         ######
  381.         elsif($UserMsg =~ /^${CmdPrefix}Coin/i) {
  382.             $Coin = rand(100); # Generates a random number from 0 - 100, so really, tails has the advantage.
  383.             #Command could be lchanged to two lines using an array..
  384.             # @Coin = ("Heads", "Tails");
  385.             # Command($Com.$Coin[rand(@Coin)]);
  386.             if($Coin > 50) {
  387.                 Command($Com."Heads");
  388.             }
  389.             else {
  390.                 Command($Com."Tails");
  391.             }
  392.         }
  393.         ##################
  394.         #Guess The Number#
  395.         ##################
  396.         elsif($UserMsg =~ /^${CmdPrefix}gtn (.*)/i) {
  397.             $tring = $1;
  398.             @rray = split /\s/, $tring;
  399.             if($DefCon > "4") {
  400.                 if($GTNstat =~ "OFF") {
  401.                     $GTNstat = "ON";
  402.                     $GTN = int(rand(100));
  403.                     Command($Com."Guess the Number is now on.  Use ${CmdPrefix}gtn <number from 1 to 100> to guess.");
  404.                 }
  405.                 elsif($rray[0] =~ /OFF/i) {
  406.                     $GTNstat = "OFF";
  407.                     $GTN = "";
  408.                     Command($Com."Guess the Number has been cancelled.");
  409.                 }
  410.                 elsif($GTNstat =~ "ON") {
  411.                     if($rray[0] !~ /\D/) {
  412.                         if($rray[0] == $GTN) {
  413.                             Command($Com."$rray[0] is correct.");
  414.                             Command($Com."$UserNick wins.");
  415.                             $GTNstat = "OFF";
  416.                             $GTN = "";
  417.                         }
  418.                         elsif($rray[0] !~ $GTN) {
  419.                             if($rray[0] < $GTN) {
  420.                                 Command($Com."$rray[0] is incorrect.  Try a higher number.");
  421.                             }
  422.                             elsif($rray[0] > $GTN) {
  423.                                 Command($Com."$rray[0] is incorrect.  Try a lower number.");
  424.                             }
  425.                         }
  426.                     }
  427.                     else {
  428.                         Command($Com."Please just use numbers.");
  429.                     }
  430.                 }
  431.                 else {
  432.                     Command($Com."Variable confliction.  Guess the Number cancelled.");
  433.                     $GTNstat = "OFF";
  434.                     $GTN = "";
  435.                 }
  436.             }
  437.         }
  438.         ###########
  439.         #Query Spy#
  440.         ###########
  441.         elsif($UserMsg =~ /^${CmdPrefix}QuerySpy (.*)/i) {
  442.             $tring = $1;
  443.             @rray = split /\s/, $tring;
  444.             if($UserNick =~ /^$BotOwner$/i) {
  445.                 if($rray[0] =~ /^Start/i) {
  446.                     if($QuerySpy =~ /^ON/i) {
  447.                         Command($Com."QuerySpy is already on.");
  448.                     }
  449.                     else {
  450.                         $QuerySpy = "ON";
  451.                         $QueryAt = "atLog";
  452.                         Command($Com."QuerySpy has been initiated.  Would you like to enable logging? ${CmdPrefix}QS Yes or ${CmdPrefix}QS No.");
  453.                     }
  454.                 }
  455.                 elsif($rray[0] =~ /^Stop/i) {
  456.                     if($QuerySpy =~ /^OFF/i) {
  457.                         Command($Com."QuerySpy is already off.");
  458.                     }
  459.                     else {
  460.                         $QuerySpy = "OFF";
  461.                         $QueryAt = "";
  462.                         $QSTarg = "";
  463.                         $QueryChan = "";
  464.                         $QueryLog = "";
  465.                         Command($Com."QuerySpy has been disabled.");
  466.                     }
  467.                 }
  468.                 else {
  469.                     Command($Com."That is not a valid option.");
  470.                 }
  471.             }
  472.         }
  473.         elsif($UserMsg =~ /^${CmdPrefix}QS (.*)/i) {
  474.             $tring = $1;
  475.             @rray = split /\s/, $tring;
  476.             if($UserNick =~ /^$BotOwner$/i) {
  477.                 if($QueryAt =~ /^atLog/i) {
  478.                     if($rray[0] =~ /^Yes/i) {
  479.                         $QueryLog = "Yes";
  480.                         Command($Com."Logging is now enabled.  Please choose a target via ${CmdPrefix}Target <target>");
  481.                         $QueryAt = "atTarg";
  482.                     }
  483.                     elsif($rray[0] =~ /^No/i) {
  484.                         $QueryLog = "No";
  485.                         Command($Com."Logging is now disabled.  Please choose a target via ${CmdPrefix}Target <target>");
  486.                         $QueryAt = "atTarg";
  487.                     }
  488.                     else {
  489.                         Command($Com."Please use only Yes or No options.");
  490.                     }
  491.                 }
  492.             }
  493.         }
  494.         elsif($UserMsg =~ /^${CmdPrefix}Target (.*)/i) {
  495.             $tring = $1;
  496.             @rray = split /\s/, $tring;
  497.             if($QueryAt =~ /^atTarg/i) {
  498.                 if($UserNick =~ /^$BotOwner$/i) {
  499.                     $QSTarg = $rray[0];
  500.                     $QueryAt = "atWhere";
  501.                     Command($Com."QuerySpy target set to $QSTarg");
  502.                     Command($Com."Choose where messages will be send with ${CmdPrefix}Where");
  503.                 }
  504.             }
  505.         }
  506.         elsif($UserMsg =~ /^${CmdPrefix}Where (.*)/i) {
  507.             $tring = $1;
  508.             @rray = split /\s/, $tring;
  509.             if($UserNick =~ /^$BotOwner$/i) {
  510.                 if($QueryAt =~ /^atWhere/i) {
  511.                     $QueryChan = $rray[0];
  512.                     $QueryAt = "atSay";
  513.                     if($QueryLog =~ /^Yes/i) {
  514.                         open DATA, ">>".$BotPath."QueryLogs.txt";
  515.                         print DATA "QuerySpy session started with $QSTarg"."\n";
  516.                         close DATA;
  517.                     }
  518.                     Command($Com."QuerySpy channel set to $QueryChan");
  519.                 }
  520.             }
  521.         }
  522.         elsif($UserNick =~ /^$QSTarg/i) {
  523.             $tring = $UserMsg;
  524.             @rray = split (/\s/, $tring);
  525.             if($QueryAt =~ /^atSay/i) {
  526.                 if($Event =~ /PRIVMSG/) {
  527.                     $irc->yield(privmsg.$QueryWhere."$UserNick ~~ $UserMsg");
  528.                     if($QueryLog =~ /^Yes/i) {
  529.                         open DATA, ">>".$BotPath."QueryLogs.txt";
  530.                         print DATA "QSTarg ~~ $UserMsg"."\n";
  531.                         close DATA;
  532.                     }
  533.                 }
  534.             }
  535.         }
  536.         elsif($UserMsg =~ /^${CmdPrefix}Say (.*)/i) {
  537.             if($UserNick =~ /^$BotOwner$/i) {
  538.                 if($QueryAt =~ /^atSay/i) {
  539.                     $irc->yield(privmsg.$QSTarg."$1");
  540.                     $irc->yield(privmsg.$QueryChan.$1);
  541.                     if($QueryLog =~ /^Yes/i) {
  542.                         open DATA, ">>".$Botpath."QueryLogs.txt";
  543.                         print DATA "$BotOwner ~~ ".$1."\n";
  544.                         close DATA
  545.                     }
  546.                 }
  547.             }
  548.         }
  549.         ###############
  550.         #Truth or Dare#
  551.         ###############
  552.         elsif($UserMsg =~ /^${CmdPrefix}TD/i) {
  553.             if($DefCon > 3) {
  554.                 if($TDstat =~ "OFF") {
  555.                     $TDstat = "ON";
  556.                     $TDwhere = "atMode";
  557.                     $TDtarg = $UserNick;
  558.                     Command($Com."Truth or Dare has begun.  Please choose either ${CmdPrefix}PG13 mode or ${CmdPrefix}XXX mode.");
  559.                 }
  560.                 elsif($TDstat =~ "ON") {
  561.                     Command($Com."Truth or Dare is already on.");
  562.                 }
  563.                 else {
  564.                     Command($Com."Variable confliction.  Ending.");
  565.                     $TDwhere = "";
  566.                     $TDstat = "OFF";
  567.                     $TDtarg = "";
  568.                 }
  569.             }
  570.         }
  571.         elsif($UserMsg =~ /^${CmdPrefix}PG13/i) {
  572.             if(($DefCon > 3) && ($TDwhere = "atMode")) {
  573.                 $TDmode = "PG13";
  574.                 $TDwhere = "atPick";
  575.                 Command($Com."Mode set to PG13.");
  576.                 Command($Com."Please pick the first target, $TDtarg");
  577.             }
  578.         }
  579.         elsif($UserMsg =~ /^${CmdPrefix}XXX/i) {
  580.             if(($DefCon > 3) && ($TDwhere = "atMode")) {
  581.                 $TDmode = "XXX";
  582.                 $TDwhere = "atPick";
  583.                 Command($Com."Mode set to XXX.");
  584.                 Command($Com."Please pick the first target, $TDtarg");
  585.             }
  586.         }
  587.         elsif($UserMsg =~ /^${CmdPrefix}Pick (.*)/i) {
  588.             $tring = $1;
  589.             @rray = split /\s/, $tring;
  590.             if(($DefCon > 3) && ($TDwhere = "atPick")) {
  591.                 if($rray[0] !~ $BotNick) {
  592.                     $TDtarg = $rray[1];
  593.                     Command($Com."Please choose either ${CmdPrefix}Truth or ${CmdPrefix}Dare.");
  594.                     $TDwhere = "atChoose";
  595.                 }
  596.             }
  597.         }
  598.         elsif($UserMsg =~ /^${CmdPrefix}Truth/i) {
  599.             if($DefCon > 3) {
  600.                 if($TDmode = "PG13") {
  601.                     open DATA, "<".$BotPath."PG13Truth.txt";
  602.                     @PG13Truth=<DATA>;
  603.                     close DATA;
  604.                     $TDwhere = "atPick";
  605.                     Command($Com."$PG13Truth[int(rand(@PG13Truth))]");
  606.                     Command($Com."Please type ${CmdPrefix}Pick <nick> after answering.");
  607.                 }
  608.                 if($TDmode = "XXX") {
  609.                     open DATA, "<".$BotPath."XXXTruth.txt";
  610.                     @PG13Truth=<DATA>;
  611.                     close DATA;
  612.                     $TDwhere = "atPick";
  613.                     Command($Com."$XXXTruth[int(rand(@XXXTruth))]");
  614.                     Command($Com."Please type ${CmdPrefix}Pick <nick> after answering.");
  615.                 }
  616.             }
  617.         }
  618.         elsif($UserMsg =~ /^${CmdPrefix}Dare/i) {
  619.             if($DefCon > 3) { # Could connect it with the elsif above, elsif($UserMsg =~ /^${CmdPrefix}Dare/i) && ($DefCon > 3) {
  620.                 if($TDmode = "PG13") {
  621.                     open DATA, "<".$BotPath."PG13Dare.txt";
  622.                     @PG13Truth=<DATA>;
  623.                     close DATA;
  624.                     $TDwhere = "atPick";
  625.                     Command($Com."$PG13Dare[int(rand(@PG13Dare))]");
  626.                     Command($Com."Please type ${CmdPrefix}Pick <nick> after answering.");
  627.                 }
  628.                 if($TDmode = "XXX") {
  629.                     open DATA, "<".$BotPath."XXXDare.txt";
  630.                     @PG13Truth=<DATA>;
  631.                     close DATA;
  632.                     $TDwhere = "atPick";
  633.                     Command($Com."$XXXDare[int(rand(@XXXDare))]");
  634.                     Command($Com."Please type ${CmdPrefix}Pick <nick> after answering.");
  635.                 }
  636.             }
  637.         }
  638.         elsif($UserMsg =~ /^${CmdPrefix}TD-/i) {
  639.             if($TDstat = "ON") {
  640.                 $TDstat = "OFF";
  641.                 Command($Com."Truth or Dare has been disabled.");
  642.                 $TDwhere = "";
  643.                 $TDmode = "";
  644.                 $TDtarg = "";
  645.             }
  646.         }
  647.         ######
  648.         #Math#
  649.         ######
  650.         elsif($UserMsg =~ /^${CmdPrefix}Math (.*)/i) {
  651.             $tring = $1;
  652.             @rray = split /\s/, $tring;
  653.             if($DefCon > 1) {
  654.                 if($rray[0] =~ /Calc/i) {
  655.                     $MathAns = eval $rray[1];
  656.                     Command($Com."The answer is $MathAns");
  657.                 }
  658.                 elsif($rray[0] =~ /Abs/i) {
  659.                     $MathAns = abs $rray[1];
  660.                     Command($Com."The answer is $MathAns");
  661.                 }
  662.                 elsif($rray[0] =~ /Cos/i) {
  663.                     $MathAns = cos $rray[1];
  664.                     Command($Com."The answer is $MathAns");
  665.                 }
  666.                 elsif($rray[0] =~ /Exp/i) {
  667.                     $MathAns = exp $rray[1];
  668.                     Command($Com."The answer is $MathAns");
  669.                 }
  670.                 elsif($rray[0] =~ /Log/i) {
  671.                     $MathAns = log $rray[1];
  672.                     Command($Com."The answer is $MathAns");
  673.                 }
  674.                 elsif($rray[0] =~ /Sin/i) {
  675.                     $MathAns = sin $rray[1];
  676.                     Command($Com."The answer is $MathAns");
  677.                 }
  678.                 elsif($rray[0] =~ /Sqrt/i) {
  679.                     $MathAns = sqrt $rray[1];
  680.                     Command($Com."The answer is $MathAns");
  681.                 }
  682.             }
  683.         }
  684.         #####################
  685.         #Important Commands #
  686.         #####################
  687.         elsif($UserMsg =~ /^${CmdPrefix}(Help|Commands)$/i) {
  688.             if($DefCon > 1) {
  689.                 Command($Com."!GTN - Starts Guess the Number game.  Remember to include a space after !gtn or it won't start correctly.");
  690.                 Command($Com."!DefCon - Sets DefCon level.  Only usable by owner.");
  691.                 Command($Com."!Math - Performs mathematical operations.  Currently supported:");
  692.                 Command($Com."Math(cont) - abs (absolute value), cos (cosine), exp (exponent), log (logarithm), sin (sine), sqrt (square root)");
  693.                 Command($Com."Math(cont) - calc (acts as a calculator)");
  694.             }
  695.         }
  696.         elsif($UserMsg =~ /^${CmdPrefix}AJ$/i) {
  697.             if($DefCon > 2) {
  698.                 open DATA, "<".$BotPath.(split / /, $Connect)[0].(split / /, $Connect)[1]."-AutoJoin.txt";
  699.                 @Channels=<DATA>;
  700.                 close DATA;
  701.                 if($Channels[0] !~ /$Where,/i) {
  702.                     open DATA, ">>".$BotPath.(split / /, $Connect)[0].(split / /, $Connect)[1]."-Autojoin.txt"; print DATA "$Where,";
  703.                     Command($Com."Channel added to AutoJoin.");
  704.                 }
  705.                 else {
  706.                     Command($Com."Channel already in AutoJoin.");
  707.                 }
  708.             }
  709.         }
  710.         #####################
  711.         #    END        #
  712.         #####################
  713.     }
  714. }
  715. sub Regexit {
  716.     ($Reg = $_[0]) =~ s/\\/\\\\/gs;
  717.     $Reg =~ s/(\?|\(|\)|\||\[|\|\{|\}|\.)/\\$1/gs;
  718.     $Reg =~ s/\*/\(\.\*\)/gs;
  719.     return $Reg;
  720. }
  721. sub CREATEUser {
  722.     if($DBUsers !~ /(.*)<$_[0] :(.*?)>(.*)/i) {
  723.         open DATA, ">>".$BotPath."DBUsers.txt";
  724.         print DATA "<".$_[0]." : \\\[Access 1\\\] >";
  725.         close DATA;
  726.         open DATA, "<".$BotPath."DBUsers.txt";
  727.         @DB = <DATA>;
  728.         chomp($DBUsers = $DB[0]);
  729.         close DATA;
  730.     }
  731. }
  732. sub SpamProtect {
  733.     my($Sec, $Min, $Hour, $Day, $mon, $year, $WDay, $YDay) = localtime;
  734.     return (((($YDay * 24) * 60) * 60) + (($Hour * 60) * 60) + ($Min * 60) + $Sec);
  735. }
  736. sub Command {
  737.     $PrivmsgA = $_[0];
  738.     @PrivmsgB = split / /, $PrivmsgA;
  739.     $ComA = shift(@PrivmsgB);
  740.     $ComB = shift(@PrivmsgB);
  741.     if($BotNick =~ /Luka/i) { $BotFont = "〜"; $irc->yield($ComA => $ComB => POE::Component::IRC::Common::MAGENTA.(join " ", @PrivmsgB)." 〜"); }
  742.     elsif($BotNick =~ /(Rin|Len)/i) { $BotFont = "〜"; $irc->yield($ComA => $ComB => POE::Component::IRC::Common::ORANGE.(join " ", @PrivmsgB)." ☯"); }
  743.     elsif($BotNick =~ /Pichu/i) { $BotFont = "⚡"; $irc->yield($ComA => $ComB => POE::Component::IRC::Common::ORANGE.(join " ", @PrivmsgB)." ⚡"); }
  744.     elsif($BotNick =~ /Akul/i) { $irc->yield($ComA => $ComB => POE::Component::IRC::Common::MAGENTA.(reverse(join " ", @PrivmsgB))." 〜"); }
  745.     elsif($BotNick =~ /Ukalay/i) { $irc->yield($ComA => $ComB => POE::Component::IRC::Common::MAGENTA.(PigLatin(join " ", @PrivmsgB))." 〜"); }
  746.     else { $irc->yield($ComA => $ComB => (join " ", @PrivmsgB).""); }
  747. }
  748. sub GetTime { # This is just for timestamps, just leave it.
  749.     my($Sec, $Min, $Hour, $Day, $Mon, $Year, $WDay, $YDay) = localtime;
  750.     my $APM = "AM";
  751.     if($Hour > 12) { $Hour -= 12; $APM = "PM"; }
  752.     if($Hour < 10) { $Hour = "0".$Hour; }
  753.     if($Min < 10) { $Min = "0".$Min; }
  754.     if($Sec < 10) { $Sec = "0".$Sec; }
  755.     return "[ $Hour:$Min:$Sec $APM ]    ";
  756. }
  757. # Caaz was here.
  758. $poe_kernel->run();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement