Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use warnings;
- use strict;
- use POE;
- use POE::Component::IRC;
- use POE::Component::IRC::Common;
- use POE::Component::IRC::Qnet;
- use POE::Component::IRC::Qnet::State;
- use Date::Calc;
- #Starting up the Bot
- my ($irc) = POE::Component::IRC::Qnet::State->spawn();
- POE::Session->create(
- inline_states => {
- _start => \&bot_start,
- irc_001 => \&on_connect,
- irc_public => \&on_public,
- irc_join => \&on_join,
- irc_nick_sync => \&synced,
- irc_invite => \&invite,
- irc_ctcp_action => \&action,
- irc_nick => \&nick,
- irc_mode => \&mode,
- irc_msg => \&command,
- irc_kick => \&kick,
- irc_topic => \&topic,
- heartbeat => \&heartbeat,
- },
- );
- sub bot_start {
- $irc->yield(register => "all");
- $irc->yield(
- connect => {
- Nick => 'TheCynicalBot',
- Username => 'TheCynicalBot',
- Ircname => 'Perlbot',
- Server => 'localhost',
- Port => '10001',
- Password => '',
- }
- );
- print "Connected to Quakenet....\n";
- }
- sub on_connect {
- my @channels = ('#cynicalbrit', '#cynical.shoutcast');
- foreach my $channels (@channels) {
- $irc->yield(join => $channels);
- print "Joining " . $channels . "\n";
- }
- }
- sub heartbeat {
- $_[KERNEL]->delay(heartbeat => 15);
- }
- #Global Variables
- my %stafftitle = (
- 'Raltharg' => '#cynicalbrit Admin',
- 'TotalBiscuit' => 'the Cynical Brit',
- 'iKing' => '#cynicalbrit Moderator',
- 'Amaranthea' => '#cynicalbrit Moderator'
- );
- my @kicks = ('Good job, Sir', 'He got served!', 'Piss off you lower form of life.', '"You are the weakest link, goodbye.', 'Hey look, there is a troll on your face', "I don't like you", 'Want a cookie? Too bad.');
- my @idiotlist = ('\?', '\bwhen\b', '\bshow\b', '\bblue\s*plz\b', '\btonight\b', '\bstarts\b', '\bstream\b', '\bwatch\b', '\blisten\b', '\btotal\s*biscuit\b');
- #Subroutines
- sub on_public {
- my ($kernel, $who, $where, $msg) = @_[KERNEL, ARG0, ARG1, ARG2];
- my $nick = (split /!/, $who)[0];
- my $channel = $where->[0];
- my $ts = scalar localtime;
- print " [$ts] <$channel> <$nick> $msg\n";
- my $idiotcount = '0';
- if ($msg =~ /^!song$/i) {
- $irc->yield(privmsg => '#cynical.shoutcast' => '!song ' . $nick . '');
- }
- if ($channel eq '#cynical.shoutcast') {
- $irc->yield(privmsg => '#cynicalbrit' => $msg);
- }
- if ($irc->is_channel_operator($channel, $nick)) {
- if ($msg =~ /^!peak$/i || $msg =~ /^!listeners$/i) {
- $irc->yield(privmsg => '#cynical.shoutcast' => $msg);
- };
- };
- foreach my $idiot (@idiotlist) {
- if ($msg =~ m/$idiot/i) {
- $idiotcount++;
- }
- }
- if ($idiotcount >= '3') {
- $irc->yield(kick => $channel => $nick => 'Your stupidity has exceeded the set threshold.');
- }
- }
- sub on_join {
- my ($kernel, $who, $channel) = @_[KERNEL, ARG0, ARG1];
- my $nick = (split /!/, $who)[0];
- my $ts = scalar localtime;
- print " [$ts] <$channel> $nick joined\n";
- }
- sub synced {
- my ($kernel, $nick, $channel) = @_[KERNEL, ARG0, ARG1];
- my $ts = scalar localtime;
- my $qname = $irc->is_nick_authed($nick);
- if (($nick =~ /^Total/i) || ($nick =~ /Bain/i) || ($nick =~ /Biscuit/i)) {
- if (!$qname) {
- $irc->yield(kick => $channel => $nick => 'You are not TotalBiscuit');
- } elsif ($qname ne 'TotalBiscuit') {
- $irc->yield(kick => $channel => $nick => 'You are not TotalBiscuit');
- }
- }
- if ($qname) {
- foreach my $staff (keys %stafftitle) {
- if ($qname eq $staff) {
- $irc->yield(mode => '' . $channel . ' +o ' . $nick . '');
- $irc->yield(privmsg => $channel => 'Welcome ' . $nick . ', ' . $stafftitle{$staff} . '.');
- }
- }
- }
- }
- sub nick {
- my ($kernel, $who, $newnick) = @_[KERNEL, ARG0, ARG1];
- my $nick = (split /!/, $who)[0];
- my $ts = scalar localtime;
- my $channel = '#cynicalbrit';
- my $qname = $irc->is_nick_authed($newnick);
- if (($newnick =~ /^Total/i) || ($newnick =~ /Bain/i) || ($nick =~ /Biscuit/i)) {
- if (!$qname) {
- $irc->yield(kick => $channel => $nick => 'You are not TotalBiscuit');
- $irc->yield(kick => $channel => $newnick => 'You are not TotalBiscuit');
- } elsif ($qname ne 'TotalBiscuit') {
- $irc->yield(kick => $channel => $nick => 'You are not TotalBiscuit');
- $irc->yield(kick => $channel => $newnick => 'You are not TotalBiscuit');
- }
- }
- }
- sub invite {
- my ($kernel, $who, $channel) = @_[KERNEL, ARG0, ARG1];
- my $nick = (split /!/, $who)[0];
- my $ts = scalar localtime;
- my $qname = $irc->is_nick_authed($nick);
- if (!$qname) {
- $irc->yield(notice => $nick => 'You do not have necessary permissions to use invite, if you are staff, please log in or fuck off.');
- } elsif ($qname) {
- foreach my $staff (keys %stafftitle) {
- if ($qname eq $staff) {
- $irc->yield(join => $channel);
- $irc->yield(notice => $nick => 'Joining ' . $channel . '.');
- print "Joining $channel\n";
- }
- }
- }
- }
- sub action {
- my ($kernel, $who, $where, $action) = @_[KERNEL, ARG0, ARG1, ARG2];
- my $nick = (split /!/, $who)[0];
- my $channel = $where->[0];
- my $ts = scalar localtime;
- print " [$ts] <$channel> *$nick $action\n";
- if ($action =~ /^slaps/i) {
- $irc->yield(kick => $channel => $nick => 'Use of the slap command is prohibited.');
- }
- }
- sub topic {
- my ($kernel, $who, $where, $topicscast) = @_[KERNEL, ARG0, ARG1, ARG2];
- my $nick = (split /!/, $who)[0];
- if ($where eq '#cynicalbot.shoutcast') {
- $irc->yield(topic => '#cynicalbrit' => $topicscast);
- }
- }
- sub mode {
- my ($kernel, $who, $channel, $mode, @victim) = @_[KERNEL, ARG0, ARG1, ARG2, ARG3 .. $#_];
- my $nick = (split /!/, $who)[0];
- my $ts = scalar localtime;
- foreach my $victim (@victim) {
- print " [$ts] <$channel> $nick applies $mode $victim\n";
- }
- }
- sub command {
- my ($kernel, $who, $msg) = @_[KERNEL, ARG0, ARG2];
- my $nick = (split /!/, $who)[0];
- my $ts = scalar localtime;
- my $qname = $irc->is_nick_authed($nick);
- print " [$ts] <Private Command> <$nick> $msg\n";
- }
- sub kick {
- my ($kernel, $who, $channel, $victim, $why) = @_[KERNEL, ARG0, ARG1, ARG2, ARG3];
- my $nick = (split /!/, $who)[0];
- my $ts = scalar localtime;
- my $qname = $irc->is_nick_authed($nick);
- print " [$ts] <$channel> $nick has kicked $victim ($why)\n";
- if ($qname) {
- foreach my $staff (keys %stafftitle) {
- if ($qname eq $staff) {
- $irc->yield(privmsg => $channel => $kicks[int rand($#kicks+1)]);
- }
- }
- }
- }
- #Closing
- $poe_kernel->run();
- exit 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement