/usr/share/perl5/Bot/BasicBot/Pluggable/Module/Join.pm is in libbot-basicbot-pluggable-perl 1.20-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | package Bot::BasicBot::Pluggable::Module::Join;
$Bot::BasicBot::Pluggable::Module::Join::VERSION = '1.20';
use base qw(Bot::BasicBot::Pluggable::Module);
use warnings;
use strict;
sub connected {
my $self = shift;
my $channels = $self->get("channels") || [];
## If we are not a array reference, we are problably the old
## string format ... trying to convert
if ( not ref($channels) && $channels =~ 'ARRAY' ) {
$channels = [ split( /\s+/, $channels ) ];
}
for ( @{$channels} ) {
print "Joining $_.\n";
$self->bot->join($_);
}
}
sub help {
return
"Join and leave channels. Usage: join <channel>, leave/part <channel>, channels. Requires direct addressing.";
}
sub told {
my ( $self, $mess ) = @_;
my $body = $mess->{body};
return unless defined $body;
return unless $mess->{address};
my ( $command, $param ) = split( /\s+/, $body, 2 );
$command = lc($command);
return unless $command =~ /^(join|leave|part|channels)$/;
if (!$self->authed($mess->{who})) {
return "Sorry, you must be authenticated to do that.";
}
if ( $command eq "join" ) {
$self->add_channel($param);
return "Ok.";
}
elsif ( $command eq "leave" or $command eq "part" ) {
$self->remove_channel( $param || $mess->{channel} );
return "Ok.";
}
elsif ( $command eq "channels" ) {
my @channels = $self->bot->channels;
my $channel_num = scalar @channels;
if ( $channel_num == 0 ) {
return "I'm not in any channel.";
}
elsif ( $channel_num == 1 ) {
return "I'm in " . $channels[0] . ".";
}
elsif ( $channel_num == 2 ) {
return "I'm in " . $channels[0] . " and " . $channels[1] . ".";
}
else {
return
"I'm in "
. join( ', ', @channels[ 0 .. $#channels - 1 ] )
. " and $channels[-1].";
}
}
}
sub chanjoin {
my ( $self, $mess ) = @_;
if ( $mess->{who} eq $self->bot->nick ) {
$self->set( channels => [ $self->bot->channels ] );
}
}
sub chanpart {
my ( $self, $mess ) = @_;
if ( $mess->{who} eq $self->bot->nick ) {
$self->set( channels => [ $self->bot->channels ] );
}
}
sub add_channel {
my ( $self, $channel ) = @_;
$self->bot->join($channel);
}
sub remove_channel {
my ( $self, $channel ) = @_;
$self->bot->part($channel);
}
1;
__END__
=head1 NAME
Bot::BasicBot::Pluggable::Module::Join - join and leave channels; remembers state
=head1 VERSION
version 1.20
=head1 IRC USAGE
=over 4
=item join <channel>
=item part <channel>
=item channels
List the channels the bot is in.
=back
=head1 METHODS
=over 4
=item add_channel($channel)
=item remove_channel($channel)
=back
=head1 AUTHOR
Mario Domgoergen <mdom@cpan.org>
This program is free software; you can redistribute it
and/or modify it under the same terms as Perl itself.
|