mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-25 04:02:37 +01:00
Restrict admin level setting to appropriate admins
This commit is contained in:
parent
9219f02654
commit
62d05f398f
@ -95,6 +95,16 @@ sub adminadd {
|
|||||||
|
|
||||||
$channel = '.*' if lc $channel eq 'global';
|
$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);
|
$self->{pbot}->{admins}->add_admin($name, $channel, $hostmask, $level, $password);
|
||||||
return "Admin added.";
|
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);
|
return $self->{pbot}->{admins}->{admins}->set($channel, $hostmask, $key, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user