view release on metacpan or search on metacpan
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
# Comment this out to disable the OFTC plugin
$oftc_enabled = 1;
# Nickname to use on OFTC
$oftc_nick = 'fonbot';
# Channels to join on OFTC
@oftc_channels = ();
# Password to identify to NickServ with
$oftc_nickserv_password = 'asd';
# BitlBee
# =======
# Comment this out to disable the BitlBee plugin
$bitlbee_enabled = 1;
# Nickname to use on BitlBee
$bitlbee_nick = 'marius';
# BitlBee server hostname
$bitlbee_server = 'localhost';
# BitlBee server port
$bitlbee_port = 6667;
# BitlBee server password
$bitlbee_password = 'parola';
# Common
# ======
# Directory to store state in
$dir = '/home/marius/fonbotsrv';
# Run fonbotd as this user
$user = 'marius';
lib/App/FonBot/Plugin/BitlBee.pm view on Meta::CPAN
use v5.14;
use strict;
use warnings;
use parent qw/App::FonBot::Plugin::IRC/;
use POE;
use POE::Component::IRC::Plugin::Connector;
use App::FonBot::Plugin::Config qw/$bitlbee_enabled $bitlbee_nick $bitlbee_server $bitlbee_port $bitlbee_password/;
##################################################
sub _start{
return unless $bitlbee_enabled;
my $self=$_[OBJECT];
$self->{irc} = POE::Component::IRC->spawn(
Flood => 1,
Nick => $bitlbee_nick,
lib/App/FonBot/Plugin/BitlBee.pm view on Meta::CPAN
);
$self->{irc}->yield(register => qw/msg public/);
$self->{irc}->yield(connect => {});
$self->{irc}->plugin_add(Connector => POE::Component::IRC::Plugin::Connector->new);
$_[KERNEL]->alias_set('BITLBEE')
}
sub irc_public{
my ($self, $msg)=@_[OBJECT, ARG2];
$self->{irc}->yield(privmsg => '&bitlbee', "identify $bitlbee_password") if $msg =~ /^Welcome to the BitlBee gateway!$/;
$self->{irc}->yield(privmsg => '&bitlbee', 'yes') if $msg =~ /New request:/;
}
1;
__END__
=encoding utf-8
=head1 NAME
lib/App/FonBot/Plugin/BitlBee.pm view on Meta::CPAN
BitlBee nickname
=item C<$bilbee_server>
BitlBee server hostname
=item C<$bitlbee_port>
BitlBee server port
=item C<$bitlbee_password>
BitlBee identify password
=back
=head1 AUTHOR
Marius Gavrilescu C<< <marius@ieval.ro> >>
=head1 COPYRIGHT AND LICENSE
Copyright 2013-2015 Marius Gavrilescu
lib/App/FonBot/Plugin/Config.pm view on Meta::CPAN
use v5.14;
use strict;
use warnings;
use parent qw/Exporter/;
use Apache2::Authen::Passphrase;
use Log::Log4perl qw//;
our @EXPORT_OK=qw/$oftc_enabled $oftc_nick @oftc_channels $oftc_nickserv_password $bitlbee_enabled $bitlbee_nick $bitlbee_server $bitlbee_port $bitlbee_password $dir $user $group @supplementary_groups $httpd_port $email_batch_seconds $email_from $ema...
##################################################
our ($oftc_enabled, $oftc_nick, @oftc_channels, $oftc_nickserv_password);
our ($bitlbee_enabled, $bitlbee_nick, $bitlbee_server, $bitlbee_port, $bitlbee_password);
our ($dir, $user, $group, @supplementary_groups);
our ($httpd_port);
our ($email_batch_seconds, $email_from, $email_subject);
##################################################
my $log=Log::Log4perl->get_logger(__PACKAGE__);
sub init{
$log->info('reading config file');
lib/App/FonBot/Plugin/Config.pm view on Meta::CPAN
__END__
=encoding utf-8
=head1 NAME
App::FonBot::Plugin::Config - FonBot plugin for reading configuration files
=head1 SYNOPSIS
use App::FonBot::Plugin::Config qw/$oftc_enabled $oftc_nick @oftc_channels $oftc_nickserv_password $bitlbee_enabled $bitlbee_nick $bitlbee_server $bitlbee_port $bitlbee_password $user $group @supplementary_groups $httpd_port/;
App::FonBot::Plugin::Config->init;
# Variables used in App::FonBot:Plugin::OFTC
say "The OFTC plugin is ".($oftc_enabled ? 'enabled' : 'disabled');
say "The OFTC NickServ password is $oftc_nickserv_password";
say "The OFTC nickname is $oftc_nick";
say "The OFTC channels are @oftc_channels";
# Variables used in App::FonBot::Plugin::BitlBee
say "The BitlBee plugin is ".($bitlbee_enabled ? 'enabled' : 'disabled');
say "The BitlBee server runs on port $bitlbee_port of host $bitlbee_server"
say "The BitlBee nickname is $bitlbee_nick";
say "The BitlBee password is $bitlbee_password";
# Variables used in App::FonBot::Plugin::Common
say "The storage directory is $dir";
say "The user is $user";
say "The primary group is $group";
say "The supplementary groups are @supplementary_groups";
# Variables used in App::FonBot::Plugin::HTTPD
say "The HTTPD listens on port $httpd_port"
lib/App/FonBot/Plugin/Email.pm view on Meta::CPAN
#untaint $file
$file =~ /^(.*)$/;
$file = $1;
unlink $file;
return unless defined $email;
my $replyto=$email->header('From');
return unless defined $replyto;
my ($user,$password)=split ' ', $email->header('Subject'), 2;
chomp $password;
$log->debug("Processing email from $user");
eval { pwcheck $user, $password };
if ($@) {
$log->debug("Incorrect credentials in email subject from user $user. Exception: $@");
POE::Kernel->yield(send_message => $replyto, "Incorrect credentials");
return
}
$ok_user_addresses{"$user EMAIL $replyto"}=1;
my $process_email_part = sub {
local *__ANON__ = "process_email_part"; #Name this sub. See http://www.perlmonks.org/?node_id=304883
lib/App/FonBot/Plugin/HTTPD.pm view on Meta::CPAN
die 'Bad Request';
}
sub pre_auth{
my ($request, $response)=@_;
eval {
my $authorization=$request->header('Authorization') // die 'No Authorization header';
$authorization =~ /^Basic (.+)$/ or die 'Invalid Authorization header';
my ($user, $password) = decode_base64($1) =~ /^(.+):(.*)$/ or die 'Invalid Authorization header';
eval { pwcheck $user, $password; 1 } or die 'Invalid user/password combination';
$request->header(Username => $user);
$log->debug("HTTP request from $user to url ".$request->url);
};
if (my $error = $@) {
$response->code(HTTP_UNAUTHORIZED);
$response->message('Bad username or password');
$response->header(Content_Type => 'text/plain');
$response->header(WWW_Authenticate => 'Basic realm="fonbotd"');
$response->content('Unauthorized');
$log->debug("Request denied: $error");
return RC_DENY
}
$response->content('');
RC_OK
}
lib/App/FonBot/Plugin/IRC.pm view on Meta::CPAN
local $_ = $cmd;
if (/^myid$/i){
$self->{irc}->yield(privmsg => $nick, $from);
} elsif (/^login$/i) {
my ($user, $pass) = @args;
eval { pwcheck $user, $pass };
if ($@) {
$self->{log}->debug("Login for $user failed");
$self->{irc}->yield(privmsg => $nick, 'Bad username/password combination');
} else {
$self->{log}->debug("Login for $user succeded");
$self->{nick_to_username}{$from} = $user;
$self->{irc}->yield(privmsg => $nick, "Logged in as $user");
}
} elsif (/^logout$/i){
delete $self->{nick_to_username}{$from};
} elsif (/^prefix$/i){
if (defined $username) {
$self->{prefix}{$username} = [@args];
} else {
$self->{irc}->yield(privmsg => $nick, 'You are not logged in. Say "login your_username your_password" (where your_username and your_password are your login credentials) to login.');
}
} elsif (/^noprefix$/i){
if (defined $username) {
delete $self->{prefix}{$username}
} else {
$self->{irc}->yield(privmsg => $nick, 'You are not logged in. Say "login your_username your_password" (where your_username and your_password are your login credentials) to login.');
}
} else {
if (defined $username) {
$ok_user_addresses{"$username $address"}=1;
$self->{log}->debug("Command $cmd @args from $username");
if (exists $self->{prefix}{$username}) {
sendmsg $username, undef, $address, @{$self->{prefix}{$username}}, $cmd, @args;
} else {
sendmsg $username, undef, $address, $cmd, @args;
}
} else {
$self->{irc}->yield(privmsg => $nick, 'You are not logged in. Say "login your_username your_password" (where your_username and your_password are your login credentials) to login.');
}
}
}
sub irc_public{
# Do nothing
}
sub irc_001{
# Do nothing
lib/App/FonBot/Plugin/OFTC.pm view on Meta::CPAN
use strict;
use warnings;
use parent qw/App::FonBot::Plugin::IRC/;
use POE;
use POE::Component::IRC::Plugin::AutoJoin;
use POE::Component::IRC::Plugin::Connector;
use POE::Component::IRC::Plugin::NickServID;
use App::FonBot::Plugin::Config qw/$oftc_enabled $oftc_nick @oftc_channels $oftc_nickserv_password/;
##################################################
sub _start{
return unless $oftc_enabled;
my $self=$_[OBJECT];
$self->{irc} = POE::Component::IRC->spawn(
Nick => $oftc_nick,
Username => $oftc_nick,
lib/App/FonBot/Plugin/OFTC.pm view on Meta::CPAN
);
$self->{irc}->yield(register => qw/msg/);
$self->{irc}->yield(connect => {});
$self->{irc}->plugin_add(Connector => POE::Component::IRC::Plugin::Connector->new);
$self->{irc}->plugin_add(AutoJoin => POE::Component::IRC::Plugin::AutoJoin->new(
Channels => \@oftc_channels
));
$self->{irc}->plugin_add(NickServID => POE::Component::IRC::Plugin::NickServID->new(
Password => $oftc_nickserv_password
));
$_[KERNEL]->alias_set('OFTC');
}
1;
__END__
=head1 NAME
lib/App/FonBot/Plugin/OFTC.pm view on Meta::CPAN
=head1 SYNOPSIS
use App::FonBot::Plugin::OFTC;
App::FonBot::Plugin::OFTC->init;
END {App::FonBot::Plugin::OFTC->fini};
=head1 DESCRIPTION
This is one of the two implementations of C<App::FonBot::Plugin::IRC>. It connects to OFTC, joins C<$oftc_channel>, identifies with NickServ using the C<$oftc_nickserv_password> password, and processes received commands.
=head1 CONFIGURATION VARIABLES
These are the L<App::FonBot::Plugin::Config> configuration variables used in this module
=over
=item C<$oftc_enabled>
If false, the OFTC plugin is disabled.
=item C<$oftc_nick>
IRC nickname.
=item C<@oftc_channels>
List of channels to join.
=item C<$oftc_nickserv_password>
Password to identify to NickServ with.
=back
=head1 AUTHOR
Marius Gavrilescu C<< <marius@ieval.ro> >>
=head1 COPYRIGHT AND LICENSE