mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-29 23:39:24 +01:00
Quotegrabs: added more information to getq (grab owner and timestamp)
Interpreter: remove leading and trailing whitespace from text to improve parsing AntiFlood: Remove some log output, improve some other log output
This commit is contained in:
parent
df42b242e4
commit
314eabaf3e
@ -94,7 +94,6 @@ sub add_message {
|
|||||||
if($mode == $self->{FLOOD_JOIN}) {
|
if($mode == $self->{FLOOD_JOIN}) {
|
||||||
if($text =~ /^JOIN/) {
|
if($text =~ /^JOIN/) {
|
||||||
$self->message_history->{$account}->{channels}->{$channel}{join_watch}++;
|
$self->message_history->{$account}->{channels}->{$channel}{join_watch}++;
|
||||||
$self->{pbot}->logger->log("$account $channel joinwatch adjusted: " . $self->message_history->{$account}->{channels}->{$channel}{join_watch} . "\n");
|
|
||||||
} else {
|
} else {
|
||||||
# PART or QUIT
|
# PART or QUIT
|
||||||
# check QUIT message for netsplits, and decrement joinwatch if found
|
# check QUIT message for netsplits, and decrement joinwatch if found
|
||||||
@ -204,7 +203,7 @@ sub check_flood {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($max_messages > 0 and $length >= $max_messages) {
|
if($max_messages > 0 and $length >= $max_messages) {
|
||||||
$self->{pbot}->logger->log("More than $max_messages messages, comparing time differences ($max_time)\n") if $mode == $self->{FLOOD_JOIN};
|
# $self->{pbot}->logger->log("More than $max_messages messages, comparing time differences ($max_time)\n") if $mode == $self->{FLOOD_JOIN};
|
||||||
|
|
||||||
my %msg;
|
my %msg;
|
||||||
if($mode == $self->{FLOOD_CHAT}) {
|
if($mode == $self->{FLOOD_CHAT}) {
|
||||||
@ -213,9 +212,9 @@ sub check_flood {
|
|||||||
elsif($mode == $self->{FLOOD_JOIN}) {
|
elsif($mode == $self->{FLOOD_JOIN}) {
|
||||||
my $count = 0;
|
my $count = 0;
|
||||||
my $i = $length - 1;
|
my $i = $length - 1;
|
||||||
$self->{pbot}->logger->log("Checking flood history, i = $i\n") if $self->message_history->{$account}->{channels}->{$channel}{join_watch} >= $max_messages;
|
# $self->{pbot}->logger->log("Checking flood history, i = $i\n") if $self->message_history->{$account}->{channels}->{$channel}{join_watch} >= $max_messages;
|
||||||
for(; $i >= 0; $i--) {
|
for(; $i >= 0; $i--) {
|
||||||
$self->{pbot}->logger->log($i . " " . $self->message_history->{$account}->{channels}->{$channel}{messages}->[$i]{mode} ." " . $self->message_history->{$account}->{channels}->{$channel}{messages}->[$i]{msg} . " " . $self->message_history->{$account}->{channels}->{$channel}{messages}->[$i]{timestamp} . " [" . ago_exact(time - $self->message_history->{$account}->{channels}->{$channel}{messages}->[$i]{timestamp}) . "]\n") if $self->message_history->{$account}->{channels}->{$channel}{join_watch} >= $max_messages;
|
# $self->{pbot}->logger->log($i . " " . $self->message_history->{$account}->{channels}->{$channel}{messages}->[$i]{mode} ." " . $self->message_history->{$account}->{channels}->{$channel}{messages}->[$i]{msg} . " " . $self->message_history->{$account}->{channels}->{$channel}{messages}->[$i]{timestamp} . " [" . ago_exact(time - $self->message_history->{$account}->{channels}->{$channel}{messages}->[$i]{timestamp}) . "]\n") if $self->message_history->{$account}->{channels}->{$channel}{join_watch} >= $max_messages;
|
||||||
next if $self->message_history->{$account}->{channels}->{$channel}{messages}->[$i]{mode} != $self->{FLOOD_JOIN};
|
next if $self->message_history->{$account}->{channels}->{$channel}{messages}->[$i]{mode} != $self->{FLOOD_JOIN};
|
||||||
last if ++$count >= 4;
|
last if ++$count >= 4;
|
||||||
}
|
}
|
||||||
@ -406,8 +405,9 @@ sub check_nickserv_accounts {
|
|||||||
my $baninfo = $self->{pbot}->bantracker->get_baninfo($mask);
|
my $baninfo = $self->{pbot}->bantracker->get_baninfo($mask);
|
||||||
|
|
||||||
if(defined $baninfo) {
|
if(defined $baninfo) {
|
||||||
$self->{pbot}->logger->log("anti-flood: [check-bans] $mask is banned in $baninfo->{channel} by $baninfo->{owner}\n");
|
$self->{pbot}->logger->log("anti-flood: [check-bans] $mask evaded $baninfo->{banmask} banned in $baninfo->{channel} by $baninfo->{owner}\n");
|
||||||
push @banned_channels, $baninfo->{channel};
|
push @banned_channels, $baninfo->{channel};
|
||||||
|
$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}");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,9 @@ sub process_line {
|
|||||||
|
|
||||||
$from = lc $from if defined $from;
|
$from = lc $from if defined $from;
|
||||||
|
|
||||||
|
$text =~ s/^\s+//;
|
||||||
|
$text =~ s/\s+$//;
|
||||||
|
|
||||||
my $pbot = $self->pbot;
|
my $pbot = $self->pbot;
|
||||||
|
|
||||||
$pbot->antiflood->check_flood($from, $nick, $user, $host, $text, $pbot->{MAX_FLOOD_MESSAGES}, 10, $pbot->antiflood->{FLOOD_CHAT}) if defined $from;
|
$pbot->antiflood->check_flood($from, $nick, $user, $host, $text, $pbot->{MAX_FLOOD_MESSAGES}, 10, $pbot->antiflood->{FLOOD_CHAT}) if defined $from;
|
||||||
|
@ -12,6 +12,8 @@ use vars qw($VERSION);
|
|||||||
$VERSION = $PBot::PBot::VERSION;
|
$VERSION = $PBot::PBot::VERSION;
|
||||||
|
|
||||||
use HTML::Entities;
|
use HTML::Entities;
|
||||||
|
use Time::Duration;
|
||||||
|
use Time::HiRes qw(gettimeofday);
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
if(ref($_[1]) eq 'HASH') {
|
if(ref($_[1]) eq 'HASH') {
|
||||||
@ -46,7 +48,7 @@ sub initialize {
|
|||||||
#-------------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------------
|
||||||
$pbot->commands->register(sub { $self->grab_quotegrab(@_) }, "grab", 0);
|
$pbot->commands->register(sub { $self->grab_quotegrab(@_) }, "grab", 0);
|
||||||
$pbot->commands->register(sub { $self->show_quotegrab(@_) }, "getq", 0);
|
$pbot->commands->register(sub { $self->show_quotegrab(@_) }, "getq", 0);
|
||||||
$pbot->commands->register(sub { $self->delete_quotegrab(@_) }, "delq", 0);
|
$pbot->commands->register(sub { $self->delete_quotegrab(@_) }, "delq", 10);
|
||||||
$pbot->commands->register(sub { $self->show_random_quotegrab(@_) }, "rq", 0);
|
$pbot->commands->register(sub { $self->show_random_quotegrab(@_) }, "rq", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,7 +263,9 @@ sub show_quotegrab {
|
|||||||
}
|
}
|
||||||
|
|
||||||
my $quotegrab = $self->{quotegrabs}[$arguments - 1];
|
my $quotegrab = $self->{quotegrabs}[$arguments - 1];
|
||||||
return "$arguments: <$quotegrab->{nick}> $quotegrab->{text}";
|
my $timestamp = $quotegrab->{timestamp};
|
||||||
|
my $ago = ago(gettimeofday - $timestamp);
|
||||||
|
return "$arguments: grabbed by $quotegrab->{grabbed_by} on " . localtime($timestamp) . " [$ago] <$quotegrab->{nick}> $quotegrab->{text}";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub show_random_quotegrab {
|
sub show_random_quotegrab {
|
||||||
|
@ -13,8 +13,8 @@ use warnings;
|
|||||||
# These are set automatically by the build/commit script
|
# These are set automatically by the build/commit script
|
||||||
use constant {
|
use constant {
|
||||||
BUILD_NAME => "PBot",
|
BUILD_NAME => "PBot",
|
||||||
BUILD_REVISION => 322,
|
BUILD_REVISION => 323,
|
||||||
BUILD_DATE => "2011-10-31",
|
BUILD_DATE => "2011-12-03",
|
||||||
};
|
};
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
Loading…
Reference in New Issue
Block a user