From bb95e07c8e319cb1e86f9e5d16f1ed068deed514 Mon Sep 17 00:00:00 2001 From: Valithor Obsidion Date: Thu, 29 Oct 2026 13:11:26 -0400 Subject: [PATCH] Stop the bot crashing when hosted verification is unavailable Moderator::scrutinizeCkey runs from GameServer's serverinfo timer for every connected player. Verifier::get throws VerifierException while hosted verification is unavailable, and the uncaught throw was a PHP fatal that took VZGCivilizationbot offline on 2026-10-28 and again on 2026-10-29. When verification status is unknown, skip the new-account checks (never treat the player as unverified) and skip the chat-moderation ban (admin status is unknown), logging a warning instead. Co-Authored-By: Claude Opus 5.5 --- src/Civ13/Moderator.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/Civ13/Moderator.php b/src/Civ13/Moderator.php index 534f1e05..26c47332 100644 --- a/src/Civ13/Moderator.php +++ b/src/Civ13/Moderator.php @@ -13,6 +13,7 @@ namespace Civ13; +use Civ13\Exceptions\VerifierException; use Discord\Discord; use Monolog\Logger; use React\Promise\PromiseInterface; @@ -169,9 +170,15 @@ public function scrutinizeCkey(string $ckey): void } } } - if ($this->civ13->verifier->get('ss13', $ckey)) { + try { + if ($this->civ13->verifier->get('ss13', $ckey)) { + return; + } // Verified users are exempt from further checks + } catch (VerifierException $e) { // Verification status is unknown, so never treat the user as unverified + $this->logger->warning("Skipped new-account checks for `$ckey`: {$e->getMessage()}"); + return; - } // Verified users are exempt from further checks + } if (! isset($this->civ13->permitted[$ckey]) && ! isset($this->civ13->ages[$ckey]) && ($age = $this->civ13->getByondAge($ckey)) && ! $this->civ13->checkByondAge($age)) { // Force new accounts to register in Discord $ban = ['ckey' => $ckey, 'duration' => '999 years', 'reason' => "Byond account `$ckey` must register and be approved to play. ($age) Verify at {$this->civ13->discord_formatted}"]; if (isset($this->civ13->channel_ids['staff_bot']) && $channel = $this->discord->getChannel($this->civ13->channel_ids['staff_bot'])) { @@ -235,7 +242,14 @@ private function __relayViolation(GameServer $gameserver, string $ckey, array $b if (isset($this->civ13->verifier)) { if ($guild = $this->discord->guilds->get('id', $this->civ13->civ13_guild_id)) { - if ($item = $this->civ13->verifier->get('ss13', $ckey)) { + try { + $item = $this->civ13->verifier->get('ss13', $ckey); + } catch (VerifierException $e) { // Admin status is unknown; warn only rather than risk banning staff + $this->logger->warning("Skipped chat-moderation ban for `$ckey`: {$e->getMessage()}"); + + return false; + } + if ($item) { if (isset($item['discord']) && $member = $guild->members->get('id', $item['discord'])) { if ($member->roles->has($this->civ13->role_ids['Admin'])) { return false;