1 ################################
3 ################################
5 package BotModules::Parrot;
13 if ($self->isAdmin($event)) {
15 '' => 'This module allows you to make the bot do stuff.',
16 'say' => 'Makes the bot say something. The <target> can be a person or channel. Syntax: say <target> <text>',
17 'do' => 'Makes the bot do (/me) something. The <target> can be a person or channel. Syntax: do <target> <text>',
18 'invite' => 'Makes the bot invite (/invite) somebody to a channel. Syntax: invite <who> <channel>',
19 'announce' => 'Makes the bot announce something to every channel in which this module is enabled. Syntax: announce <text>',
22 return $self->SUPER::Help($event);
28 my ($event, $message) = @_;
29 if ((($event->{'level'} == 1) and ($self->isAdmin($event))) or
30 (($event->{'level'} == 3) and ($event->{'God_channel_rights'}) and ($event->{'Parrot_channel'} eq $event->{'God_channel'}))) {
31 if ($message =~ /^\s*say\s+(\S+)\s+(.*)$/osi) {
32 local $event->{'target'} = $1;
33 $self->say($event, $2);
34 } elsif ($message =~ /^\s*do\s+(\S+)\s+(.*)$/osi) {
35 local $event->{'target'} = $1;
36 $self->emote($event, $2);
37 } elsif ($message =~ /^\s*announce\s+(.*)$/osi) {
38 $self->announce($event, $1);
39 } elsif ($message =~ /^\s* invite \s+
41 (?: (?:in|to|into) \s+
44 $self->invite($event, $1, $2);
46 return $self->SUPER::Told(@_);
49 if (($event->{'level'} == 1) and (($message =~ /^\s*say\s+(\S+)\s+(.*)$/osi) or ($message =~ /^\s*do\s+(\S+)\s+(.*)$/osi))) {
50 $event->{'God_channel'} = lc($1);
51 $event->{'Parrot_channel'} = lc($1);
53 my $result = $self->SUPER::Told(@_);
54 return $result < (3 * defined($event->{'Parrot_channel'})) ? 3 : $result;
56 # Note: We go through some contortions here because if the parent
57 # returns 3 or more, some other module sets God_channel, and
58 # the command is either not 'say' or 'do' (or the God_channel happens
59 # to be different to the channel we are looking at) then it is theoretically
60 # possible that God_channel_rights could be set, but not for the channel
61 # we care about. Or something..... ;-)
64 return 0; # we've dealt with it, no need to do anything else.