################################ # Parrot Module # ################################ package BotModules::Parrot; use vars qw(@ISA); @ISA = qw(BotModules); 1; sub Help { my $self = shift; my ($event) = @_; if ($self->isAdmin($event)) { return { '' => 'This module allows you to make the bot do stuff.', 'say' => 'Makes the bot say something. The can be a person or channel. Syntax: say ', 'do' => 'Makes the bot do (/me) something. The can be a person or channel. Syntax: do ', 'invite' => 'Makes the bot invite (/invite) somebody to a channel. Syntax: invite ', 'announce' => 'Makes the bot announce something to every channel in which this module is enabled. Syntax: announce ', }; } else { return $self->SUPER::Help($event); } } sub Told { my $self = shift; my ($event, $message) = @_; if ((($event->{'level'} == 1) and ($self->isAdmin($event))) or (($event->{'level'} == 3) and ($event->{'God_channel_rights'}) and ($event->{'Parrot_channel'} eq $event->{'God_channel'}))) { if ($message =~ /^\s*say\s+(\S+)\s+(.*)$/osi) { local $event->{'target'} = $1; $self->say($event, $2); } elsif ($message =~ /^\s*do\s+(\S+)\s+(.*)$/osi) { local $event->{'target'} = $1; $self->emote($event, $2); } elsif ($message =~ /^\s*announce\s+(.*)$/osi) { $self->announce($event, $1); } elsif ($message =~ /^\s* invite \s+ (\S+) \s+ (?: (?:in|to|into) \s+ (?:channel \s+)? )? (\S+) \s*$/osix) { $self->invite($event, $1, $2); } else { return $self->SUPER::Told(@_); } } else { if (($event->{'level'} == 1) and (($message =~ /^\s*say\s+(\S+)\s+(.*)$/osi) or ($message =~ /^\s*do\s+(\S+)\s+(.*)$/osi))) { $event->{'God_channel'} = lc($1); $event->{'Parrot_channel'} = lc($1); } my $result = $self->SUPER::Told(@_); return $result < (3 * defined($event->{'Parrot_channel'})) ? 3 : $result; # Note: We go through some contortions here because if the parent # returns 3 or more, some other module sets God_channel, and # the command is either not 'say' or 'do' (or the God_channel happens # to be different to the channel we are looking at) then it is theoretically # possible that God_channel_rights could be set, but not for the channel # we care about. Or something..... ;-) } return 0; # we've dealt with it, no need to do anything else. }