3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-17 09:29:30 +01:00

Commands/Factoids: remove "not owner" restriction on factset/factunset

This commit is contained in:
Pragmatic Software 2024-11-14 01:21:48 -08:00
parent 5bca8c7d16
commit c6433a662f
No known key found for this signature in database
GPG Key ID: CC916B6E3C84ECCE
2 changed files with 6 additions and 41 deletions

View File

@ -390,33 +390,11 @@ sub cmd_factset($self, $context) {
} }
} }
if (defined $owner_channel) {
my $factoid = $self->{pbot}->{factoids}->{data}->{storage}->get_data($owner_channel, $owner_trigger);
my $owner;
my $mask;
if ($factoid->{'locked'}) {
# check owner against full hostmask for locked factoids
$owner = $factoid->{'owner'};
$mask = $context->{hostmask};
} else {
# otherwise just the nick
($owner) = $factoid->{'owner'} =~ m/([^!]+)/;
$mask = $context->{nick};
}
if ((defined $value and $key ne 'action' and $key ne 'action_with_args')
and lc $mask ne lc $owner
and not $self->{pbot}->{capabilities}->userhas($userinfo, 'admin'))
{
return "You are not the owner of $trigger_name.";
}
}
my $result = $self->{pbot}->{factoids}->{data}->{storage}->set($channel, $trigger, $key, $value); my $result = $self->{pbot}->{factoids}->{data}->{storage}->set($channel, $trigger, $key, $value);
if (defined $value and $result =~ m/set to/) { $self->log_factoid($channel, $trigger, $context->{hostmask}, "set $key to $value"); } if (defined $value and $result =~ m/set to/) {
$self->log_factoid($channel, $trigger, $context->{hostmask}, "set $key to $value");
}
return $result; return $result;
} }
@ -472,20 +450,7 @@ sub cmd_factunset($self, $context) {
$channel_name = 'global' if $channel_name eq '.*'; $channel_name = 'global' if $channel_name eq '.*';
$trigger_name = "\"$trigger_name\"" if $trigger_name =~ / /; $trigger_name = "\"$trigger_name\"" if $trigger_name =~ / /;
my $oldvalue; my $oldvalue = $self->{pbot}->{factoids}->{data}->{storage}->get_data($channel, $trigger, $key);
if (defined $owner_channel) {
my $factoid = $self->{pbot}->{factoids}->{data}->{storage}->get_data($owner_channel, $owner_trigger);
my ($owner) = $factoid->{'owner'} =~ m/([^!]+)/;
if ($key ne 'action_with_args' and lc $context->{nick} ne lc $owner
and not $self->{pbot}->{capabilities}->userhas($userinfo, 'admin'))
{
return "You are not the owner of $trigger_name.";
}
$oldvalue = $self->{pbot}->{factoids}->{data}->{storage}->get_data($channel, $trigger, $key);
}
if (not defined $oldvalue) { if (not defined $oldvalue) {
return "[$channel_name] $trigger_name: key '$key' does not exist."; return "[$channel_name] $trigger_name: key '$key' does not exist.";

View File

@ -25,8 +25,8 @@ use PBot::Imports;
# These are set by the /misc/update_version script # These are set by the /misc/update_version script
use constant { use constant {
BUILD_NAME => "PBot", BUILD_NAME => "PBot",
BUILD_REVISION => 4851, BUILD_REVISION => 4852,
BUILD_DATE => "2024-11-13", BUILD_DATE => "2024-11-14",
}; };
sub initialize {} sub initialize {}