From d0ebf98441f92f5258d98f8e5a1bcae4986e028b Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Wed, 27 May 2015 10:46:30 -0700 Subject: [PATCH] Automatically unmute +q'd offenders after mute_timeout (7 days) --- PBot/BanTracker.pm | 1 + PBot/IRCHandlers.pm | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/PBot/BanTracker.pm b/PBot/BanTracker.pm index 7bcc48cf..d75a1e77 100644 --- a/PBot/BanTracker.pm +++ b/PBot/BanTracker.pm @@ -35,6 +35,7 @@ sub initialize { $self->{banlist} = {}; $self->{pbot}->{registry}->add_default('text', 'bantracker', 'chanserv_ban_timeout', '604800'); + $self->{pbot}->{registry}->add_default('text', 'bantracker', 'mute_timeout', '604800'); $self->{pbot}->{registry}->add_default('text', 'bantracker', 'debug', '0'); $self->{pbot}->{commands}->register(sub { $self->dumpbans(@_) }, "dumpbans", 60); diff --git a/PBot/IRCHandlers.pm b/PBot/IRCHandlers.pm index 5ca0c638..588c9b38 100644 --- a/PBot/IRCHandlers.pm +++ b/PBot/IRCHandlers.pm @@ -203,6 +203,14 @@ sub on_mode { } } } + elsif($mode eq "+q") { + if($nick ne $event->{conn}->nick) { + if (exists $self->{pbot}->{channels}->{channels}->hash->{$channel} and $self->{pbot}->{channels}->{channels}->hash->{$channel}{chanop}) { + $self->{pbot}->{chanops}->{unmute_timeout}->hash->{$channel}->{$target}{timeout} = gettimeofday + $self->{pbot}->{registry}->get_value('bantracker', 'mute_timeout'); + $self->{pbot}->{chanops}->{unmute_timeout}->save; + } + } + } elsif($mode eq "+e" && $channel eq $event->{conn}->nick) { foreach my $chan (keys %{ $self->{pbot}->{channels}->{channels}->hash }) { if($self->{channels}->{channels}->hash->{$chan}{enabled}) {