3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-23 19:22:40 +01:00

Add ircd config mapping; automatically unban certain types of bans after 7 days

This commit is contained in:
Pragmatic Software 2017-05-21 02:20:44 -07:00
parent 35b1c13012
commit 2d85b14b2e
2 changed files with 45 additions and 0 deletions

View File

@ -79,6 +79,23 @@ sub on_banlist_entry {
$self->{pbot}->{logger}->log("ban-tracker: [banlist entry] $channel: $target banned by $source $ago.\n");
$self->{banlist}->{$channel}->{'+b'}->{$target} = [ $source, $timestamp ];
if ($target =~ m/^\*!\*@/ or $target =~ m/^\*!.*\@gateway\/web/i) {
my $timeout = 60 * 60 * 24 * 7;
if ($target =~ m/\// and $target !~ m/\@gateway/) {
$timeout = 0; # permanent bans for cloaks that aren't gateway
}
if ($timeout && $self->{pbot}->{chanops}->can_gain_ops($channel)) {
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}->save;
}
}
}
return 0;
}

View File

@ -50,6 +50,7 @@ sub initialize {
$self->{pbot}->{event_dispatcher}->register_handler('irc.nicknameinuse', sub { $self->on_nicknameinuse(@_) });
$self->{pbot}->{event_dispatcher}->register_handler('irc.invite', sub { $self->on_invite(@_) });
$self->{pbot}->{event_dispatcher}->register_handler('irc.cap', sub { $self->on_cap(@_) });
$self->{pbot}->{event_dispatcher}->register_handler('irc.map', sub { $self->on_map(@_) });
}
sub default_handler {
@ -216,6 +217,18 @@ sub on_mode {
$self->{pbot}->{chanops}->{unban_timeout}->hash->{$channel}->{$target}{timeout} = gettimeofday + $self->{pbot}->{registry}->get_value('bantracker', 'chanserv_ban_timeout');
$self->{pbot}->{chanops}->{unban_timeout}->save;
}
} elsif ($target =~ m/^\*!\*@/ or $target =~ m/^\*!.*\@gateway\/web/i) {
my $timeout = 60 * 60 * 24 * 7;
if ($target =~ m/\// and $target !~ m/\@gateway/) {
$timeout = 0; # permanent bans for cloaks that aren't gateway
}
if ($timeout && $self->{pbot}->{chanops}->can_gain_ops($channel)) {
$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}->save;
}
}
}
elsif($mode eq "+q") {
@ -350,6 +363,21 @@ sub on_departure {
return 0;
}
sub on_map {
my ($self, $event_type, $event) = @_;
# remove and discard first and last elements
shift @{ $event->{event}->{args} };
pop @{ $event->{event}->{args} };
foreach my $arg (@{ $event->{event}->{args} }) {
my ($key, $value) = split /=/, $arg;
$self->{pbot}->{ircd}->{$key} = $value;
$self->{pbot}->{logger}->log(" $key\n") if not defined $value;
$self->{pbot}->{logger}->log(" $key=$value\n") if defined $value;
}
}
sub on_cap {
my ($self, $event_type, $event) = @_;