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

Plugins/Spinach: replace levels with capabilities

This commit is contained in:
Pragmatic Software 2020-02-11 21:59:39 -08:00
parent afe4638b0a
commit 20695d5f73

View File

@ -388,9 +388,9 @@ sub spinach_cmd {
} }
when ('load') { when ('load') {
my $admin = $self->{pbot}->{users}->loggedin_admin($self->{channel}, "$nick!$user\@$host"); my $u = $self->{pbot}->{users}->loggedin($self->{channel}, "$nick!$user\@$host");
if (not $admin or $admin->{level} < 90) { if (not $u or not $self->{pbot}->{capabilities}->userhas($u, 'botowner')) {
return "$nick: Sorry, only very powerful admins may reload the questions."; return "$nick: Sorry, only botowners may reload the questions.";
} }
$arguments = undef if not length $arguments; $arguments = undef if not length $arguments;
@ -922,9 +922,9 @@ sub spinach_cmd {
return "Usage: spinach state set <new state>"; return "Usage: spinach state set <new state>";
} }
my $admin = $self->{pbot}->{users}->loggedin_admin($self->{channel}, "$nick!$user\@$host"); my $u = $self->{pbot}->{users}->loggedin($self->{channel}, "$nick!$user\@$host");
if (not $admin or $admin->{level} < 90) { if (not $self->{pbot}->{capabilities}->userhas($u, 'admin')) {
return "$nick: Sorry, only very powerful admins may set game state."; return "$nick: Sorry, only admins may set game state.";
} }
$self->{previous_state} = $self->{current_state}; $self->{previous_state} = $self->{current_state};
@ -938,8 +938,8 @@ sub spinach_cmd {
} }
my $admin = $self->{pbot}->{users}->loggedin_admin($self->{channel}, "$nick!$user\@$host"); my $admin = $self->{pbot}->{users}->loggedin_admin($self->{channel}, "$nick!$user\@$host");
if (not $admin or $admin->{level} < 90) { if (not $admin) {
return "$nick: Sorry, only very powerful admins may set game state."; return "$nick: Sorry, only admins may set game state.";
} }
$self->{state_data}->{previous_result} = $self->{state_data}->{result}; $self->{state_data}->{previous_result} = $self->{state_data}->{result};
@ -962,7 +962,7 @@ sub spinach_cmd {
} }
my $admin = $self->{pbot}->{users}->loggedin_admin($self->{channel}, "$nick!$user\@$host"); my $admin = $self->{pbot}->{users}->loggedin_admin($self->{channel}, "$nick!$user\@$host");
if (defined $value and (not $admin or $admin->{level} <= 0)) { if (defined $value and not $admin) {
return "$nick: Sorry, only Spinach admins may set game settings."; return "$nick: Sorry, only Spinach admins may set game settings.";
} }
@ -981,7 +981,7 @@ sub spinach_cmd {
} }
my $admin = $self->{pbot}->{users}->loggedin_admin($self->{channel}, "$nick!$user\@$host"); my $admin = $self->{pbot}->{users}->loggedin_admin($self->{channel}, "$nick!$user\@$host");
if (not $admin or $admin->{level} <= 0) { if (not $admin) {
return "$nick: Sorry, only Spinach admins may set game settings."; return "$nick: Sorry, only Spinach admins may set game settings.";
} }