2010-03-22 08:33:44 +01:00
|
|
|
# File: ChanOps.pm
|
2010-03-24 07:47:40 +01:00
|
|
|
# Author: pragma_
|
2010-03-22 08:33:44 +01:00
|
|
|
#
|
|
|
|
# Purpose: Provides channel operator status tracking and commands.
|
|
|
|
|
2017-03-05 22:33:31 +01:00
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
2010-03-22 08:33:44 +01:00
|
|
|
package PBot::ChanOps;
|
|
|
|
|
|
|
|
use warnings;
|
|
|
|
use strict;
|
|
|
|
|
2014-05-18 02:27:57 +02:00
|
|
|
use PBot::ChanOpCommands;
|
2010-03-22 08:33:44 +01:00
|
|
|
use Time::HiRes qw(gettimeofday);
|
|
|
|
|
|
|
|
sub new {
|
|
|
|
if(ref($_[1]) eq 'HASH') {
|
2014-05-20 00:59:51 +02:00
|
|
|
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference");
|
2010-03-22 08:33:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
my ($class, %conf) = @_;
|
|
|
|
my $self = bless {}, $class;
|
|
|
|
$self->initialize(%conf);
|
|
|
|
return $self;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub initialize {
|
|
|
|
my ($self, %conf) = @_;
|
|
|
|
|
2014-05-20 00:59:51 +02:00
|
|
|
$self->{pbot} = delete $conf{pbot} // Carp::croak("Missing pbot reference to ChanOps");
|
2010-03-22 08:33:44 +01:00
|
|
|
|
2014-05-20 00:59:51 +02:00
|
|
|
$self->{unban_timeout} = PBot::DualIndexHashObject->new(
|
|
|
|
pbot => $self->{pbot},
|
|
|
|
name => 'Unban Timeouts',
|
|
|
|
filename => $self->{pbot}->{registry}->get_value('general', 'data_dir') . '/unban_timeouts'
|
|
|
|
);
|
2014-05-17 22:08:19 +02:00
|
|
|
|
|
|
|
$self->{unban_timeout}->load;
|
|
|
|
|
2015-05-27 19:45:43 +02:00
|
|
|
$self->{unmute_timeout} = PBot::DualIndexHashObject->new(
|
|
|
|
pbot => $self->{pbot},
|
|
|
|
name => 'Unmute Timeouts',
|
|
|
|
filename => $self->{pbot}->{registry}->get_value('general', 'data_dir') . '/unmute_timeouts'
|
|
|
|
);
|
|
|
|
|
|
|
|
$self->{unmute_timeout}->load;
|
|
|
|
|
2017-05-21 08:48:03 +02:00
|
|
|
$self->{unban_queue} = {};
|
|
|
|
|
2012-10-27 23:03:10 +02:00
|
|
|
$self->{op_commands} = {};
|
2010-03-22 08:33:44 +01:00
|
|
|
$self->{is_opped} = {};
|
2014-08-11 09:34:30 +02:00
|
|
|
$self->{op_requested} = {};
|
2010-03-22 08:33:44 +01:00
|
|
|
|
2014-05-20 00:59:51 +02:00
|
|
|
$self->{commands} = PBot::ChanOpCommands->new(pbot => $self->{pbot});
|
|
|
|
|
|
|
|
$self->{pbot}->{registry}->add_default('text', 'general', 'deop_timeout', $conf{'deop_timeout'} // 300);
|
2014-05-18 02:27:57 +02:00
|
|
|
|
2015-05-27 19:45:43 +02:00
|
|
|
$self->{pbot}->{timer}->register(sub { $self->check_opped_timeouts }, 10);
|
|
|
|
$self->{pbot}->{timer}->register(sub { $self->check_unban_timeouts }, 10);
|
|
|
|
$self->{pbot}->{timer}->register(sub { $self->check_unmute_timeouts }, 10);
|
2017-05-21 11:18:00 +02:00
|
|
|
$self->{pbot}->{timer}->register(sub { $self->check_unban_queue }, 30);
|
2010-03-23 19:24:02 +01:00
|
|
|
}
|
2010-03-22 08:33:44 +01:00
|
|
|
|
2015-06-26 05:54:38 +02:00
|
|
|
sub can_gain_ops {
|
|
|
|
my ($self, $channel) = @_;
|
2016-10-29 19:47:08 +02:00
|
|
|
$channel = lc $channel;
|
2015-06-26 05:54:38 +02:00
|
|
|
return exists $self->{pbot}->{channels}->{channels}->hash->{$channel} && $self->{pbot}->{channels}->{channels}->hash->{$channel}{chanop};
|
|
|
|
}
|
|
|
|
|
2010-03-22 08:33:44 +01:00
|
|
|
sub gain_ops {
|
|
|
|
my $self = shift;
|
|
|
|
my $channel = shift;
|
2016-10-29 19:47:08 +02:00
|
|
|
$channel = lc $channel;
|
2018-06-06 00:02:02 +02:00
|
|
|
|
2014-08-11 09:34:30 +02:00
|
|
|
return if exists $self->{op_requested}->{$channel};
|
2015-06-26 05:54:38 +02:00
|
|
|
return if not $self->can_gain_ops($channel);
|
2014-08-11 09:34:30 +02:00
|
|
|
|
2012-10-27 23:03:10 +02:00
|
|
|
if(not exists $self->{is_opped}->{$channel}) {
|
2014-05-18 22:09:05 +02:00
|
|
|
$self->{pbot}->{conn}->privmsg("chanserv", "op $channel");
|
2014-08-11 09:34:30 +02:00
|
|
|
$self->{op_requested}->{$channel} = scalar gettimeofday;
|
2010-03-22 08:33:44 +01:00
|
|
|
} else {
|
2012-10-27 23:03:10 +02:00
|
|
|
$self->perform_op_commands($channel);
|
2010-03-22 08:33:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub lose_ops {
|
|
|
|
my $self = shift;
|
|
|
|
my $channel = shift;
|
2016-10-29 19:47:08 +02:00
|
|
|
$channel = lc $channel;
|
2014-05-18 22:09:05 +02:00
|
|
|
$self->{pbot}->{conn}->privmsg("chanserv", "op $channel -" . $self->{pbot}->{registry}->get_value('irc', 'botnick'));
|
2010-03-22 08:33:44 +01:00
|
|
|
}
|
|
|
|
|
2014-04-19 12:38:16 +02:00
|
|
|
sub add_op_command {
|
|
|
|
my ($self, $channel, $command) = @_;
|
2016-10-29 19:47:08 +02:00
|
|
|
$channel = lc $channel;
|
2015-06-26 05:54:38 +02:00
|
|
|
return if not $self->can_gain_ops($channel);
|
2014-04-19 12:38:16 +02:00
|
|
|
push @{ $self->{op_commands}->{$channel} }, $command;
|
|
|
|
}
|
|
|
|
|
2010-03-22 08:33:44 +01:00
|
|
|
sub perform_op_commands {
|
|
|
|
my $self = shift;
|
2012-10-27 23:03:10 +02:00
|
|
|
my $channel = shift;
|
2016-10-29 19:47:08 +02:00
|
|
|
$channel = lc $channel;
|
2014-05-17 22:08:19 +02:00
|
|
|
my $botnick = $self->{pbot}->{registry}->get_value('irc', 'botnick');
|
2012-10-27 23:03:10 +02:00
|
|
|
|
2014-05-18 22:09:05 +02:00
|
|
|
$self->{pbot}->{logger}->log("Performing op commands...\n");
|
2014-04-19 12:38:16 +02:00
|
|
|
while(my $command = shift @{ $self->{op_commands}->{$channel} }) {
|
2010-03-22 08:33:44 +01:00
|
|
|
if($command =~ /^mode (.*?) (.*)/i) {
|
2014-05-18 22:09:05 +02:00
|
|
|
$self->{pbot}->{conn}->mode($1, $2);
|
2014-08-11 09:34:30 +02:00
|
|
|
$self->{pbot}->{logger}->log(" executing mode [$1] [$2]\n");
|
2010-03-22 08:33:44 +01:00
|
|
|
} elsif($command =~ /^kick (.*?) (.*?) (.*)/i) {
|
2014-05-18 22:09:05 +02:00
|
|
|
$self->{pbot}->{conn}->kick($1, $2, $3) unless $1 =~ /\Q$botnick\E/i;
|
|
|
|
$self->{pbot}->{logger}->log(" executing kick on $1 $2 $3\n");
|
2010-03-22 08:33:44 +01:00
|
|
|
}
|
|
|
|
}
|
2014-05-18 22:09:05 +02:00
|
|
|
$self->{pbot}->{logger}->log("Done.\n");
|
2010-03-22 08:33:44 +01:00
|
|
|
}
|
|
|
|
|
2010-06-18 09:03:16 +02:00
|
|
|
sub ban_user {
|
2010-03-22 08:33:44 +01:00
|
|
|
my $self = shift;
|
2010-05-30 04:02:29 +02:00
|
|
|
my ($mask, $channel) = @_;
|
2012-10-27 23:03:10 +02:00
|
|
|
|
2014-04-19 12:38:16 +02:00
|
|
|
$self->add_op_command($channel, "mode $channel +b $mask");
|
2010-03-23 19:24:02 +01:00
|
|
|
$self->gain_ops($channel);
|
2010-03-22 08:33:44 +01:00
|
|
|
}
|
|
|
|
|
2018-06-06 00:02:02 +02:00
|
|
|
sub get_akas {
|
|
|
|
my ($self, $mask, $channel) = @_;
|
|
|
|
my $masks;
|
2015-08-20 07:26:28 +02:00
|
|
|
|
2015-09-04 05:44:33 +02:00
|
|
|
if ($mask !~ m/[!@\$]/) {
|
2015-08-20 07:26:28 +02:00
|
|
|
my ($message_account, $hostmask) = $self->{pbot}->{messagehistory}->{database}->find_message_account_by_nick($mask);
|
|
|
|
|
|
|
|
if (defined $hostmask) {
|
2015-08-22 20:05:53 +02:00
|
|
|
my $nickserv = $self->{pbot}->{messagehistory}->{database}->get_current_nickserv_account($message_account);
|
2018-06-06 00:02:02 +02:00
|
|
|
$masks = $self->{pbot}->{bantracker}->get_baninfo($hostmask, $channel, $nickserv);
|
2015-08-20 07:26:28 +02:00
|
|
|
}
|
2017-03-03 20:42:39 +01:00
|
|
|
|
|
|
|
my %akas = $self->{pbot}->{messagehistory}->{database}->get_also_known_as($mask);
|
|
|
|
|
|
|
|
foreach my $aka (keys %akas) {
|
|
|
|
next if $akas{$aka}->{type} == $self->{pbot}->{messagehistory}->{database}->{alias_type}->{WEAK};
|
|
|
|
next if $akas{$aka}->{nickchange} == 1;
|
|
|
|
|
|
|
|
my $b = $self->{pbot}->{bantracker}->get_baninfo($aka, $channel);
|
|
|
|
if (defined $b) {
|
2018-06-06 00:02:02 +02:00
|
|
|
$masks = {} if not defined $masks;
|
|
|
|
push @$masks, @$b;
|
2017-03-03 20:42:39 +01:00
|
|
|
}
|
|
|
|
}
|
2015-08-20 07:26:28 +02:00
|
|
|
}
|
|
|
|
|
2018-06-06 00:02:02 +02:00
|
|
|
return $masks
|
|
|
|
}
|
|
|
|
|
|
|
|
sub unban_user {
|
|
|
|
my $self = shift;
|
|
|
|
my ($mask, $channel, $immediately) = @_;
|
|
|
|
|
|
|
|
$mask = lc $mask;
|
|
|
|
$channel = lc $channel;
|
|
|
|
$self->{pbot}->{logger}->log("Unbanning $channel $mask\n");
|
|
|
|
|
|
|
|
my $bans = $self->get_akas($mask, $channel);
|
|
|
|
|
2015-08-20 07:26:28 +02:00
|
|
|
if (not defined $bans) {
|
|
|
|
my $baninfo = {};
|
|
|
|
$baninfo->{banmask} = $mask;
|
2017-05-21 08:48:03 +02:00
|
|
|
$baninfo->{type} = '+b';
|
2015-08-20 07:26:28 +02:00
|
|
|
push @$bans, $baninfo;
|
|
|
|
}
|
|
|
|
|
2017-03-03 20:42:39 +01:00
|
|
|
my %unbanned;
|
2015-08-20 07:26:28 +02:00
|
|
|
foreach my $baninfo (@$bans) {
|
2017-05-21 08:48:03 +02:00
|
|
|
next if $baninfo->{type} ne '+b';
|
2017-03-03 20:42:39 +01:00
|
|
|
next if exists $unbanned{$baninfo->{banmask}};
|
|
|
|
$unbanned{$baninfo->{banmask}} = 1;
|
2017-08-03 22:30:42 +02:00
|
|
|
$self->add_to_unban_queue($channel, 'b', $baninfo->{banmask});
|
2013-07-24 14:35:40 +02:00
|
|
|
}
|
2017-08-04 08:19:02 +02:00
|
|
|
$self->check_unban_queue if $immediately;
|
2010-03-22 08:33:44 +01:00
|
|
|
}
|
|
|
|
|
2010-06-18 09:03:16 +02:00
|
|
|
sub ban_user_timed {
|
2010-03-22 08:33:44 +01:00
|
|
|
my $self = shift;
|
2010-05-30 04:02:29 +02:00
|
|
|
my ($mask, $channel, $length) = @_;
|
2010-03-22 08:33:44 +01:00
|
|
|
|
2016-10-29 19:47:08 +02:00
|
|
|
$channel = lc $channel;
|
|
|
|
$mask = lc $mask;
|
|
|
|
|
2015-09-04 05:44:33 +02:00
|
|
|
if ($mask !~ m/[!@\$]/) {
|
2015-08-22 20:05:53 +02:00
|
|
|
my ($message_account, $hostmask) = $self->{pbot}->{messagehistory}->{database}->find_message_account_by_nick($mask);
|
|
|
|
if (defined $hostmask) {
|
|
|
|
my $nickserv = $self->{pbot}->{messagehistory}->{database}->get_current_nickserv_account($message_account);
|
|
|
|
if (defined $nickserv && length $nickserv) {
|
|
|
|
$mask = '$a:' . $nickserv;
|
|
|
|
} else {
|
|
|
|
my ($nick, $user, $host) = $hostmask =~ m/([^!]+)!([^@]+)@(.*)/;
|
|
|
|
$mask = "*!$user\@" . PBot::AntiFlood::address_to_mask($host);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$mask .= '!*@*';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-18 09:03:16 +02:00
|
|
|
$self->ban_user($mask, $channel);
|
2015-05-07 06:13:39 +02:00
|
|
|
if ($length > 0) {
|
|
|
|
$self->{unban_timeout}->hash->{$channel}->{$mask}{timeout} = gettimeofday + $length;
|
|
|
|
$self->{unban_timeout}->save;
|
2015-06-08 03:02:35 +02:00
|
|
|
} else {
|
|
|
|
if ($self->{pbot}->{chanops}->{unban_timeout}->find_index($channel, $mask)) {
|
|
|
|
$self->{pbot}->{chanops}->{unban_timeout}->remove($channel, $mask);
|
|
|
|
}
|
2015-05-07 06:13:39 +02:00
|
|
|
}
|
2010-03-22 08:33:44 +01:00
|
|
|
}
|
|
|
|
|
2015-05-27 19:45:43 +02:00
|
|
|
sub mute_user {
|
|
|
|
my $self = shift;
|
|
|
|
my ($mask, $channel) = @_;
|
|
|
|
|
|
|
|
$self->add_op_command($channel, "mode $channel +q $mask");
|
|
|
|
$self->gain_ops($channel);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub unmute_user {
|
|
|
|
my $self = shift;
|
2017-08-04 08:19:02 +02:00
|
|
|
my ($mask, $channel, $immediately) = @_;
|
2018-06-06 00:02:02 +02:00
|
|
|
|
2016-10-29 19:47:08 +02:00
|
|
|
$mask = lc $mask;
|
|
|
|
$channel = lc $channel;
|
2015-05-27 19:45:43 +02:00
|
|
|
$self->{pbot}->{logger}->log("Unmuting $channel $mask\n");
|
2017-05-21 11:18:00 +02:00
|
|
|
|
2018-06-06 00:02:02 +02:00
|
|
|
my $mutes = $self->get_akas($mask, $channel);
|
|
|
|
|
|
|
|
if (not defined $mutes) {
|
|
|
|
my $muteinfo = {};
|
|
|
|
$muteinfo->{banmask} = $mask;
|
|
|
|
$muteinfo->{type} = '+q';
|
|
|
|
push @$mutes, $muteinfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
my %unmutes;
|
|
|
|
foreach my $muteinfo (@$mutes) {
|
|
|
|
next if $muteinfo->{type} ne '+q';
|
|
|
|
next if exists $unmutes{$muteinfo->{banmask}};
|
|
|
|
$unmutes{$muteinfo->{banmask}} = 1;
|
|
|
|
$self->add_to_unban_queue($channel, 'q', $muteinfo->{banmask});
|
2015-05-27 19:45:43 +02:00
|
|
|
}
|
2017-05-21 11:18:00 +02:00
|
|
|
|
2017-08-04 08:19:02 +02:00
|
|
|
$self->check_unban_queue if $immediately;
|
2015-05-27 19:45:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
sub mute_user_timed {
|
|
|
|
my $self = shift;
|
|
|
|
my ($mask, $channel, $length) = @_;
|
|
|
|
|
2016-10-29 19:47:08 +02:00
|
|
|
$channel = lc $channel;
|
|
|
|
$mask = lc $mask;
|
|
|
|
|
2015-05-27 19:45:43 +02:00
|
|
|
$mask .= '!*@*' if $mask !~ m/[\$!@]/;
|
|
|
|
$self->mute_user($mask, $channel);
|
|
|
|
if ($length > 0) {
|
|
|
|
$self->{unmute_timeout}->hash->{$channel}->{$mask}{timeout} = gettimeofday + $length;
|
|
|
|
$self->{unmute_timeout}->save;
|
2015-06-08 03:02:35 +02:00
|
|
|
} else {
|
|
|
|
if ($self->{pbot}->{chanops}->{unmute_timeout}->find_index($channel, $mask)) {
|
|
|
|
$self->{pbot}->{chanops}->{unmute_timeout}->remove($channel, $mask);
|
|
|
|
}
|
2015-05-27 19:45:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-18 09:46:13 +01:00
|
|
|
sub join_channel {
|
2015-07-29 02:47:22 +02:00
|
|
|
my ($self, $channels) = @_;
|
2014-12-18 09:46:13 +01:00
|
|
|
|
2015-07-29 02:47:22 +02:00
|
|
|
$self->{pbot}->{conn}->join($channels);
|
2014-12-18 09:46:13 +01:00
|
|
|
|
2015-07-29 02:47:22 +02:00
|
|
|
foreach my $channel (split /,/, $channels) {
|
2016-10-29 19:47:08 +02:00
|
|
|
$channel = lc $channel;
|
2015-07-29 02:47:22 +02:00
|
|
|
$self->{pbot}->{event_dispatcher}->dispatch_event('pbot.join', { channel => $channel });
|
2014-12-18 09:46:13 +01:00
|
|
|
|
2015-07-29 02:47:22 +02:00
|
|
|
delete $self->{is_opped}->{$channel};
|
|
|
|
delete $self->{op_requested}->{$channel};
|
|
|
|
|
|
|
|
if (exists $self->{pbot}->{channels}->{channels}->hash->{$channel}
|
|
|
|
and exists $self->{pbot}->{channels}->{channels}->hash->{$channel}{permop}
|
|
|
|
and $self->{pbot}->{channels}->{channels}->hash->{$channel}{permop}) {
|
|
|
|
$self->gain_ops($channel);
|
|
|
|
}
|
2014-12-18 09:46:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub part_channel {
|
|
|
|
my ($self, $channel) = @_;
|
|
|
|
|
2016-10-29 19:47:08 +02:00
|
|
|
$channel = lc $channel;
|
|
|
|
|
2014-12-18 09:46:13 +01:00
|
|
|
$self->{pbot}->{event_dispatcher}->dispatch_event('pbot.part', { channel => $channel });
|
|
|
|
$self->{pbot}->{conn}->part($channel);
|
|
|
|
|
|
|
|
delete $self->{is_opped}->{$channel};
|
|
|
|
delete $self->{op_requested}->{$channel};
|
|
|
|
}
|
|
|
|
|
2015-06-26 05:54:38 +02:00
|
|
|
sub has_ban_timeout {
|
|
|
|
my ($self, $channel, $mask) = @_;
|
2016-10-29 19:47:08 +02:00
|
|
|
return exists $self->{unban_timeout}->hash->{lc $channel}->{lc $mask};
|
2015-06-26 05:54:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
sub has_mute_timeout {
|
|
|
|
my ($self, $channel, $mask) = @_;
|
2016-10-29 19:47:08 +02:00
|
|
|
return exists $self->{unmute_timeout}->hash->{lc $channel}->{lc $mask};
|
2015-06-26 05:54:38 +02:00
|
|
|
}
|
|
|
|
|
2017-05-21 08:48:03 +02:00
|
|
|
sub add_to_unban_queue {
|
|
|
|
my ($self, $channel, $mode, $target) = @_;
|
|
|
|
push @{$self->{unban_queue}->{$channel}->{$mode}}, $target;
|
|
|
|
$self->{pbot}->{logger}->log("Added -$mode $target for $channel to unban queue.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
sub check_unban_queue {
|
|
|
|
my $self = shift;
|
|
|
|
|
2017-08-03 22:30:42 +02:00
|
|
|
my $MAX_COMMANDS = 4;
|
|
|
|
my $commands = 0;
|
|
|
|
|
2017-05-21 08:48:03 +02:00
|
|
|
foreach my $channel (keys %{$self->{unban_queue}}) {
|
2017-08-03 22:30:42 +02:00
|
|
|
my $done = 0;
|
|
|
|
while (not $done) {
|
|
|
|
my ($list, $count, $modes);
|
|
|
|
$list = '';
|
|
|
|
$modes = '-';
|
|
|
|
$count = 0;
|
|
|
|
|
|
|
|
foreach my $mode (keys %{$self->{unban_queue}->{$channel}}) {
|
|
|
|
while (@{$self->{unban_queue}->{$channel}->{$mode}}) {
|
|
|
|
my $target = pop @{$self->{unban_queue}->{$channel}->{$mode}};
|
|
|
|
$list .= " $target";
|
|
|
|
$modes .= $mode;
|
|
|
|
last if ++$count >= $self->{pbot}->{ircd}->{MODES};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (not @{$self->{unban_queue}->{$channel}->{$mode}}) {
|
|
|
|
delete $self->{unban_queue}->{$channel}->{$mode};
|
|
|
|
}
|
|
|
|
|
|
|
|
last if $count >= $self->{pbot}->{ircd}->{MODES};
|
2017-05-21 08:48:03 +02:00
|
|
|
}
|
|
|
|
|
2017-08-09 10:22:13 +02:00
|
|
|
if (not keys %{ $self->{unban_queue}->{$channel} }) {
|
2017-08-03 22:30:42 +02:00
|
|
|
delete $self->{unban_queue}->{$channel};
|
|
|
|
$done = 1;
|
2017-05-21 08:48:03 +02:00
|
|
|
}
|
2017-05-21 11:18:00 +02:00
|
|
|
|
2017-08-03 22:30:42 +02:00
|
|
|
if ($count) {
|
|
|
|
$self->add_op_command($channel, "mode $channel $modes $list");
|
|
|
|
$self->gain_ops($channel);
|
2017-05-21 08:48:03 +02:00
|
|
|
|
2017-08-03 22:30:42 +02:00
|
|
|
return if ++$commands >= $MAX_COMMANDS;
|
|
|
|
}
|
2017-05-21 11:18:00 +02:00
|
|
|
}
|
2017-05-21 08:48:03 +02:00
|
|
|
}
|
|
|
|
}
|
2015-06-26 05:54:38 +02:00
|
|
|
|
2010-06-18 09:03:16 +02:00
|
|
|
sub check_unban_timeouts {
|
2010-03-22 08:33:44 +01:00
|
|
|
my $self = shift;
|
2010-06-18 12:46:23 +02:00
|
|
|
|
|
|
|
return if not $self->{pbot}->{joined_channels};
|
|
|
|
|
2010-03-23 19:24:02 +01:00
|
|
|
my $now = gettimeofday();
|
|
|
|
|
2013-07-24 14:35:40 +02:00
|
|
|
foreach my $channel (keys %{ $self->{unban_timeout}->hash }) {
|
|
|
|
foreach my $mask (keys %{ $self->{unban_timeout}->hash->{$channel} }) {
|
|
|
|
if($self->{unban_timeout}->hash->{$channel}->{$mask}{timeout} < $now) {
|
2017-05-21 11:18:00 +02:00
|
|
|
$self->{unban_timeout}->hash->{$channel}->{$mask}{timeout} = $now + 7200;
|
2013-07-24 14:35:40 +02:00
|
|
|
$self->unban_user($mask, $channel);
|
|
|
|
}
|
2010-03-22 08:33:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-27 19:45:43 +02:00
|
|
|
sub check_unmute_timeouts {
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
return if not $self->{pbot}->{joined_channels};
|
|
|
|
|
|
|
|
my $now = gettimeofday();
|
|
|
|
|
|
|
|
foreach my $channel (keys %{ $self->{unmute_timeout}->hash }) {
|
|
|
|
foreach my $mask (keys %{ $self->{unmute_timeout}->hash->{$channel} }) {
|
|
|
|
if($self->{unmute_timeout}->hash->{$channel}->{$mask}{timeout} < $now) {
|
2017-05-21 11:18:00 +02:00
|
|
|
$self->{unmute_timeout}->hash->{$channel}->{$mask}{timeout} = $now + 7200;
|
2015-05-27 19:45:43 +02:00
|
|
|
$self->unmute_user($mask, $channel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-23 19:24:02 +01:00
|
|
|
sub check_opped_timeouts {
|
2010-03-22 08:33:44 +01:00
|
|
|
my $self = shift;
|
2010-03-23 19:24:02 +01:00
|
|
|
my $now = gettimeofday();
|
2010-03-22 08:33:44 +01:00
|
|
|
|
2010-03-23 19:24:02 +01:00
|
|
|
foreach my $channel (keys %{ $self->{is_opped} }) {
|
|
|
|
if($self->{is_opped}->{$channel}{timeout} < $now) {
|
2018-06-06 00:02:02 +02:00
|
|
|
unless (exists $self->{pbot}->{channels}->{channels}->hash->{$channel}
|
|
|
|
and exists $self->{pbot}->{channels}->{channels}->hash->{$channel}{permop}
|
2014-12-18 09:46:13 +01:00
|
|
|
and $self->{pbot}->{channels}->{channels}->hash->{$channel}{permop}) {
|
|
|
|
$self->lose_ops($channel);
|
|
|
|
delete $self->{is_opped}->{$channel}; # assume chanserv is alive and deop will succeed
|
|
|
|
}
|
2010-03-22 08:33:44 +01:00
|
|
|
} else {
|
2012-08-24 00:50:07 +02:00
|
|
|
# my $timediff = $self->{is_opped}->{$channel}{timeout} - $now;
|
2014-05-18 22:09:05 +02:00
|
|
|
# $self->{pbot}->{logger}->log("deop $channel in $timediff seconds\n");
|
2010-03-22 08:33:44 +01:00
|
|
|
}
|
|
|
|
}
|
2014-08-11 09:34:30 +02:00
|
|
|
|
|
|
|
foreach my $channel (keys %{ $self->{op_requested} }) {
|
|
|
|
if ($now - $self->{op_requested}->{$channel} > 60 * 5) {
|
|
|
|
$self->{pbot}->{logger}->log("5 minutes since OP request for $channel and no OP yet; trying again ...\n");
|
|
|
|
delete $self->{op_requested}->{$channel};
|
|
|
|
$self->gain_ops($channel);
|
|
|
|
}
|
|
|
|
}
|
2010-03-22 08:33:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
1;
|