mirror of
https://github.com/pragma-/pbot.git
synced 2025-11-27 12:07:29 +01:00
Plugin/Wordle: restrict game-ids to alphanum; minor improvements
This commit is contained in:
parent
9fada0f82c
commit
2afc6210c5
@ -13,6 +13,7 @@ use PBot::Imports;
|
||||
use PBot::Core::Utils::IsAbbrev;
|
||||
|
||||
use Storable qw(dclone);
|
||||
use Time::HiRes qw/time/;
|
||||
use Time::Duration;
|
||||
use JSON::XS;
|
||||
use utf8;
|
||||
@ -379,6 +380,10 @@ sub wordle($self, $context) {
|
||||
my $gameid = $self->gameid($args[2], $context, 1) // 'main';
|
||||
my $game = $gameid ne 'main' ? "($gameid) " : '';
|
||||
|
||||
if ($gameid !~ /^[a-zA-Z0-9_]{1,16}$/) {
|
||||
return "Invalid game-id `$gameid`; must be [a-zA-Z0-9_]{1,16}";
|
||||
}
|
||||
|
||||
$self->{players}->{$channel}->{$context->{message_account}}->{gameid} = $gameid;
|
||||
|
||||
if (defined $self->{games}->{$channel}->{$gameid}->{wordle}
|
||||
@ -420,6 +425,10 @@ sub wordle($self, $context) {
|
||||
my $gameid = $self->gameid($args[3], $context, 1) // 'main';
|
||||
my $game = $gameid ne 'main' ? "($gameid) " : '';
|
||||
|
||||
if ($gameid !~ /^[a-zA-Z0-9_]{1,16}$/) {
|
||||
return "Invalid game-id `$gameid`; must be [a-zA-Z0-9_]{1,16}";
|
||||
}
|
||||
|
||||
if (defined $self->{games}->{$custom_channel}->{$gameid}->{wordle}
|
||||
&& !$self->{games}->{$custom_channel}->{$gameid}->{solved}
|
||||
&& !$self->{games}->{$custom_channel}->{$gameid}->{givenup}) {
|
||||
@ -570,6 +579,10 @@ sub gameid($self, $gameid, $context, $newgame = 0) {
|
||||
$gameid = $self->{players}->{$channel}->{$context->{message_account}}->{gameid};
|
||||
return $gameid if defined $gameid;
|
||||
}
|
||||
|
||||
if (exists $self->{games}->{$channel}->{main}) {
|
||||
return 'main';
|
||||
}
|
||||
} else {
|
||||
if (!exists $self->{games}->{$channel}->{$gameid} && !$newgame) {
|
||||
return undef;
|
||||
@ -909,7 +922,7 @@ sub check_games($self) {
|
||||
my $botnick = $self->{pbot}->{registry}->get_value('irc', 'botnick');
|
||||
foreach my $channel (keys $self->{games}->%*) {
|
||||
foreach my $gameid (keys $self->{games}->{$channel}->%*) {
|
||||
if ($now - $self->{games}->{$channel}->{$gameid}->{guess_time} > 60 * 60 * 24 * 3) {
|
||||
if ($now - $self->{games}->{$channel}->{$gameid}->{guess_time} > 60 * 60 * 24) {
|
||||
my $wordle = join '', $self->{games}->{$channel}->{$gameid}->{wordle}->@*;
|
||||
|
||||
my $state;
|
||||
|
||||
@ -25,8 +25,8 @@ use PBot::Imports;
|
||||
# These are set by the /misc/update_version script
|
||||
use constant {
|
||||
BUILD_NAME => "PBot",
|
||||
BUILD_REVISION => 4922,
|
||||
BUILD_DATE => "2025-10-22",
|
||||
BUILD_REVISION => 4923,
|
||||
BUILD_DATE => "2025-11-05",
|
||||
};
|
||||
|
||||
sub initialize {}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user