From 7d3cd3f215b19f64f1214c1c3e11ebc92281c3cd Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Wed, 6 Mar 2024 15:07:09 -0800 Subject: [PATCH] Plugin/Spinach: fix subroutine signatures --- lib/PBot/Plugin/Spinach.pm | 6 +++--- lib/PBot/Plugin/Spinach/Rank.pm | 20 ++++++++++---------- lib/PBot/Plugin/Spinach/Stats.pm | 2 +- lib/PBot/VERSION.pm | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/PBot/Plugin/Spinach.pm b/lib/PBot/Plugin/Spinach.pm index 73f1c89a..07f1809a 100644 --- a/lib/PBot/Plugin/Spinach.pm +++ b/lib/PBot/Plugin/Spinach.pm @@ -1345,8 +1345,8 @@ sub create_states($self) { $self->{states}{'gameover'}{trans}{next} = 'getplayers'; } -sub commify($self) { - my $text = reverse $_[0]; +sub commify($self, $value) { + my $text = reverse $value; $text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g; return scalar reverse $text; } @@ -1662,7 +1662,7 @@ sub getnewquestion($self, $state) { } } -sub showquestion($self, $state, $show_category) { +sub showquestion($self, $state, $show_category = undef) { return if $state->{reroll_category}; if (exists $state->{current_question}) { diff --git a/lib/PBot/Plugin/Spinach/Rank.pm b/lib/PBot/Plugin/Spinach/Rank.pm index 926b7491..9a52d21f 100644 --- a/lib/PBot/Plugin/Spinach/Rank.pm +++ b/lib/PBot/Plugin/Spinach/Rank.pm @@ -28,34 +28,34 @@ sub initialize($self, %conf) { $self->{stats} = PBot::Plugin::Spinach::Stats->new(pbot => $self->{pbot}, filename => $self->{filename}); } -sub sort_generic($self, $key) { +sub sort_generic($self, $key, @rest) { if ($self->{rank_direction} eq '+') { return $b->{$key} <=> $a->{$key}; } else { return $a->{$key} <=> $b->{$key}; } } -sub print_generic($self, $key, $player) { +sub print_generic($self, $key, $player, @rest) { return undef if $player->{games_played} == 0; return "$player->{nick}: $player->{$key}"; } -sub print_avg_score($self, $player) { +sub print_avg_score($self, $player, @rest) { return undef if $player->{games_played} == 0; my $result = int $player->{avg_score}; return "$player->{nick}: $result"; } -sub sort_bad_lies($self) { +sub sort_bad_lies($self, @rest) { if ($self->{rank_direction} eq '+') { return $b->{questions_played} - $b->{good_lies} <=> $a->{questions_played} - $a->{good_lies}; } else { return $a->{questions_played} - $a->{good_lies} <=> $b->{questions_played} - $b->{good_lies}; } } -sub print_bad_lies($self, $player) { +sub print_bad_lies($self, $player, @rest) { return undef if $player->{games_played} == 0; my $result = $player->{questions_played} - $player->{good_lies}; return "$player->{nick}: $result"; } -sub sort_mentions($self) { +sub sort_mentions($self, @rest) { if ($self->{rank_direction} eq '+') { return $b->{games_played} - $b->{times_first} - $b->{times_second} - $b->{times_third} <=> $a->{games_played} - $a->{times_first} - $a->{times_second} - $a->{times_third}; @@ -65,13 +65,13 @@ sub sort_mentions($self) { } } -sub print_mentions($self, $player) { +sub print_mentions($self, $player, @rest) { return undef if $player->{games_played} == 0; my $result = $player->{games_played} - $player->{times_first} - $player->{times_second} - $player->{times_third}; return "$player->{nick}: $result"; } -sub sort_expr($self) { +sub sort_expr($self, @rest) { my $result = eval { my $result_a = $self->{expr}->val( { @@ -123,7 +123,7 @@ sub sort_expr($self) { return $result; } -sub print_expr($self, $player) { +sub print_expr($self, $player, @rest) { return undef if $player->{games_played} == 0; my $result = eval { @@ -155,7 +155,7 @@ sub print_expr($self, $player) { return "$player->{nick}: $result"; } -sub rank($self, $arguments) { +sub rank($self, $arguments, @rest) { my %ranks = ( highscore => { sort => sub { $self->sort_generic('high_score', @_) }, diff --git a/lib/PBot/Plugin/Spinach/Stats.pm b/lib/PBot/Plugin/Spinach/Stats.pm index ede67db1..7d341d7a 100644 --- a/lib/PBot/Plugin/Spinach/Stats.pm +++ b/lib/PBot/Plugin/Spinach/Stats.pm @@ -75,7 +75,7 @@ sub add_player($self, $id, $nick, $channel) { return $id; } -sub get_player_id($self, $nick, $channel, $dont_create_new) { +sub get_player_id($self, $nick, $channel, $dont_create_new = undef) { my ($account_id) = $self->{pbot}->{messagehistory}->{database}->find_message_account_by_nick($nick); $account_id = $self->{pbot}->{messagehistory}->{database}->get_ancestor_id($account_id); diff --git a/lib/PBot/VERSION.pm b/lib/PBot/VERSION.pm index 38da3fb4..7933a1c2 100644 --- a/lib/PBot/VERSION.pm +++ b/lib/PBot/VERSION.pm @@ -25,8 +25,8 @@ use PBot::Imports; # These are set by the /misc/update_version script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 4705, - BUILD_DATE => "2024-03-05", + BUILD_REVISION => 4706, + BUILD_DATE => "2024-03-06", }; sub initialize {}