From dde93db0ac9937a77fa58ea5fbe6106f32266177 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Sun, 5 Apr 2020 16:58:56 -0700 Subject: [PATCH] ChanOps: dequeue existing identical ban/mute timeouts when adding/updating timeout --- PBot/ChanOpCommands.pm | 6 ++++-- PBot/ChanOps.pm | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/PBot/ChanOpCommands.pm b/PBot/ChanOpCommands.pm index 50e6f5af..fb21efb5 100644 --- a/PBot/ChanOpCommands.pm +++ b/PBot/ChanOpCommands.pm @@ -486,15 +486,17 @@ sub mute_user { my ($self, $from, $nick, $user, $host, $arguments, $stuff) = @_; my ($target, $channel, $length) = $self->{pbot}->{interpreter}->split_args($stuff->{arglist}, 3); + $channel = '' if not defined $channel; + if (not defined $from) { $self->{pbot}->{logger}->log("Command missing ~from parameter!\n"); return ""; } - if (not defined $channel and $from !~ m/^#/) { return "Usage from private message: mute [timeout (default: 24 hours)]"; } + if (not length $channel and $from !~ m/^#/) { return "Usage from private message: mute [timeout (default: 24 hours)]"; } if ($channel !~ m/^#/) { - $length = "$channel $length"; + $length = $channel . ' ' . (defined $length ? $length : ''); $length = undef if $length eq ' '; $channel = exists $stuff->{admin_channel_override} ? $stuff->{admin_channel_override} : $from; } diff --git a/PBot/ChanOps.pm b/PBot/ChanOps.pm index f237a4c1..8587ed71 100644 --- a/PBot/ChanOps.pm +++ b/PBot/ChanOps.pm @@ -224,6 +224,8 @@ sub ban_user_timed { $data->{reason} = $reason if defined $reason; $self->{unban_timeout}->add($channel, $mask, $data); + $self->{pbot}->{timer}->dequeue_event("unban_timeout $channel $mask"); + if ($length > 0) { $self->enqueue_unban_timeout($channel, $mask, $length); } @@ -278,6 +280,8 @@ sub mute_user_timed { $data->{reason} = $reason if defined $reason; $self->{unmute_timeout}->add($channel, $mask, $data); + $self->{pbot}->{timer}->dequeue_event("unmute_timeout $channel $mask"); + if ($length > 0) { $self->enqueue_unmute_timeout($channel, $mask, $length); }