Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- print "POE IRC Bot. Skeleton by Caaz.\n";
- print "SERVER \(Optional PORT NICK\)\n";
- chomp($Connect = <STDIN>);
- use POE::Component::IRC;
- use POE;
- BOTVARS: {
- $BotNick = "DuskBot"; # Nick
- $BotUser = "Dusk"; # Username "indent"
- $BotName = "DuskBot 2.0"; # Real Name
- $CmdPrefix = "!"; # Command Prefix
- $BotPass = "Removed"; # Nickserv Password
- $BotOwner = "Solareon"; # Owner of the Bot
- $BotPath = "/home/solareon/Desktop/DuskBot"; # Path to any files.
- $BotVersion = "DuskBot 2.0 (Perl)";
- }
- FILES: {
- open DATA, "<".$BotPath."DBUsers.txt";
- @DB = <DATA>;
- chomp($DBUsers = $DB[0]);
- close DATA;
- }
- open DATA, "<".$BotPath.(split / /, $Connect)[0]."-AutoJoin.txt";
- @Channels=<DATA>;
- close DATA;chomp(@Channels);
- $BotChannels = $Channels[0];
- $Connect = $Connect." ".$BotNick;
- $BotNick = (split / /, $Connect)[2];
- my ($irc) = POE::Component::IRC->spawn();
- POE::Session->create(inline_states => {
- _start => sub {
- $irc->yield(register => "all");
- $irc->yield( connect => {
- Nick => (split / /, $Connect)[2],
- Username => $BotUser,
- Ircname => $BotName,
- Server => (split / /, $Connect)[0],
- Port => (split / /, $Connect)[1],
- });
- },
- irc_001 => sub {
- $TDstat = "OFF";
- $DefCon = "5";
- $GTNstat = "OFF";
- $irc->yield(mode => $BotNick." +B");
- $irc->yield(privmsg => "Nickserv" => "id ".$BotPass);
- my $alarm_id = $irc->delay( [ join => $BotChannels ], 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_ctcp_version => sub {
- my ($kernel, $IRCWho, $where, $IRCWhat) = @_[KERNEL, ARG0, ARG1, ARG2];
- $IRCWhere = $where->[0];
- print GetTime()."CTCP > * Got CTCP VERSION from ".(split /!/, $IRCWho)[0]."\n";
- $irc->yield(ctcpreply => (split /!/, $IRCWho)[0] => $BotVersion);
- },
- 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" if((split /!/, $IRCWho)[0] !~ /WolfBot/i);
- 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_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 !~ /sex/i) { $irc->yield(join => $Use$
- elsif($Event =~ /JOIN/) { $Com = "notice ".$_[3]." "; $UserMsg = $_[3]; $Where = $_[1]; }
- elsif($Event =~ /NICK/) { if($_[1] =~ /^$BotOwner$/i) { print "Owner changing...\n"; $BotOwner = Regexit($_[3]) } }
- $UserNick = Regexit($_[1]);
- $UserHost = $_[2];
- $UserMsg = POE::Component::IRC::Common::strip_formatting(POE::Component::IRC::Common::strip_color($UserMsg));
- $CurSec = SpamProtect();
- &CREATEUser($UserNick);
- if($DBUsers =~ /(.*)<$UserNick :(.*?)\[Access (.*?)\](.*?)>(.*)/i) {
- $Access = $3;
- if($Access <= 0) {
- return 0;
- }
- }
- ##########
- #WereWolf#
- ##########
- 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) {
- my $alarm_id = $irc->delay( [ privmsg => "#wwolf" => "Woohoo! I won. :D" ], 1 );
- while ( ($key, $value) = each %WW ) {
- $WW{$key} = "";
- }
- }
- elsif($UserMsg =~ /^$BotNick lost,/i) {
- my $alarm_id = $irc->delay( [ privmsg => "#wwolf" => ";~; I didn't think I'd lose..." ], 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...");
- $irc->yield(privmsg => "#wwolf" => $rray[int(rand(@rray))]) if(rand(100) > 50);
- }
- elsif($UserMsg =~ /^The game is over\.$|^Game cancelled\./i) {
- while ( ($key, $value) = each %WW ) {
- $WW{$key} = "";
- }
- }
- 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"};
- print "Updating players...\n".@WWPlayers."\n";
- }
- elsif($UserMsg =~ /has cast their vote for (.*?)!/i) {
- $tring = $1;
- $WW{"Votes".Regexit($tring)}++;
- if(($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)) > 80) && ($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)) > 70) {
- 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);
- $WW{"Vote"} = $BotNick;
- }
- 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);
- $WW{"Vote"} = $BotNick;
- }
- 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) {
- $irc->yield(privmsg => "wolfbot" => "kill ".$WWPlayers[int(rand(@WWPlayers))]);
- }
- 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"});
- }
- 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"});
- }
- if($WW{"MyType"} =~ /Doppleganger/i) {
- $WW{"Target"} = $WWPlayers[int(rand(@WWPlayers))];
- $irc->yield(privmsg => "wolfbot" => "dopple ".$WW{"Target"});
- }
- if($WW{"MyType"} =~ /Angel/i) {
- $WW{"Target"} = $WWPlayers[int(rand(@WWPlayers))];
- $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."." ], 5 );
- $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";
- }
- }
- }
- }
- ################
- #Owner commands#
- ################
- if($_[4] =~ /^${CmdPrefix}Do (.*)/i) {
- @rray = split / /, $1;
- if($UserNick =~ /^$BotOwner$/i) {
- $irc->yield(@rray);
- }
- }
- elsif($_[4] =~ /^${CmdPrefix}Setv \$(.*?) (.*)/i) {
- $tring = $1;
- $tringt = $2;
- if($UserNick =~ /^$BotOwner$/i) {
- ${$tring} = $tringt;
- Command($Com."$tring set to $tringt");
- }
- }
- elsif($UserMsg =~ /^${CmdPrefix}Vars \$(.*)/i) {
- $tring = $1;
- if($UserNick =~ /^$BotOwner$/i) {
- Command($Com."${$tring}") if(${$tring} !~ /$BotPass/);
- }
- }
- elsif($UserMsg =~ /^${CmdPrefix}DefCon (.*)/i) {
- $tring = $1;
- if($UserNick =~ /^$BotOwner$/i) {
- if($tring !~ /\D/) {
- @rray = split /\s/, $tring;
- $DefCon = $rray[0];
- Command($Com."DefCon setting changed to $rray[0]");
- }
- elsif($tring =~ /Current/i) {
- Command($Com."Current DefCon setting is $DefCon");
- }
- }
- }
- elsif($UserMsg =~ /^${CmdPrefix}Nick (.*)/i) {
- $tring = $1;
- if($UserNick =~ /^$BotOwner$/i) {
- $BotNick = $tring;
- $irc->yield(nick => $tring);
- }
- }
- elsif($UserMsg =~ /^${CmdPrefix}Amsg (.*)/i) {
- $tring = $1;
- open DATA, "<".$BotPath.(split / /, $Connect)[0]."-AutoJoin.txt";
- @Channels=<DATA>;
- close DATA;chomp(@Channels);
- $BotChannels = $Channels[0];
- $irc->yield(join => $BotChannels);
- if($UserNick =~ /^$BotOwner$/i) {
- $irc->yield(privmsg => $BotChannels => $tring);
- }
- }
- ######
- #Coin#
- ######
- elsif($UserMsg =~ /^${CmdPrefix}Coin/i) {
- $Coin = rand(100);
- if($Coin > 50) {
- Command($Com."Heads");
- }
- else {
- Command($Com."Tails");
- }
- }
- ##################
- #Guess The Number#
- ##################
- elsif($UserMsg =~ /^${CmdPrefix}gtn (.*)/i) {
- $tring = $1;
- @rray = split /\s/, $tring;
- if($DefCon > "4") {
- if($GTNstat =~ "OFF") {
- $GTNstat = "ON";
- $GTN = int(rand(100));
- Command($Com."Guess the Number is now on. Use ${CmdPrefix}gtn <number from 1 to 100> to guess.");
- }
- elsif($rray[0] =~ /OFF/i) {
- $GTNstat = "OFF";
- $GTN = "";
- Command($Com."Guess the Number has been cancelled.");
- }
- elsif($GTNstat =~ "ON") {
- if($rray[0] !~ /\D/) {
- if($rray[0] == $GTN) {
- Command($Com."$rray[0] is correct.");
- Command($Com."$UserNick wins.");
- $GTNstat = "OFF";
- $GTN = "";
- }
- elsif($rray[0] !~ $GTN) {
- if($rray[0] < $GTN) {
- Command($Com."$rray[0] is incorrect. Try a higher number.");
- }
- elsif($rray[0] > $GTN) {
- Command($Com."$rray[0] is incorrect. Try a lower number.");
- }
- }
- }
- else {
- Command($Com."Please just use numbers.");
- }
- }
- else {
- Command($Com."Variable confliction. Guess the Number cancelled.");
- $GTNstat = "OFF";
- $GTN = "";
- }
- }
- }
- ###########
- #Query Spy#
- ###########
- elsif($UserMsg =~ /^${CmdPrefix}QuerySpy (.*)/i) {
- $tring = $1;
- @rray = split /\s/, $tring;
- if($UserNick =~ /^$BotOwner$/i) {
- if($rray[0] =~ /^Start/i) {
- if($QuerySpy =~ /^ON/i) {
- Command($Com."QuerySpy is already on.");
- }
- else {
- $QuerySpy = "ON";
- $QueryAt = "atLog";
- Command($Com."QuerySpy has been initiated. Would you like to enable logging? ${CmdPrefix}QS Yes or ${CmdPrefix}QS No.");
- }
- }
- elsif($rray[0] =~ /^Stop/i) {
- if($QuerySpy =~ /^OFF/i) {
- Command($Com."QuerySpy is already off.");
- }
- else {
- $QuerySpy = "OFF";
- $QueryAt = "";
- $QSTarg = "";
- $QueryChan = "";
- $QueryLog = "";
- Command($Com."QuerySpy has been disabled.");
- }
- }
- else {
- Command($Com."That is not a valid option.");
- }
- }
- }
- elsif($UserMsg =~ /^${CmdPrefix}QS (.*)/i) {
- $tring = $1;
- @rray = split /\s/, $tring;
- if($UserNick =~ /^$BotOwner$/i) {
- if($QueryAt =~ /^atLog/i) {
- if($rray[0] =~ /^Yes/i) {
- $QueryLog = "Yes";
- Command($Com."Logging is now enabled. Please choose a target via ${CmdPrefix}Target <target>");
- $QueryAt = "atTarg";
- }
- elsif($rray[0] =~ /^No/i) {
- $QueryLog = "No";
- Command($Com."Logging is now disabled. Please choose a target via ${CmdPrefix}Target <target>");
- $QueryAt = "atTarg";
- }
- else {
- Command($Com."Please use only Yes or No options.");
- }
- }
- }
- }
- elsif($UserMsg =~ /^${CmdPrefix}Target (.*)/i) {
- $tring = $1;
- @rray = split /\s/, $tring;
- if($QueryAt =~ /^atTarg/i) {
- if($UserNick =~ /^$BotOwner$/i) {
- $QSTarg = $rray[0];
- $QueryAt = "atWhere";
- Command($Com."QuerySpy target set to $QSTarg");
- Command($Com."Choose where messages will be send with ${CmdPrefix}Where");
- }
- }
- }
- elsif($UserMsg =~ /^${CmdPrefix}Where (.*)/i) {
- $tring = $1;
- @rray = split /\s/, $tring;
- if($UserNick =~ /^$BotOwner$/i) {
- if($QueryAt =~ /^atWhere/i) {
- $QueryChan = $rray[0];
- $QueryAt = "atSay";
- if($QueryLog =~ /^Yes/i) {
- open DATA, ">>".$BotPath."QueryLogs.txt";
- print DATA "QuerySpy session started with $QSTarg"."\n";
- close DATA;
- }
- Command($Com."QuerySpy channel set to $QueryChan");
- }
- }
- }
- elsif($UserNick =~ /^$QSTarg/i) {
- $tring = $UserMsg;
- @rray = split (/\s/, $tring);
- if($QueryAt =~ /^atSay/i) {
- if($Event =~ /PRIVMSG/) {
- $irc->yield(privmsg.$QueryWhere."$UserNick ~~ $UserMsg");
- if($QueryLog =~ /^Yes/i) {
- open DATA, ">>".$BotPath."QueryLogs.txt";
- print DATA "QSTarg ~~ $UserMsg"."\n";
- close DATA;
- }
- }
- }
- }
- elsif($UserMsg =~ /^${CmdPrefix}Say (.*)/i) {
- if($UserNick =~ /^$BotOwner$/i) {
- if($QueryAt =~ /^atSay/i) {
- $irc->yield(privmsg.$QSTarg."$1");
- $irc->yield(privmsg.$QueryChan.$1);
- if($QueryLog =~ /^Yes/i) {
- open DATA, ">>".$Botpath."QueryLogs.txt";
- print DATA "$BotOwner ~~ ".$1."\n";
- close DATA
- }
- }
- }
- }
- ###############
- #Truth or Dare#
- ###############
- elsif($UserMsg =~ /^${CmdPrefix}TD/i) {
- if($DefCon > 3) {
- if($TDstat =~ "OFF") {
- $TDstat = "ON";
- $TDwhere = "atMode";
- $TDtarg = $UserNick;
- Command($Com."Truth or Dare has begun. Please choose either ${CmdPrefix}PG13 mode or ${CmdPrefix}XXX mode.");
- }
- elsif($TDstat =~ "ON") {
- Command($Com."Truth or Dare is already on.");
- }
- else {
- Command($Com."Variable confliction. Ending.");
- $TDwhere = "";
- $TDstat = "OFF";
- $TDtarg = "";
- }
- }
- }
- elsif($UserMsg =~ /^${CmdPrefix}PG13/i) {
- if(($DefCon > 3) && ($TDwhere = "atMode")) {
- $TDmode = "PG13";
- $TDwhere = "atPick";
- Command($Com."Mode set to PG13.");
- Command($Com."Please pick the first target, $TDtarg");
- }
- }
- elsif($UserMsg =~ /^${CmdPrefix}XXX/i) {
- if(($DefCon > 3) && ($TDwhere = "atMode")) {
- $TDmode = "XXX";
- $TDwhere = "atPick";
- Command($Com."Mode set to XXX.");
- Command($Com."Please pick the first target, $TDtarg");
- }
- }
- elsif($UserMsg =~ /^${CmdPrefix}Pick (.*)/i) {
- $tring = $1;
- @rray = split /\s/, $tring;
- if(($DefCon > 3) && ($TDwhere = "atPick")) {
- if($rray[0] !~ $BotNick) {
- $TDtarg = $rray[1];
- Command($Com."Please choose either ${CmdPrefix}Truth or ${CmdPrefix}Dare.");
- $TDwhere = "atChoose";
- }
- }
- }
- elsif($UserMsg =~ /^${CmdPrefix}Truth/i) {
- if($DefCon > 3) {
- if($TDmode = "PG13") {
- open DATA, "<".$BotPath."PG13Truth.txt";
- @PG13Truth=<DATA>;
- close DATA;
- $TDwhere = "atPick";
- Command($Com."$PG13Truth[int(rand(@PG13Truth))]");
- Command($Com."Please type ${CmdPrefix}Pick <nick> after answering.");
- }
- if($TDmode = "XXX") {
- open DATA, "<".$BotPath."XXXTruth.txt";
- @PG13Truth=<DATA>;
- close DATA;
- $TDwhere = "atPick";
- Command($Com."$XXXTruth[int(rand(@XXXTruth))]");
- Command($Com."Please type ${CmdPrefix}Pick <nick> after answering.");
- }
- }
- }
- elsif($UserMsg =~ /^${CmdPrefix}Dare/i) {
- if($DefCon > 3) {
- if($TDmode = "PG13") {
- open DATA, "<".$BotPath."PG13Dare.txt";
- @PG13Truth=<DATA>;
- close DATA;
- $TDwhere = "atPick";
- Command($Com."$PG13Dare[int(rand(@PG13Dare))]");
- Command($Com."Please type ${CmdPrefix}Pick <nick> after answering.");
- }
- if($TDmode = "XXX") {
- open DATA, "<".$BotPath."XXXDare.txt";
- @PG13Truth=<DATA>;
- close DATA;
- $TDwhere = "atPick";
- Command($Com."$XXXDare[int(rand(@XXXDare))]");
- Command($Com."Please type ${CmdPrefix}Pick <nick> after answering.");
- }
- }
- }
- elsif($UserMsg =~ /^${CmdPrefix}TD-/i) {
- if($TDstat = "ON") {
- $TDstat = "OFF";
- Command($Com."Truth or Dare has been disabled.");
- $TDwhere = "";
- $TDmode = "";
- $TDtarg = "";
- }
- }
- ######
- #Math#
- ######
- elsif($UserMsg =~ /^${CmdPrefix}Math (.*)/i) {
- $tring = $1;
- @rray = split /\s/, $tring;
- if($DefCon > 1) {
- if($rray[0] =~ /Calc/i) {
- $MathAns = eval $rray[1];
- Command($Com."The answer is $MathAns");
- }
- elsif($rray[0] =~ /Abs/i) {
- $MathAns = abs $rray[1];
- Command($Com."The answer is $MathAns");
- }
- elsif($rray[0] =~ /Cos/i) {
- $MathAns = cos $rray[1];
- Command($Com."The answer is $MathAns");
- }
- elsif($rray[0] =~ /Exp/i) {
- $MathAns = exp $rray[1];
- Command($Com."The answer is $MathAns");
- }
- elsif($rray[0] =~ /Log/i) {
- $MathAns = log $rray[1];
- Command($Com."The answer is $MathAns");
- }
- elsif($rray[0] =~ /Sin/i) {
- $MathAns = sin $rray[1];
- Command($Com."The answer is $MathAns");
- }
- elsif($rray[0] =~ /Sqrt/i) {
- $MathAns = sqrt $rray[1];
- Command($Com."The answer is $MathAns");
- }
- }
- }
- #####################
- #Important Commands #
- #####################
- elsif($UserMsg =~ /^${CmdPrefix}(Help|Commands)$/i) {
- if($DefCon > 1) {
- Command($Com."!GTN - Starts Guess the Number game. Remember to include a space after !gtn or it won't start correctly.");
- Command($Com."!DefCon - Sets DefCon level. Only usable by owner.");
- Command($Com."!Math - Performs mathematical operations. Currently supported:");
- Command($Com."Math(cont) - abs (absolute value), cos (cosine), exp (exponent), log (logarithm), sin (sine), sqrt (square root)");
- Command($Com."Math(cont) - calc (acts as a calculator)");
- }
- }
- elsif($UserMsg =~ /^${CmdPrefix}AJ$/i) {
- if($DefCon > 2) {
- open DATA, "<".$BotPath.(split / /, $Connect)[0].(split / /, $Connect)[1]."-AutoJoin.txt";
- @Channels=<DATA>;
- close DATA;
- if($Channels[0] !~ /$Where,/i) {
- open DATA, ">>".$BotPath.(split / /, $Connect)[0].(split / /, $Connect)[1]."-Autojoin.txt"; print DATA "$Where,";
- Command($Com."Channel added to AutoJoin.");
- }
- else {
- Command($Com."Channel already in AutoJoin.");
- }
- }
- }
- #####################
- # END #
- #####################
- }
- }
- sub Regexit {
- ($Reg = $_[0]) =~ s/\\/\\\\/gs;
- $Reg =~ s/(\?|\(|\)|\||\[|\|\{|\}|\.)/\\$1/gs;
- $Reg =~ s/\*/\(\.\*\)/gs;
- return $Reg;
- }
- sub CREATEUser {
- if($DBUsers !~ /(.*)<$_[0] :(.*?)>(.*)/i) {
- open DATA, ">>".$BotPath."DBUsers.txt";
- print DATA "<".$_[0]." : \\\[Access 1\\\] >";
- close DATA;
- open DATA, "<".$BotPath."DBUsers.txt";
- @DB = <DATA>;
- chomp($DBUsers = $DB[0]);
- close DATA;
- }
- }
- sub SpamProtect {
- my($Sec, $Min, $Hour, $Day, $mon, $year, $WDay, $YDay) = localtime;
- return (((($YDay * 24) * 60) * 60) + (($Hour * 60) * 60) + ($Min * 60) + $Sec);
- }
- sub Command {
- $PrivmsgA = $_[0];
- @PrivmsgB = split / /, $PrivmsgA;
- $ComA = shift(@PrivmsgB);
- $ComB = shift(@PrivmsgB);
- if($BotNick =~ /Luka/i) { $BotFont = "〜"; $irc->yield($ComA => $ComB => POE::Component::IRC::Common::MAGENTA.(join " ", @PrivmsgB)." 〜"); }
- elsif($BotNick =~ /(Rin|Len)/i) { $BotFont = "〜"; $irc->yield($ComA => $ComB => POE::Component::IRC::Common::ORANGE.(join " ", @PrivmsgB)." ☯"); }
- elsif($BotNick =~ /Pichu/i) { $BotFont = "⚡"; $irc->yield($ComA => $ComB => POE::Component::IRC::Common::ORANGE.(join " ", @PrivmsgB)." ⚡"); }
- elsif($BotNick =~ /Akul/i) { $irc->yield($ComA => $ComB => POE::Component::IRC::Common::MAGENTA.(reverse(join " ", @PrivmsgB))." 〜"); }
- elsif($BotNick =~ /Ukalay/i) { $irc->yield($ComA => $ComB => POE::Component::IRC::Common::MAGENTA.(PigLatin(join " ", @PrivmsgB))." 〜"); }
- else { $irc->yield($ComA => $ComB => (join " ", @PrivmsgB).""); }
- }
- 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