mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-23 03:02:47 +01:00
Add SSL support, and other misc updates
This commit is contained in:
parent
abd9fafb87
commit
dc52430044
@ -540,8 +540,8 @@ sub check_nickserv_accounts {
|
||||
}
|
||||
|
||||
foreach my $baninfo (@bans) {
|
||||
$self->{pbot}->logger->log("anti-flood: [check-bans] $account_mask evaded $baninfo->{banmask} banned in $baninfo->{channel} by $baninfo->{owner}\n");
|
||||
$self->{pbot}->conn->privmsg($nick, "You have been banned in $baninfo->{channel} for attempting to evade a ban on $baninfo->{banmask} set by $baninfo->{owner}");
|
||||
$self->{pbot}->logger->log("anti-flood: [check-bans] $account_mask may have evaded $baninfo->{banmask} banned in $baninfo->{channel} by $baninfo->{owner}\n");
|
||||
#$self->{pbot}->conn->privmsg($nick, "You have been banned in $baninfo->{channel} for attempting to evade a ban on $baninfo->{banmask} set by $baninfo->{owner}");
|
||||
|
||||
$account_mask =~ m/[^!]+\!(.*)/;
|
||||
my $banmask = "*!$1";
|
||||
|
@ -693,7 +693,7 @@ sub factfind {
|
||||
chop $text;
|
||||
return "found one factoid submitted for " . ($last_chan eq '.*' ? 'global channel' : $last_chan) . " " . $argtype . ": '$last_trigger' is '" . $factoids->{$last_chan}->{$last_trigger}->{action} . "'";
|
||||
} else {
|
||||
return "$i factoids " . $argtype . ": $text" unless $i == 0;
|
||||
return "found $i factoids " . $argtype . ": $text" unless $i == 0;
|
||||
|
||||
my $chans = (defined $channel ? ($channel eq '.*' ? 'global channel' : $channel) : 'any channels');
|
||||
return "No factoids " . $argtype . " submitted for $chans";
|
||||
|
@ -129,7 +129,7 @@ sub execute_module {
|
||||
Carp::croak("Could not chdir to '$module_dir': $!");
|
||||
}
|
||||
|
||||
print "module arguments: [$arguments]\n";
|
||||
# print "module arguments: [$arguments]\n";
|
||||
|
||||
if(defined $tonick) {
|
||||
$self->{pbot}->logger->log("($from): $nick!$user\@$host) sent to $tonick\n");
|
||||
|
@ -207,7 +207,7 @@ sub interpreter {
|
||||
my ($result, $channel);
|
||||
my $pbot = $self->{pbot};
|
||||
|
||||
return undef if not length $keyword;
|
||||
return undef if not length $keyword or $count > 5;
|
||||
|
||||
$from = lc $from;
|
||||
|
||||
@ -253,13 +253,13 @@ sub interpreter {
|
||||
|
||||
# if multiple channels have this keyword, then ask user to disambiguate
|
||||
if($found > 1) {
|
||||
return $ref_from . "Ambiguous keyword '$original_keyword' exists in multiple locations (use 'fact <location> <keyword>' to choose one): $chans";
|
||||
return $ref_from . "Ambiguous keyword '$original_keyword' exists in multiple channels (use 'fact <channel> <keyword>' to choose one): $chans";
|
||||
}
|
||||
# if there's just one other channel that has this keyword, trigger that instance
|
||||
elsif($found == 1) {
|
||||
$pbot->logger->log("Found '$original_keyword' as '$fwd_trig' in [$fwd_chan]\n");
|
||||
|
||||
return $pbot->factoids->interpreter($from, $nick, $user, $host, $count, $fwd_trig, $arguments, $tonick, $fwd_chan);
|
||||
return $pbot->factoids->interpreter($from, $nick, $user, $host, ++$count, $fwd_trig, $arguments, $tonick, $fwd_chan);
|
||||
}
|
||||
# otherwise keyword hasn't been found, display similiar matches for all channels
|
||||
else {
|
||||
@ -270,7 +270,7 @@ sub interpreter {
|
||||
|
||||
# found factfind matches
|
||||
if($matches !~ m/^No factoids/) {
|
||||
return "No such factoid '$original_keyword'; found $matches";
|
||||
return "No such factoid '$original_keyword'; $matches";
|
||||
}
|
||||
|
||||
# otherwise find levenshtein closest matches from all channels
|
||||
|
@ -50,6 +50,8 @@ my %autoloaded = ( 'ircname' => undef,
|
||||
'hostname' => undef,
|
||||
'pacing' => undef,
|
||||
'ssl' => undef,
|
||||
'ssl_ca_path' => undef,
|
||||
'ssl_ca_file' => undef,
|
||||
);
|
||||
|
||||
# This hash will contain any global default handlers that the user specifies.
|
||||
@ -77,6 +79,8 @@ sub new {
|
||||
_lastsl => 0,
|
||||
_pacing => 0, # no pacing by default
|
||||
_ssl => 0, # no ssl by default
|
||||
_ssl_ca_path => undef,
|
||||
_ssl_ca_file => undef,
|
||||
_format => { 'default' => "[%f:%t] %m <%d>", },
|
||||
};
|
||||
|
||||
@ -228,6 +232,8 @@ sub connect {
|
||||
$self->username($arg{'Username'}) if exists $arg{'Username'};
|
||||
$self->pacing($arg{'Pacing'}) if exists $arg{'Pacing'};
|
||||
$self->ssl($arg{'SSL'}) if exists $arg{'SSL'};
|
||||
$self->ssl_ca_path($arg{'SSL_ca_path'}) if exists $arg{'SSL_ca_path'};
|
||||
$self->ssl_ca_file($arg{'SSL_ca_file'}) if exists $arg{'SSL_ca_file'};
|
||||
}
|
||||
|
||||
# Lots of error-checking claptrap first...
|
||||
@ -261,11 +267,30 @@ sub connect {
|
||||
if($self->ssl) {
|
||||
require IO::Socket::SSL;
|
||||
|
||||
$self->socket(IO::Socket::SSL->new(PeerAddr => $self->server,
|
||||
PeerPort => $self->port,
|
||||
Proto => "tcp",
|
||||
LocalAddr => $self->hostname,
|
||||
));
|
||||
if($self->ssl_ca_file) {
|
||||
$self->socket(IO::Socket::SSL->new(PeerAddr => $self->server,
|
||||
PeerPort => $self->port,
|
||||
Proto => "tcp",
|
||||
LocalAddr => $self->hostname,
|
||||
SSL_verify_mode => IO::Socket::SSL->SSL_VERIFY_PEER,
|
||||
SSL_ca_file => $self->ssl_ca_file,
|
||||
));
|
||||
} elsif($self->ssl_ca_path) {
|
||||
$self->socket(IO::Socket::SSL->new(PeerAddr => $self->server,
|
||||
PeerPort => $self->port,
|
||||
Proto => "tcp",
|
||||
LocalAddr => $self->hostname,
|
||||
SSL_verify_mode => IO::Socket::SSL->SSL_VERIFY_PEER,
|
||||
SSL_ca_path => $self->ssl_ca_path,
|
||||
));
|
||||
} else {
|
||||
$self->socket(IO::Socket::SSL->new(PeerAddr => $self->server,
|
||||
PeerPort => $self->port,
|
||||
Proto => "tcp",
|
||||
LocalAddr => $self->hostname,
|
||||
));
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$self->socket(IO::Socket::INET->new(PeerAddr => $self->server,
|
||||
|
19
PBot/PBot.pm
19
PBot/PBot.pm
@ -74,6 +74,10 @@ sub initialize {
|
||||
$self->{module_dir} = delete $conf{module_dir} // "$ENV{HOME}/pbot/modules";
|
||||
|
||||
$self->{ircserver} = delete $conf{ircserver} // "irc.freenode.net";
|
||||
$self->{port} = delete $conf{port} // 6667;
|
||||
$self->{SSL} = delete $conf{SSL} // 0;
|
||||
$self->{SSL_ca_file} = delete $conf{SSL_ca_file} // undef;
|
||||
$self->{SSL_ca_path} = delete $conf{SSL_ca_path} // undef;
|
||||
$self->{botnick} = delete $conf{botnick} // "pbot3";
|
||||
$self->{username} = delete $conf{username} // "pbot3";
|
||||
$self->{ircname} = delete $conf{ircname} // "http://code.google.com/p/pbot2-pl/";
|
||||
@ -171,12 +175,15 @@ sub connect {
|
||||
$self->logger->log("Connecting to $server ...\n");
|
||||
|
||||
$self->conn($self->irc->newconn(
|
||||
Nick => $self->{botnick},
|
||||
Username => $self->{username},
|
||||
Ircname => $self->{ircname},
|
||||
Server => $server,
|
||||
Port => $self->{port}))
|
||||
or Carp::croak "$0: Can't connect to IRC server.\n";
|
||||
Nick => $self->{botnick},
|
||||
Username => $self->{username},
|
||||
Ircname => $self->{ircname},
|
||||
Server => $server,
|
||||
SSL => $self->{SSL},
|
||||
SSL_ca_file => $self->{SSL_ca_file},
|
||||
SSL_ca_path => $self->{SSL_ca_path},
|
||||
Port => $self->{port}))
|
||||
or Carp::croak "$0: Can't connect to IRC server.\n";
|
||||
|
||||
$self->{connected} = 1;
|
||||
|
||||
|
@ -13,8 +13,8 @@ use warnings;
|
||||
# These are set automatically by the build/commit script
|
||||
use constant {
|
||||
BUILD_NAME => "PBot",
|
||||
BUILD_REVISION => 403,
|
||||
BUILD_DATE => "2013-02-12",
|
||||
BUILD_REVISION => 404,
|
||||
BUILD_DATE => "2013-02-24",
|
||||
};
|
||||
|
||||
1;
|
||||
|
@ -12,7 +12,7 @@ my $RESULTS_SPECIFIED = 2;
|
||||
my $search = join ' ', @ARGV;
|
||||
|
||||
if(not length $search) {
|
||||
print "Usage: c11std [-list] [-n#] [-section <section>] [search text] -- 'section' must be in the form of X.YpZ where X and Y are section/chapter and, optionally, Z is paragraph. If both 'section' and 'search text' are specified, then the search space will be within the specified section. You may use -n # to skip to the #th match. To list only the section numbers containing 'search text', add -list.\n";
|
||||
print "Usage: c11std [-list] [-n#] [-section <section>] [search text] -- 'section' must be in the form of X.YpZ where X and Y are section/chapter and, optionally, pZ is paragraph. If both 'section' and 'search text' are specified, then the search space will be within the specified section. You may use -n # to skip to the #th match. To list only the section numbers containing 'search text', add -list.\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ my $RESULTS_SPECIFIED = 2;
|
||||
my $search = join ' ', @ARGV;
|
||||
|
||||
if(not length $search) {
|
||||
print "Usage: c99std [-list] [-n#] [-section <section>] [search text] -- 'section' must be in the form of X.YpZ where X and Y are section/chapter and, optionally, Z is paragraph. If both 'section' and 'search text' are specified, then the search space will be within the specified section. You may use -n # to skip to the #th match. To list only the section numbers containing 'search text', add -list.\n";
|
||||
print "Usage: c99std [-list] [-n#] [-section <section>] [search text] -- 'section' must be in the form of X.YpZ where X and Y are section/chapter and, optionally, pZ is paragraph. If both 'section' and 'search text' are specified, then the search space will be within the specified section. You may use -n # to skip to the #th match. To list only the section numbers containing 'search text', add -list.\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ my $RESULTS_SPECIFIED = 2;
|
||||
my $search = join ' ', @ARGV;
|
||||
|
||||
if(not length $search) {
|
||||
print "Usage: cstd [-list] [-n#] [-section <section>] [search text] -- 'section' must be in the form of X.YpZ where X and Y are section/chapter and, optionally, Z is paragraph. If both 'section' and 'search text' are specified, then the search space will be within the specified section. You may use -n # to skip to the #th match. To list only the section numbers containing 'search text', add -list.\n";
|
||||
print "Usage: cstd [-list] [-n#] [-section <section>] [search text] -- 'section' must be in the form of X.YpZ where X and Y are section/chapter and, optionally, pZ is paragraph. If both 'section' and 'search text' are specified, then the search space will be within the specified section. You may use -n # to skip to the #th match. To list only the section numbers containing 'search text', add -list.\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
|
18
pbot.pl
18
pbot.pl
@ -26,6 +26,21 @@ my %config = (
|
||||
# IRC server address to connect to
|
||||
ircserver => 'irc.freenode.net',
|
||||
|
||||
# IRC port
|
||||
port => '6667',
|
||||
|
||||
# Use SSL? 0 = disabled, 1 = enabled
|
||||
# Note that you may need to use a specific port for SSL; e.g., freenode uses 6697 or 7000 for SSL
|
||||
# Uncomment SSL_ca_path or SSL_ca_file below to enable SSL verification (will still work without
|
||||
# verification, but will be susceptible to man-in-the-middle attacks)
|
||||
SSL => 0,
|
||||
|
||||
# SSL CA certificates path; e.g., linux: /etc/ssl/certs
|
||||
# SSL_ca_path => '/etc/ssl/certs',
|
||||
|
||||
# SSL CA file, if SSL_ca_path will not do; e.g., OpenBSD: /etc/ssl/cert.pem
|
||||
# SSL_ca_file => '/etc/ssl/cert.pem',
|
||||
|
||||
# IRC nick (what people see when you talk in channels)
|
||||
# (must be a nick registered with a NickServ account for channel auto-join to work)
|
||||
botnick => 'pbot3',
|
||||
@ -62,6 +77,9 @@ my %config = (
|
||||
# You shouldn't need to change anything below this line.
|
||||
# -----------------------------------------------------
|
||||
|
||||
# Maximum messages to remember per nick/hostmask
|
||||
MAX_NICK_MESSAGES => 256,
|
||||
|
||||
# Path to data directory
|
||||
data_dir => "$bothome/data",
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user