Plugins: use new Users system

This commit is contained in:
Pragmatic Software 2020-01-25 12:31:08 -08:00
parent 5dd03f1c0c
commit b92fe8a83f
10 changed files with 55 additions and 55 deletions

View File

@ -277,7 +277,7 @@ sub actiontrigger {
}
if ($level > 0) {
my $admin = $self->{pbot}->{admins}->find_admin($channel, "$nick!$user\@$host");
my $admin = $self->{pbot}->{users}->find_admin($channel, "$nick!$user\@$host");
if (not defined $admin or $level > $admin->{level}) {
return "You may not set a level higher than your own.";
}

View File

@ -65,7 +65,7 @@ sub on_join {
$channel = lc $channel;
return 0 if not $self->{pbot}->{chanops}->can_gain_ops($channel);
return 0 if $self->{pbot}->{antiflood}->whitelisted($channel, "$nick!$user\@$host");
return 0 if $self->{pbot}->{admins}->loggedin($channel, "$nick!$user\@$host");
return 0 if $self->{pbot}->{users}->loggedin_admin($channel, "$nick!$user\@$host");
if (exists $self->{kicks}->{$channel}
and exists $self->{kicks}->{$channel}->{$nick}) {

View File

@ -71,7 +71,7 @@ sub on_public {
return 0 if $channel !~ m/^#/;
return 0 if $event->{interpreted};
return 0 if $self->{pbot}->{antiflood}->whitelisted($channel, "$nick!$user\@$host", 'antiflood');
return 0 if $self->{pbot}->{admins}->loggedin($channel, "$nick!$user\@$host");
return 0 if $self->{pbot}->{users}->loggedin_admin($channel, "$nick!$user\@$host");
my $account = $self->{pbot}->{messagehistory}->{database}->get_message_account($nick, $user, $host);

View File

@ -105,7 +105,7 @@ sub battleship_cmd {
my ($self, $from, $nick, $user, $host, $arguments) = @_;
$arguments =~ s/^\s+|\s+$//g;
my $usage = "Usage: battleship challenge|accept|bomb|board|quit|players|kick|abort; for more information about a command: battleship help <command>";
my $usage = "Usage: battleship challenge|accept|bomb|board|score|quit|players|kick|abort; for more information about a command: battleship help <command>";
my $command;
($command, $arguments) = split / /, $arguments, 2;
@ -122,7 +122,7 @@ sub battleship_cmd {
default {
if (length $arguments) {
return "Battleship has no such command '$arguments'. I can't help you with that.";
return "Battleship help is coming soon.";
} else {
return "Usage: battleship help <command>";
}
@ -221,7 +221,7 @@ sub battleship_cmd {
}
when ('abort') {
if (not $self->{pbot}->{admins}->loggedin($self->{channel}, "$nick!$user\@$host")) {
if (not $self->{pbot}->{users}->loggedin_admin($self->{channel}, "$nick!$user\@$host")) {
return "$nick: Sorry, only admins may abort the game.";
}
@ -249,7 +249,7 @@ sub battleship_cmd {
}
when ('kick') {
if (not $self->{pbot}->{admins}->loggedin($self->{channel}, "$nick!$user\@$host")) {
if (not $self->{pbot}->{users}->loggedin_admin($self->{channel}, "$nick!$user\@$host")) {
return "$nick: Sorry, only admins may kick people from the game.";
}
@ -375,7 +375,7 @@ sub battleship_cmd {
}
when ('fullboard') {
if (not $self->{pbot}->{admins}->loggedin($self->{channel}, "$nick!$user\@$host")) {
if (not $self->{pbot}->{users}->loggedin_admin($self->{channel}, "$nick!$user\@$host")) {
return "$nick: Sorry, only admins may see the full board.";
}
@ -910,14 +910,14 @@ sub show_battlefield {
$self->{pbot}->{logger}->log("showing battlefield for player $player\n");
$buf = "$color{cyan} ";
$buf = "$color{cyan},01 ";
for($x = 1; $x < $self->{N_X} + 1; $x++) {
if ($x % 10 == 0) {
$buf .= $color{yellow} if $self->{N_X} > 10;
$buf .= "$color{yellow},01" if $self->{N_X} > 10;
$buf .= $x % 10;
$buf .= ' ';
$buf .= $color{cyan} if $self->{N_X} > 10;
$buf .= "$color{cyan},01" if $self->{N_X} > 10;
} else {
$buf .= $x % 10;
$buf .= ' ';
@ -927,88 +927,88 @@ sub show_battlefield {
$buf .= "\n";
for ($y = 0; $y < $self->{N_Y}; $y++) {
$buf .= sprintf("$color{cyan}%c ", 97 + $y);
$buf .= sprintf("$color{cyan},01%c ", 97 + $y);
for ($x = 0; $x < $self->{N_X}; $x++) {
if ($player == 0) {
if ($self->{board}->[$y][$x] eq $self->{player_two_vert} || $self->{board}->[$y][$x] eq $self->{player_two_horiz}) {
$buf .= "$color{blue}~ ";
$buf .= "$color{blue},01~ ";
next;
} else {
if ($self->{board}->[$y][$x] eq '1' || $self->{board}->[$y][$x] eq '2') {
$buf .= "$color{red}";
$buf .= "$color{red},01";
} elsif ($self->{board}->[$y][$x] eq 'o' || $self->{board}->[$y][$x] eq '*') {
$buf .= "$color{cyan}";
$buf .= "$color{cyan},01";
} elsif ($self->{board}->[$y][$x] eq '~') {
$buf .= "$color{blue}~ ";
$buf .= "$color{blue},01~ ";
next;
} else {
$buf .= "$color{white}";
$buf .= "$color{white},01";
}
$buf .= "$self->{board}->[$y][$x] ";
$self->{pbot}->{logger}->log("$y, $x: $self->{board}->[$y][$x]\n");
}
} elsif ($player == 1) {
if ($self->{board}->[$y][$x] eq $self->{player_one_vert} || $self->{board}->[$y][$x] eq $self->{player_one_horiz}) {
$buf .= "$color{blue}~ ";
$buf .= "$color{blue},01~ ";
next;
} else {
if ($self->{board}->[$y][$x] eq '1' || $self->{board}->[$y][$x] eq '2') {
$buf .= "$color{red}";
$buf .= "$color{red},01";
} elsif ($self->{board}->[$y][$x] eq 'o' || $self->{board}->[$y][$x] eq '*') {
$buf .= "$color{cyan}";
$buf .= "$color{cyan},01";
} elsif ($self->{board}->[$y][$x] eq '~') {
$buf .= "$color{blue}~ ";
$buf .= "$color{blue},01~ ";
next;
} else {
$buf .= "$color{white}";
$buf .= "$color{white},01";
}
$buf .= "$self->{board}->[$y][$x] ";
}
} elsif ($player == 2) {
if ($self->{board}->[$y][$x] eq $self->{player_one_vert} || $self->{board}->[$y][$x] eq $self->{player_one_horiz}
|| $self->{board}->[$y][$x] eq $self->{player_two_vert} || $self->{board}->[$y][$x] eq $self->{player_two_horiz}) {
$buf .= "$color{blue}~ ";
$buf .= "$color{blue},01~ ";
next;
} else {
if ($self->{board}->[$y][$x] eq '1' || $self->{board}->[$y][$x] eq '2') {
$buf .= "$color{red}";
$buf .= "$color{red},01";
} elsif ($self->{board}->[$y][$x] eq 'o' || $self->{board}->[$y][$x] eq '*') {
$buf .= "$color{cyan}";
$buf .= "$color{cyan},01";
} elsif ($self->{board}->[$y][$x] eq '~') {
$buf .= "$color{blue}~ ";
$buf .= "$color{blue},01~ ";
next;
} else {
$buf .= "$color{white}";
$buf .= "$color{white},01";
}
$buf .= "$self->{board}->[$y][$x] ";
}
} else {
if ($self->{board}->[$y][$x] eq '1' || $self->{board}->[$y][$x] eq '2') {
$buf .= "$color{red}";
$buf .= "$color{red},01";
} elsif ($self->{board}->[$y][$x] eq 'o' || $self->{board}->[$y][$x] eq '*') {
$buf .= "$color{cyan}";
$buf .= "$color{cyan},01";
} elsif ($self->{board}->[$y][$x] eq '~') {
$buf .= "$color{blue}~ ";
$buf .= "$color{blue},01~ ";
next;
} else {
$buf .= "$color{white}";
$buf .= "$color{white},01";
}
$buf .= "$self->{board}->[$y][$x] ";
}
}
$buf .= sprintf("$color{cyan}%c", 97 + $y);
$buf .= sprintf("$color{cyan},01%c", 97 + $y);
$buf .= "$color{reset}\n";
}
# bottom border
$buf .= "$color{cyan} ";
$buf .= "$color{cyan},01 ";
for($x = 1; $x < $self->{N_X} + 1; $x++) {
if ($x % 10 == 0) {
$buf .= $color{yellow} if $self->{N_X} > 10;
$buf .= $color{yellow},01 if $self->{N_X} > 10;
$buf .= $x % 10;
$buf .= ' ';
$buf .= $color{cyan} if $self->{N_X} > 10;
$buf .= $color{cyan},01 if $self->{N_X} > 10;
} else {
$buf .= $x % 10;
$buf .= ' ';
@ -1021,15 +1021,15 @@ sub show_battlefield {
my $player2 = $self->{player}->[1]->{nick};
if ($player == 0) {
$self->send_message($self->{player}->[$player]->{nick}, "Player One Legend: ships: [| -] ocean: [$color{blue}~$color{reset}] $player1 miss: [$color{cyan}*$color{reset}] $player2 miss: [$color{cyan}o$color{reset}] $player1 hit: [$color{red}"."1"."$color{reset}] $player2 hit: [$color{red}2$color{reset}]");
$self->send_message($self->{player}->[$player]->{nick}, "Player One Legend: ships: [| -] ocean: [$color{blue},01~$color{reset}] $player1 miss: [$color{cyan},01*$color{reset}] $player2 miss: [$color{cyan},01o$color{reset}] $player1 hit: [$color{red},01"."1"."$color{reset}] $player2 hit: [$color{red},012$color{reset}]");
} elsif ($player == 1) {
$self->send_message($self->{player}->[$player]->{nick}, "Player Two Legend: ships: [I =] ocean: [$color{blue}~$color{reset}] $player1 miss: [$color{cyan}*$color{reset}] $player2 miss: [$color{cyan}o$color{reset}] $player1 hit: [$color{red}"."1"."$color{reset}] $player2 hit: [$color{red}2$color{reset}]");
$self->send_message($self->{player}->[$player]->{nick}, "Player Two Legend: ships: [I =] ocean: [$color{blue},01~$color{reset}] $player1 miss: [$color{cyan},01*$color{reset}] $player2 miss: [$color{cyan},01o$color{reset}] $player1 hit: [$color{red},01"."1"."$color{reset}] $player2 hit: [$color{red},012$color{reset}]");
} elsif ($player == 2) {
$self->send_message($self->{channel}, "Spectator Legend: ocean: [$color{blue}~$color{reset}] $player1 miss: [$color{cyan}*$color{reset}] $player2 miss: [$color{cyan}o$color{reset}] $player1 hit: [$color{red}"."1"."$color{reset}] $player2 hit: [$color{red}2$color{reset}]");
$self->send_message($self->{channel}, "Spectator Legend: ocean: [$color{blue},01~$color{reset}] $player1 miss: [$color{cyan},01*$color{reset}] $player2 miss: [$color{cyan},01o$color{reset}] $player1 hit: [$color{red},01"."1"."$color{reset}] $player2 hit: [$color{red},012$color{reset}]");
} elsif ($player == 3) {
$self->send_message($self->{channel}, "Final Board Legend: $player1 ships: [| -] $player2 ships: [I =] ocean: [$color{blue}~$color{reset}] $player1 miss: [$color{cyan}*$color{reset}] $player2 miss: [$color{cyan}o$color{reset}] $player1 hit: [$color{red}"."1"."$color{reset}] $player2 hit: [$color{red}2$color{reset}]");
$self->send_message($self->{channel}, "Final Board Legend: $player1 ships: [| -] $player2 ships: [I =] ocean: [$color{blue},01~$color{reset}] $player1 miss: [$color{cyan},01*$color{reset}] $player2 miss: [$color{cyan},01o$color{reset}] $player1 hit: [$color{red},01"."1"."$color{reset}] $player2 hit: [$color{red},012$color{reset}]");
} else {
$self->send_message($nick, "Full Board Legend: $player1 ships: [| -] $player2 ships: [I =] ocean: [$color{blue}~$color{reset}] $player1 miss: [$color{cyan}*$color{reset}] $player2 miss: [$color{cyan}o$color{reset}] $player1 hit: [$color{red}"."1"."$color{reset}] $player2 hit: [$color{red}2$color{reset}]");
$self->send_message($nick, "Full Board Legend: $player1 ships: [| -] $player2 ships: [I =] ocean: [$color{blue},01~$color{reset}] $player1 miss: [$color{cyan},01*$color{reset}] $player2 miss: [$color{cyan},01o$color{reset}] $player1 hit: [$color{red},01"."1"."$color{reset}] $player2 hit: [$color{red},012$color{reset}]");
}
foreach my $line (split /\n/, $buf) {

View File

@ -271,7 +271,7 @@ sub connect4_cmd {
}
when ('abort') {
if (not $self->{pbot}->{admins}->loggedin($self->{channel}, "$nick!$user\@$host")) {
if (not $self->{pbot}->{users}->loggedin_admin($self->{channel}, "$nick!$user\@$host")) {
return "$nick: Sorry, only admins may abort the game.";
}
@ -290,7 +290,7 @@ sub connect4_cmd {
}
when ('kick') {
if (not $self->{pbot}->{admins}->loggedin($self->{channel}, "$nick!$user\@$host")) {
if (not $self->{pbot}->{users}->loggedin_admin($self->{channel}, "$nick!$user\@$host")) {
return "$nick: Sorry, only admins may kick people from the game.";
}

View File

@ -596,7 +596,7 @@ sub on_public {
return 0 if $event->{interpreted};
if ($self->{pbot}->{ignorelist}->check_ignore($nick, $user, $host, $channel, 1)) {
my $admin = $self->{pbot}->{admins}->loggedin($channel, "$nick!$user\@$host");
my $admin = $self->{pbot}->{users}->loggedin_admin($channel, "$nick!$user\@$host");
if (!defined $admin || $admin->{level} < 10) {
return 0;
}

View File

@ -281,7 +281,7 @@ sub delete_quotegrab {
return "/msg $nick No quotegrab matching id $arguments found.";
}
if (not $self->{pbot}->{admins}->loggedin($from, "$nick!$user\@$host") and $quotegrab->{grabbed_by} ne "$nick!$user\@$host") {
if (not $self->{pbot}->{users}->loggedin_admin($from, "$nick!$user\@$host") and $quotegrab->{grabbed_by} ne "$nick!$user\@$host") {
return "You are not the grabber of this quote.";
}

View File

@ -264,7 +264,7 @@ sub remindme {
}
if ($delete_id) {
my $admininfo = $self->{pbot}->{admins}->loggedin($target ? $target : $from, "$nick!$user\@$host");
my $admininfo = $self->{pbot}->{users}->loggedin_admin($target ? $target : $from, "$nick!$user\@$host");
# admins can delete any reminders (perhaps check admin levels against owner level?)
if ($admininfo) {
@ -303,7 +303,7 @@ sub remindme {
return "Please specify a point in time for this reminder." if not $alarm;
return "Please specify a reminder message." if not $text;
my $admininfo = $self->{pbot}->{admins}->loggedin($target ? $target : $from, "$nick!$user\@$host");
my $admininfo = $self->{pbot}->{users}->loggedin_admin($target ? $target : $from, "$nick!$user\@$host");
if ($target) {
if (not defined $admininfo) {

View File

@ -355,7 +355,7 @@ sub spinach_cmd {
}
when ('edit') {
my $admin = $self->{pbot}->{admins}->loggedin($self->{channel}, "$nick!$user\@$host");
my $admin = $self->{pbot}->{users}->loggedin_admin($self->{channel}, "$nick!$user\@$host");
if (not $admin) {
return "$nick: Sorry, only admins may edit questions.";
@ -403,7 +403,7 @@ sub spinach_cmd {
}
when ('load') {
my $admin = $self->{pbot}->{admins}->loggedin($self->{channel}, "$nick!$user\@$host");
my $admin = $self->{pbot}->{users}->loggedin_admin($self->{channel}, "$nick!$user\@$host");
if (not $admin or $admin->{level} < 90) {
return "$nick: Sorry, only very powerful admins may reload the questions.";
}
@ -503,7 +503,7 @@ sub spinach_cmd {
}
when ('abort') {
if (not $self->{pbot}->{admins}->loggedin($self->{channel}, "$nick!$user\@$host")) {
if (not $self->{pbot}->{users}->loggedin_admin($self->{channel}, "$nick!$user\@$host")) {
return "$nick: Sorry, only admins may abort the game.";
}
@ -542,7 +542,7 @@ sub spinach_cmd {
}
when ('kick') {
if (not $self->{pbot}->{admins}->loggedin($self->{channel}, "$nick!$user\@$host")) {
if (not $self->{pbot}->{users}->loggedin_admin($self->{channel}, "$nick!$user\@$host")) {
return "$nick: Sorry, only admins may kick people from the game.";
}
@ -939,7 +939,7 @@ sub spinach_cmd {
return "Usage: spinach state set <new state>";
}
my $admin = $self->{pbot}->{admins}->loggedin($self->{channel}, "$nick!$user\@$host");
my $admin = $self->{pbot}->{users}->loggedin_admin($self->{channel}, "$nick!$user\@$host");
if (not $admin or $admin->{level} < 90) {
return "$nick: Sorry, only very powerful admins may set game state.";
}
@ -954,7 +954,7 @@ sub spinach_cmd {
return "Usage: spinach state result <current state result>";
}
my $admin = $self->{pbot}->{admins}->loggedin($self->{channel}, "$nick!$user\@$host");
my $admin = $self->{pbot}->{users}->loggedin_admin($self->{channel}, "$nick!$user\@$host");
if (not $admin or $admin->{level} < 90) {
return "$nick: Sorry, only very powerful admins may set game state.";
}
@ -978,7 +978,7 @@ sub spinach_cmd {
return "Spinach stats setting cannot be modified while a game is in progress.";
}
my $admin = $self->{pbot}->{admins}->loggedin($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)) {
return "$nick: Sorry, only Spinach admins may set game settings.";
}
@ -997,7 +997,7 @@ sub spinach_cmd {
return "Spinach stats setting cannot be modified while a game is in progress.";
}
my $admin = $self->{pbot}->{admins}->loggedin($self->{channel}, "$nick!$user\@$host");
my $admin = $self->{pbot}->{users}->loggedin_admin($self->{channel}, "$nick!$user\@$host");
if (not $admin or $admin->{level} <= 0) {
return "$nick: Sorry, only Spinach admins may set game settings.";
}

View File

@ -51,7 +51,7 @@ sub show_url_titles {
return 0 if $event->{interpreted};
if ($self->{pbot}->{ignorelist}->check_ignore($nick, $user, $host, $channel)) {
my $admin = $self->{pbot}->{admins}->loggedin($channel, "$nick!$user\@$host");
my $admin = $self->{pbot}->{users}->loggedin_admin($channel, "$nick!$user\@$host");
if (!defined $admin || $admin->{level} < 10) {
return 0;
}