From fd8a43c9cda9cf5e4f8fab935d36cdcf770b79ae Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Tue, 5 Sep 2017 02:18:02 -0700 Subject: [PATCH] factundo/factredo now respect locked metadata --- PBot/FactoidCommands.pm | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/PBot/FactoidCommands.pm b/PBot/FactoidCommands.pm index c766aa02..cb631784 100644 --- a/PBot/FactoidCommands.pm +++ b/PBot/FactoidCommands.pm @@ -302,6 +302,17 @@ sub factundo { return "There are no undos available for [$channel] $trigger."; } + my $factoids = $self->{pbot}->{factoids}->{factoids}->hash; + my $admininfo = $self->{pbot}->{admins}->loggedin($channel, "$nick!$user\@$host"); + if ($factoids->{$channel}->{$trigger}->{'locked'}) { + return "/say $trigger is locked and cannot be reverted." if not defined $admininfo; + + if (exists $factoids->{$channel}->{$trigger}->{'effective-level'} + and $admininfo->{level} < $factoids->{$channel}->{$trigger}->{'effective-level'}) { + return "/say $trigger is locked with an effective-level higher than your level and cannot be reverted."; + } + } + if ($undos->{idx} == 0) { return "There are no more undos remaining for [$channel] $trigger."; } @@ -339,6 +350,17 @@ sub factredo { return "There are no redos available for [$channel] $trigger."; } + my $factoids = $self->{pbot}->{factoids}->{factoids}->hash; + my $admininfo = $self->{pbot}->{admins}->loggedin($channel, "$nick!$user\@$host"); + if ($factoids->{$channel}->{$trigger}->{'locked'}) { + return "/say $trigger is locked and cannot be reverted." if not defined $admininfo; + + if (exists $factoids->{$channel}->{$trigger}->{'effective-level'} + and $admininfo->{level} < $factoids->{$channel}->{$trigger}->{'effective-level'}) { + return "/say $trigger is locked with an effective-level higher than your level and cannot be reverted."; + } + } + if ($undos->{idx} + 1 == @{$undos->{list}}) { return "There are no more redos remaining for [$channel] $trigger."; }