3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-24 11:42:35 +01:00

Restrict admin level setting to appropriate admins

This commit is contained in:
Pragmatic Software 2017-10-15 10:56:51 -07:00
parent 9219f02654
commit 62d05f398f

View File

@ -95,6 +95,16 @@ sub adminadd {
$channel = '.*' if lc $channel eq 'global';
my $admin = $self->{pbot}->{admins}->find_admin($from, "$nick!$user\@$host");
if (not $admin) {
return "You are not an admin in $from.\n";
}
if ($admin->{level} < 90 and $level > 60) {
return "You may not set admin level higher than 60.\n";
}
$self->{pbot}->{admins}->add_admin($name, $channel, $hostmask, $level, $password);
return "Admin added.";
}
@ -157,6 +167,25 @@ sub adminset {
}
}
my $admin = $self->{pbot}->{admins}->find_admin($from, "$nick!$user\@$host");
my $target = $self->{pbot}->{admins}->find_admin($channel, $hostmask);
if (not $admin) {
return "You are not an admin in $from.";
}
if (not $target) {
return "There is no admin $hostmask in channel $channel.";
}
if ($key eq 'level' && $admin->{level} < 90 and $value > 60) {
return "You may not set admin level higher than 60.\n";
}
if ($target->{level} > $admin->{level}) {
return "You may not modify admins higher in level than you.";
}
return $self->{pbot}->{admins}->{admins}->set($channel, $hostmask, $key, $value);
}