From 6570852c6b1cfd48f4f06514e7c69f2ee7dfba3c Mon Sep 17 00:00:00 2001 From: Aleksandr Yakovlev Date: Mon, 7 Oct 2024 08:30:56 +0600 Subject: [PATCH] catch masto errors --- bot.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bot.php b/bot.php index a2b4142..b56119d 100644 --- a/bot.php +++ b/bot.php @@ -87,7 +87,11 @@ $telegram = new Longman\TelegramBot\Telegram( return; }; } -$mastodon = new MastodonClient(new Client); +try { + $mastodon = new MastodonClient(new Client); +} catch (\Exception $e) { + echo 'WARNING: could not start MastodonClient'; +} foreach ($articles as $article) { if (in_array($article['link'], $seen)) { @@ -130,7 +134,7 @@ foreach ($articles as $article) { echo $e; } } - if ($config['MASTODON'] === true) { + if ($config['MASTODON'] === true && isset($mastodon)) { $mastodon->domain($config['MASTODON_SERVER'])->token($config['MASTODON_ACCESS_TOKEN']); /* if ($image) {