mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-23 11:12:42 +01:00
Remove old ChanServ ban method and rename all quiet-related terms to ban-related terms since quiet now does +b instead of +q
This commit is contained in:
parent
e3b351946a
commit
e32850aae2
@ -2,7 +2,7 @@
|
||||
# Author: pragma_
|
||||
#
|
||||
# Purpose: Keeps track of which nick has said what and when. Used in
|
||||
# conjunction with OperatorStuff and Quotegrabs for kick/quiet on flood
|
||||
# conjunction with OperatorStuff and Quotegrabs for kick/ban on flood
|
||||
# and grabbing quotes, respectively.
|
||||
|
||||
package PBot::AntiFlood;
|
||||
@ -173,7 +173,7 @@ sub check_flood {
|
||||
|
||||
my $banmask = address_to_mask($host);
|
||||
|
||||
$self->{pbot}->chanops->quiet_user_timed("*!$user\@$banmask\$##fix_your_connection", $channel, $timeout * 60 * 60);
|
||||
$self->{pbot}->chanops->ban_user_timed("*!$user\@$banmask\$##fix_your_connection", $channel, $timeout * 60 * 60);
|
||||
|
||||
$self->{pbot}->logger->log("$nick!$user\@$banmask banned for $timeout hours due to join flooding (offense #${ $self->message_history }{$account}{$channel}{offenses}).\n");
|
||||
|
||||
@ -190,11 +190,11 @@ sub check_flood {
|
||||
${ $self->message_history }{$account}{$channel}{offenses}++;
|
||||
my $length = ${ $self->message_history }{$account}{$channel}{offenses} ** ${ $self->message_history }{$account}{$channel}{offenses} * ${ $self->message_history }{$account}{$channel}{offenses} * 30;
|
||||
if($channel =~ /^#/) { #channel flood (opposed to private message or otherwise)
|
||||
return if exists $self->{pbot}->chanops->{quieted_masks}->{"*!*\@$host"};
|
||||
return if exists $self->{pbot}->chanops->{unban_timeout}->{"*!*\@$host"};
|
||||
if($mode == $self->{FLOOD_CHAT}) {
|
||||
$self->{pbot}->chanops->quiet_user_timed("*!$user\@$host", $channel, $length);
|
||||
$self->{pbot}->chanops->ban_user_timed("*!$user\@$host", $channel, $length);
|
||||
|
||||
$self->{pbot}->logger->log("$nick $channel flood offense ${ $self->message_history }{$account}{$channel}{offenses} earned $length second quiet\n");
|
||||
$self->{pbot}->logger->log("$nick $channel flood offense ${ $self->message_history }{$account}{$channel}{offenses} earned $length second ban\n");
|
||||
|
||||
if($length < 1000) {
|
||||
$length = "$length seconds";
|
||||
@ -202,7 +202,7 @@ sub check_flood {
|
||||
$length = "a little while";
|
||||
}
|
||||
|
||||
$self->{pbot}->conn->privmsg($nick, "You have been quieted due to flooding. Please use a web paste service such as http://codepad.org for lengthy pastes. You will be allowed to speak again in $length.");
|
||||
$self->{pbot}->conn->privmsg($nick, "You have been muted due to flooding. Please use a web paste service such as http://codepad.org for lengthy pastes. You will be allowed to speak again in $length.");
|
||||
}
|
||||
} else { # private message flood
|
||||
return if exists $self->{pbot}->ignorelist->{ignore_list}->{"$nick!$user\@$host"}{$channel};
|
||||
@ -260,11 +260,11 @@ sub unbanme {
|
||||
|
||||
my $mask = "*!$user\@$banmask\$##fix_your_connection";
|
||||
|
||||
if(not exists $self->{pbot}->{chanops}->{quieted_masks}->{$mask}) {
|
||||
if(not exists $self->{pbot}->{chanops}->{unban_timeout}->{$mask}) {
|
||||
return "/msg $nick There is no temporary ban set for $mask in channel $channel.";
|
||||
}
|
||||
|
||||
if(not $self->{pbot}->chanops->{quieted_masks}->{$mask}{channel} eq $channel) {
|
||||
if(not $self->{pbot}->chanops->{unban_timeout}->{$mask}{channel} eq $channel) {
|
||||
return "/msg $nick There is no temporary ban set for $mask in channel $channel.";
|
||||
}
|
||||
|
||||
@ -283,8 +283,8 @@ sub unbanme {
|
||||
}
|
||||
|
||||
# TODO: these delete statements need to be abstracted to methods on objects
|
||||
$self->{pbot}->chanops->unquiet_user($mask, $channel);
|
||||
delete $self->{pbot}->chanops->{quieted_masks}->{$mask};
|
||||
$self->{pbot}->chanops->unban_user($mask, $channel);
|
||||
delete $self->{pbot}->chanops->{unban_timeout}->{$mask};
|
||||
delete $self->{message_history}->{$account}{$channel}{captcha};
|
||||
|
||||
return "/msg $nick You have been unbanned from $channel.";
|
||||
|
@ -35,14 +35,12 @@ sub initialize {
|
||||
|
||||
$self->{pbot} = $pbot;
|
||||
|
||||
$pbot->commands->register(sub { return $self->quiet(@_) }, "quiet", 10);
|
||||
$pbot->commands->register(sub { return $self->unquiet(@_) }, "unquiet", 10);
|
||||
$pbot->commands->register(sub { return $self->ban_user(@_) }, "ban", 10);
|
||||
$pbot->commands->register(sub { return $self->unban_user(@_) }, "unban", 10);
|
||||
$pbot->commands->register(sub { return $self->kick_user(@_) }, "kick", 10);
|
||||
$pbot->commands->register(sub { return $self->ban_user(@_) }, "ban", 10);
|
||||
$pbot->commands->register(sub { return $self->unban_user(@_) }, "unban", 10);
|
||||
$pbot->commands->register(sub { return $self->kick_user(@_) }, "kick", 10);
|
||||
}
|
||||
|
||||
sub quiet {
|
||||
sub ban_user {
|
||||
my $self = shift;
|
||||
my ($from, $nick, $user, $host, $arguments) = @_;
|
||||
my ($target, $length) = split(/\s+/, $arguments);
|
||||
@ -57,7 +55,7 @@ sub quiet {
|
||||
}
|
||||
|
||||
if(not defined $target) {
|
||||
return "/msg $nick Usage: quiet <mask> [timeout seconds (default: 3600 or 1 hour)]";
|
||||
return "/msg $nick Usage: ban <mask> [timeout seconds (default: 3600 or 1 hour)]";
|
||||
}
|
||||
|
||||
if(not defined $length) {
|
||||
@ -66,68 +64,7 @@ sub quiet {
|
||||
|
||||
return "" if $target =~ /\Q$self->{pbot}->botnick\E/i;
|
||||
|
||||
$self->{pbot}->chanops->quiet_user_timed($target, $from, $length);
|
||||
}
|
||||
|
||||
sub unquiet {
|
||||
my $self = shift;
|
||||
my ($from, $nick, $user, $host, $arguments) = @_;
|
||||
|
||||
if(not defined $from) {
|
||||
$self->{pbot}->logger->log("Command missing ~from parameter!\n");
|
||||
return "";
|
||||
}
|
||||
|
||||
my ($target, $channel) = split / /, $arguments;
|
||||
|
||||
if(not defined $target) {
|
||||
return "/msg $nick Usage: unquiet <mask> [channel]";
|
||||
}
|
||||
|
||||
$channel = $from if not defined $channel;
|
||||
|
||||
return "/msg $nick Unquiet must be used against a channel. Either use in channel, or specify !unquiet $target <channel>" if $channel !~ /^#/;
|
||||
|
||||
$self->{pbot}->chanops->unquiet_user($arguments, $from);
|
||||
delete ${ $self->{pbot}->chanops->{quieted_masks} }{$arguments};
|
||||
$self->{pbot}->conn->privmsg($arguments, "$nick has allowed you to speak again.") unless $arguments =~ /\Q$self->{pbot}->botnick\E/i;
|
||||
return "/msg $nick Done.";
|
||||
}
|
||||
|
||||
sub ban_user {
|
||||
my $self = shift;
|
||||
my ($from, $nick, $user, $host, $arguments) = @_;
|
||||
|
||||
if(not defined $from) {
|
||||
$self->{pbot}->logger->log("Command missing ~from parameter!\n");
|
||||
return "";
|
||||
}
|
||||
|
||||
if(not $from =~ /^#/) { #not a channel
|
||||
if($arguments =~ /^(#.*?) (.*?) (.*)$/) {
|
||||
$self->{pbot}->conn->privmsg("ChanServ", "AUTOREM $1 ADD $2 $3");
|
||||
unshift @{ $self->{pbot}->chanops->{op_commands} }, "kick $1 $2 Banned";
|
||||
$self->{pbot}->chanops->gain_ops($1);
|
||||
$self->{pbot}->logger->log("$nick!$user\@$host AUTOREM $2 ($3)\n");
|
||||
return "/msg $nick $2 added to auto-remove";
|
||||
} else {
|
||||
$self->{pbot}->logger->log("$nick!$user\@$host: bad format for ban in msg\n");
|
||||
return "/msg $nick Usage (in msg mode): !ban <channel> <hostmask> <reason>";
|
||||
}
|
||||
} else { #in a channel
|
||||
if($arguments =~ /^(.*?) (.*)$/) {
|
||||
$self->{pbot}->conn->privmsg("ChanServ", "AUTOREM $from ADD $1 $2");
|
||||
$self->{pbot}->logger->log("AUTOREM [$from] ADD [$1] [$2]\n");
|
||||
$self->{pbot}->logger->log("kick [$from] [$1] Banned\n");
|
||||
unshift @{ $self->{pbot}->chanops->{op_commands} }, "kick $from $1 Banned";
|
||||
$self->{pbot}->chanops->gain_ops($from);
|
||||
$self->{pbot}->logger->log("$nick ($from) AUTOREM $1 ($2)\n");
|
||||
return "/msg $nick $1 added to auto-remove";
|
||||
} else {
|
||||
$self->{pbot}->logger->log("$nick!$user\@$host: bad format for ban in channel\n");
|
||||
return "/msg $nick Usage (in channel mode): !ban <hostmask> <reason>";
|
||||
}
|
||||
}
|
||||
$self->{pbot}->chanops->ban_user_timed($target, $from, $length);
|
||||
}
|
||||
|
||||
sub unban_user {
|
||||
@ -139,26 +76,19 @@ sub unban_user {
|
||||
return "";
|
||||
}
|
||||
|
||||
if(not $from =~ /^#/) { #not a channel
|
||||
if($arguments =~ /^(#.*?) (.*)$/) {
|
||||
$self->{pbot}->conn->privmsg("ChanServ", "AUTOREM $1 DEL $2");
|
||||
unshift @{ $self->{pbot}->chanops->{op_commands} }, "mode $1 -b $2";
|
||||
$self->{pbot}->chanops->gain_ops($1);
|
||||
delete ${ $self->{pbot}->chanops->{unban_timeouts} }{$2};
|
||||
$self->{pbot}->logger->log("$nick!$user\@$host AUTOREM DEL $2 ($3)\n");
|
||||
return "/msg $nick $2 removed from auto-remove";
|
||||
} else {
|
||||
$self->{pbot}->logger->log("$nick!$user\@$host: bad format for unban in msg\n");
|
||||
return "/msg $nick Usage (in msg mode): !unban <channel> <hostmask>";
|
||||
}
|
||||
} else { #in a channel
|
||||
$self->{pbot}->conn->privmsg("ChanServ", "AUTOREM $from DEL $arguments");
|
||||
unshift @{ $self->{pbot}->chanops->{op_commands} }, "mode $from -b $arguments";
|
||||
$self->{pbot}->chanops->gain_ops($from);
|
||||
delete ${ $self->{pbot}->chanops->{unban_timeouts} }{$arguments};
|
||||
$self->{pbot}->logger->log("$nick!$user\@$host AUTOREM DEL $arguments\n");
|
||||
return "/msg $nick $arguments removed from auto-remove";
|
||||
my ($target, $channel) = split / /, $arguments;
|
||||
|
||||
if(not defined $target) {
|
||||
return "/msg $nick Usage: unban <mask> [channel]";
|
||||
}
|
||||
|
||||
$channel = $from if not defined $channel;
|
||||
|
||||
return "/msg $nick Usage for /msg: !unban $target <channel>" if $channel !~ /^#/;
|
||||
|
||||
$self->{pbot}->chanops->unban_user($arguments, $from);
|
||||
delete ${ $self->{pbot}->chanops->{unban_timeout} }{$arguments};
|
||||
return "/msg $nick $arguments has been unbanned.";
|
||||
}
|
||||
|
||||
sub kick_user {
|
||||
|
@ -34,14 +34,12 @@ sub initialize {
|
||||
}
|
||||
|
||||
$self->{pbot} = $pbot;
|
||||
$self->{quieted_masks} = {};
|
||||
$self->{unban_timeouts} = {};
|
||||
$self->{unban_timeout} = {};
|
||||
$self->{op_commands} = [];
|
||||
$self->{is_opped} = {};
|
||||
|
||||
$pbot->timer->register(sub { $self->check_opped_timeouts }, 10);
|
||||
$pbot->timer->register(sub { $self->check_quieted_timeouts }, 10);
|
||||
$pbot->timer->register(sub { $self->check_unban_timeouts }, 10);
|
||||
$pbot->timer->register(sub { $self->check_unban_timeouts }, 10);
|
||||
}
|
||||
|
||||
sub gain_ops {
|
||||
@ -82,41 +80,41 @@ sub perform_op_commands {
|
||||
$self->{pbot}->logger->log("Done.\n");
|
||||
}
|
||||
|
||||
sub quiet_user {
|
||||
sub ban_user {
|
||||
my $self = shift;
|
||||
my ($mask, $channel) = @_;
|
||||
unshift @{ $self->{op_commands} }, "mode $channel +b $mask";
|
||||
$self->gain_ops($channel);
|
||||
}
|
||||
|
||||
sub unquiet_user {
|
||||
sub unban_user {
|
||||
my $self = shift;
|
||||
my ($mask, $channel) = @_;
|
||||
unshift @{ $self->{op_commands} }, "mode $channel -b $mask";
|
||||
$self->gain_ops($channel);
|
||||
}
|
||||
|
||||
sub quiet_user_timed {
|
||||
sub ban_user_timed {
|
||||
my $self = shift;
|
||||
my ($mask, $channel, $length) = @_;
|
||||
|
||||
$self->quiet_user($mask, $channel);
|
||||
${ $self->{quieted_masks} }{$mask}{time} = gettimeofday + $length;
|
||||
${ $self->{quieted_masks} }{$mask}{channel} = $channel;
|
||||
$self->ban_user($mask, $channel);
|
||||
${ $self->{unban_timeout} }{$mask}{timeout} = gettimeofday + $length;
|
||||
${ $self->{unban_timeout} }{$mask}{channel} = $channel;
|
||||
}
|
||||
|
||||
sub check_quieted_timeouts {
|
||||
sub check_unban_timeouts {
|
||||
my $self = shift;
|
||||
my $now = gettimeofday();
|
||||
|
||||
foreach my $mask (keys %{ $self->{quieted_masks} }) {
|
||||
if($self->{quieted_masks}->{$mask}{time} < $now) {
|
||||
$self->{pbot}->logger->log("Unquieting $mask\n");
|
||||
$self->unquiet_user($mask, $self->{quieted_masks}->{$mask}{channel});
|
||||
delete $self->{quieted_masks}->{$mask};
|
||||
foreach my $mask (keys %{ $self->{unban_timeout} }) {
|
||||
if($self->{unban_timeout}->{$mask}{timeout} < $now) {
|
||||
$self->{pbot}->logger->log("Unbanning $mask\n");
|
||||
$self->unban_user($mask, $self->{unban_timeout}->{$mask}{channel});
|
||||
delete $self->{unban_timeout}->{$mask};
|
||||
} else {
|
||||
#my $timediff = $quieted_masks{$mask}{time} - $now;
|
||||
#$logger->log "quiet: $mask has $timediff seconds remaining\n"
|
||||
#my $timediff = $unban_timeout{$mask}{timeout} - $now;
|
||||
#$logger->log "ban: $mask has $timediff seconds remaining\n"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -135,20 +133,4 @@ sub check_opped_timeouts {
|
||||
}
|
||||
}
|
||||
|
||||
sub check_unban_timeouts {
|
||||
my $self = shift;
|
||||
my $now = gettimeofday();
|
||||
|
||||
foreach my $ban (keys %{ $self->{unban_timeouts} }) {
|
||||
if($self->{unban_timeouts}->{$ban}{timeout} < $now) {
|
||||
unshift @{ $self->{op_commands} }, "mode " . $self->{unban_timeout}->{$ban}{channel} . " -b $ban";
|
||||
$self->gain_ops($self->{unban_timeouts}->{$ban}{channel});
|
||||
delete $self->{unban_timeouts}->{$ban};
|
||||
} else {
|
||||
#my $timediff = $unban_timeout{$ban}{timeout} - $now;
|
||||
#$logger->log("$unban_timeout{$ban}{channel}: unban $ban in $timediff seconds\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -13,8 +13,8 @@ use warnings;
|
||||
# These are set automatically by the build/commit script
|
||||
use constant {
|
||||
BUILD_NAME => "PBot",
|
||||
BUILD_REVISION => 174,
|
||||
BUILD_DATE => "2010-06-17",
|
||||
BUILD_REVISION => 175,
|
||||
BUILD_DATE => "2010-06-18",
|
||||
};
|
||||
|
||||
1;
|
||||
|
Loading…
Reference in New Issue
Block a user