This commit is contained in:
hashbro
2026-09-16 05:35:38 +08:00
parent 26bccaf2b9
commit 7f2fc33449
7 changed files with 174 additions and 10 deletions
+30
View File
@@ -184,6 +184,36 @@ class TelegramNotifier
}
}
/**
* Timeouts, transport errors, 429 and 5xx are worth another queue attempt.
* Chat-not-found / kicked / unauthorized are permanent.
*/
public static function isRetryableSendError(?string $error): bool
{
$error = trim((string) $error);
if ($error === '') {
return true;
}
$e = strtolower($error);
if (str_contains($e, 'too many requests') || str_contains($e, 'retry after') || str_contains($e, '429')) {
return true;
}
if (preg_match('/\bhttp\s*5\d\d\b/', $e) === 1) {
return true;
}
if (str_contains($e, 'curl error')
|| str_contains($e, 'timed out')
|| str_contains($e, 'timeout')
|| str_contains($e, 'connection')
|| str_contains($e, 'resolve host')
|| str_contains($e, 'ssl')) {
return true;
}
return false;
}
/**
* @return array{ok: bool, error: ?string}
*/