3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-24 11:42:35 +01:00

Temp bans/mutes now track owner and reason for checkban/checkmute

This commit is contained in:
Pragmatic Software 2019-07-26 14:17:06 -07:00
parent 3756151c8f
commit 167edf8d95
4 changed files with 32 additions and 12 deletions

View File

@ -509,7 +509,7 @@ sub check_flood {
my $banmask = address_to_mask($host);
if ($self->{pbot}->{channels}->is_active_op("${channel}-floodbans")) {
$self->{pbot}->{chanops}->ban_user_timed("*!$user\@$banmask\$##stop_join_flood", $channel . '-floodbans', $timeout);
$self->{pbot}->{chanops}->ban_user_timed($self->{pbot}->{registry}->get_value('irc', 'botnick'), 'join flooding', "*!$user\@$banmask\$##stop_join_flood", $channel . '-floodbans', $timeout);
$self->{pbot}->{logger}->log("$nick!$user\@$banmask banned for $duration due to join flooding (offense #" . $channel_data->{offenses} . ").\n");
$self->{pbot}->{conn}->privmsg($nick, "You have been banned from $channel due to join flooding. If your connection issues have been fixed, or this was an accident, you may request an unban at any time by responding to this message with `unbanme`, otherwise you will be automatically unbanned in $duration.");
} else {
@ -535,7 +535,7 @@ sub check_flood {
if ($self->{pbot}->{registry}->get_value('antiflood', 'enforce')) {
my $length = $self->{pbot}->{registry}->get_array_value('antiflood', 'chat_flood_punishment', $channel_data->{offenses} - 1);
$self->{pbot}->{chanops}->ban_user_timed("*!$user\@" . address_to_mask($host), $channel, $length);
$self->{pbot}->{chanops}->ban_user_timed($self->{pbot}->{registry}->get_value('irc', 'botnick'), 'chat flooding', "*!$user\@" . address_to_mask($host), $channel, $length);
$length = duration($length);
$self->{pbot}->{logger}->log("$nick $channel flood offense " . $channel_data->{offenses} . " earned $length ban\n");
$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 approximately $length.");
@ -570,7 +570,7 @@ sub check_flood {
if ($self->{pbot}->{registry}->get_value('antiflood', 'enforce')) {
my $length = $self->{pbot}->{registry}->get_array_value('antiflood', 'nick_flood_punishment', $self->{nickflood}->{$ancestor}->{offenses} - 1);
$self->{pbot}->{chanops}->ban_user_timed("*!$user\@" . address_to_mask($host), $channel, $length);
$self->{pbot}->{chanops}->ban_user_timed($self->{pbot}->{registry}->get_value('irc', 'botnick'), 'nick flooding', "*!$user\@" . address_to_mask($host), $channel, $length);
$length = duration($length);
$self->{pbot}->{logger}->log("$nick nickchange flood offense " . $self->{nickflood}->{$ancestor}->{offenses} . " earned $length ban\n");
$self->{pbot}->{conn}->privmsg($nick, "You have been temporarily banned due to nick-change flooding. You will be unbanned in $length.");
@ -609,7 +609,7 @@ sub check_flood {
my $offenses = $channel_data->{enter_abuses} - $enter_abuse_max_offenses + 1 + $other_offenses;
my $ban_length = $self->{pbot}->{registry}->get_array_value('antiflood', 'enter_abuse_punishment', $offenses - 1);
$self->{pbot}->{chanops}->ban_user_timed("*!$user\@" . address_to_mask($host), $channel, $ban_length);
$self->{pbot}->{chanops}->ban_user_timed($self->{pbot}->{registry}->get_value('irc', 'botnick'), 'enter abuse', "*!$user\@" . address_to_mask($host), $channel, $ban_length);
$ban_length = duration($ban_length);
$self->{pbot}->{logger}->log("$nick $channel enter abuse offense " . $channel_data->{enter_abuses} . " earned $ban_length ban\n");
$self->{pbot}->{conn}->privmsg($nick, "You have been muted due to abusing the enter key. Please do not split your sentences over multiple messages. You will be allowed to speak again in approximately $ban_length.");
@ -1001,7 +1001,7 @@ sub check_bans {
$owner =~ s/!.*$//;
$self->{pbot}->{chanops}->add_op_command($baninfo->{channel}, "kick $baninfo->{channel} $bannick Evaded $baninfo->{banmask} set by $owner");
}
$self->{pbot}->{chanops}->ban_user_timed($banmask, $baninfo->{channel}, 60 * 60 * 24 * 14);
$self->{pbot}->{chanops}->ban_user_timed($self->{pbot}->{registry}->get_value('irc', 'botnick'), 'ban evasion', $banmask, $baninfo->{channel}, 60 * 60 * 24 * 14);
}
my $channel_data = $self->{pbot}->{messagehistory}->{database}->get_channel_data($message_account, $channel, 'validated');
if ($channel_data->{validated} & $self->{NICKSERV_VALIDATED}) {

View File

@ -95,6 +95,8 @@ sub on_banlist_entry {
if (not exists $self->{pbot}->{chanops}->{unban_timeout}->hash->{$channel}->{$target}) {
$self->{pbot}->{logger}->log("Temp ban for $target in $channel.\n");
$self->{pbot}->{chanops}->{unban_timeout}->hash->{$channel}->{$target}{timeout} = gettimeofday + $timeout;
$self->{pbot}->{chanops}->{unban_timeout}->hash->{$channel}->{$target}{owner} = $source;
$self->{pbot}->{chanops}->{unban_timeout}->hash->{$channel}->{$target}{reason} = 'Temp ban on *!*@... or *!...@gateway/web';
$self->{pbot}->{chanops}->{unban_timeout}->save;
}
}

View File

@ -73,9 +73,15 @@ sub checkban {
if (exists $self->{pbot}->{chanops}->{unban_timeout}->hash->{$channel}
&& exists $self->{pbot}->{chanops}->{unban_timeout}->hash->{$channel}->{$mask}) {
my $timeout = $self->{pbot}->{chanops}->{unban_timeout}->hash->{$channel}->{$mask}{timeout};
my $duration = duration($timeout - gettimeofday);
my $owner = $self->{pbot}->{chanops}->{unban_timeout}->hash->{$channel}->{$mask}{owner};
my $reason = $self->{pbot}->{chanops}->{unban_timeout}->hash->{$channel}->{$mask}{reason};
my $duration = concise duration($timeout - gettimeofday);
return "$mask has $duration remaining on their $channel ban";
my $result = "$mask banned in $channel ";
$result .= "by $owner " if defined $owner;
$result .= "for $reason " if defined $reason;
$result .= "($duration remaining)";
return $result;
} else {
return "$mask has no ban timeout";
}
@ -105,7 +111,15 @@ sub checkmute {
if (exists $self->{pbot}->{chanops}->{unmute_timeout}->hash->{$channel}
&& exists $self->{pbot}->{chanops}->{unmute_timeout}->hash->{$channel}->{$mask}) {
my $timeout = $self->{pbot}->{chanops}->{unmute_timeout}->hash->{$channel}->{$mask}{timeout};
my $duration = duration($timeout - gettimeofday);
my $timeout = $self->{pbot}->{chanops}->{unmute_timeout}->hash->{$channel}->{$mask}{timeout};
my $owner = $self->{pbot}->{chanops}->{unmute_timeout}->hash->{$channel}->{$mask}{owner};
my $reason = $self->{pbot}->{chanops}->{unmute_timeout}->hash->{$channel}->{$mask}{reason};
my $duration = concise duration($timeout - gettimeofday);
my $result = "$mask muted in $channel ";
$result .= "by $owner " if defined $owner;
$result .= "for $reason " if defined $reason;
$result .= "($duration remaining)";
return "$mask has $duration remaining on their $channel mute";
} else {
@ -173,7 +187,7 @@ sub ban_user {
$result .= "$sep$mask has $duration remaining on their $channel ban";
$sep = '; ';
} else {
$self->{pbot}->{chanops}->ban_user_timed($mask, $channel, $length, $immediately);
$self->{pbot}->{chanops}->ban_user_timed("$nick!$user\@$host", undef, $mask, $channel, $length, $immediately);
my $duration;
if ($length > 0) {
@ -304,7 +318,7 @@ sub mute_user {
$result .= "$sep$mask has $duration remaining on their $channel mute";
$sep = '; ';
} else {
$self->{pbot}->{chanops}->mute_user_timed($t, $channel, $length, $immediately);
$self->{pbot}->{chanops}->mute_user_timed("$nick!$user\@$host", undef, $t, $channel, $length, $immediately);
my $duration;
if ($length > 0) {

View File

@ -220,7 +220,7 @@ sub unban_user {
sub ban_user_timed {
my $self = shift;
my ($mask, $channel, $length, $immediately) = @_;
my ($owner, $reason, $mask, $channel, $length, $immediately) = @_;
$channel = lc $channel;
$mask = lc $mask;
@ -230,6 +230,8 @@ sub ban_user_timed {
if ($length > 0) {
$self->{unban_timeout}->hash->{$channel}->{$mask}{timeout} = gettimeofday + $length;
$self->{unban_timeout}->hash->{$channel}->{$mask}{owner} = $owner if defined $owner;
$self->{unban_timeout}->hash->{$channel}->{$mask}{reason} = $reason if defined $reason;
$self->{unban_timeout}->save;
} else {
if ($self->{pbot}->{chanops}->{unban_timeout}->find_index($channel, $mask)) {
@ -259,7 +261,7 @@ sub unmute_user {
sub mute_user_timed {
my $self = shift;
my ($mask, $channel, $length, $immediately) = @_;
my ($owner, $reason, $mask, $channel, $length, $immediately) = @_;
$channel = lc $channel;
$mask = lc $mask;
@ -269,6 +271,8 @@ sub mute_user_timed {
if ($length > 0) {
$self->{unmute_timeout}->hash->{$channel}->{$mask}{timeout} = gettimeofday + $length;
$self->{unmute_timeout}->hash->{$channel}->{$mask}{owner} = $owner if defined $owner;
$self->{unmute_timeout}->hash->{$channel}->{$mask}{reason} = $reason if defined $reason;
$self->{unmute_timeout}->save;
} else {
if ($self->{pbot}->{chanops}->{unmute_timeout}->find_index($channel, $mask)) {