From 2cb4e80620e85e9b98672dcef35cb020a003102f Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Thu, 29 Mar 2018 11:53:27 +0000 Subject: [PATCH] Improve examples --- bot.php | 9 ++------- magna.php | 9 +-------- tests/testing.php | 8 +------- 3 files changed, 4 insertions(+), 22 deletions(-) diff --git a/bot.php b/bot.php index df622a39..535ca769 100755 --- a/bot.php +++ b/bot.php @@ -67,13 +67,8 @@ class EventHandler extends \danog\MadelineProto\EventHandler $settings = ['app_info' => ['api_id' => 6, 'api_hash' => 'eb06d4abfb49dc3eeb1aeb98ae0f581e'], 'updates' => ['handle_updates' => true]]; //, 'connection_settings' => ['all' => ['test_mode' => true]]]; -try { - $MadelineProto = new \danog\MadelineProto\API('bot.madeline', $settings); -} catch (\danog\MadelineProto\Exception $e) { - \danog\MadelineProto\Logger::log($e->getMessage()); - unlink('bot.madeline'); - $MadelineProto = new \danog\MadelineProto\API('bot.madeline', $settings); -} +$MadelineProto = new \danog\MadelineProto\API('bot.madeline', $settings); + $MadelineProto->start(); $MadelineProto->setEventHandler('\EventHandler'); $MadelineProto->loop(); diff --git a/magna.php b/magna.php index 537576cb..9c1a8633 100755 --- a/magna.php +++ b/magna.php @@ -19,14 +19,7 @@ if (file_exists('web_data.php')) { echo 'Deserializing MadelineProto from session.madeline...'.PHP_EOL; -try { - $MadelineProto = new \danog\MadelineProto\API('session.madeline'); -} catch (\danog\MadelineProto\Exception $e) { - echo $e.PHP_EOL; - unlink('session.madeline'); - $MadelineProto = new \danog\MadelineProto\API('session.madeline'); -} - +$MadelineProto = new \danog\MadelineProto\API('session.madeline'); $MadelineProto->start(); if (!isset($MadelineProto->programmed_call)) { diff --git a/tests/testing.php b/tests/testing.php index f8cbb158..837f4c60 100755 --- a/tests/testing.php +++ b/tests/testing.php @@ -43,13 +43,7 @@ $settings = json_decode(getenv('MTPROTO_SETTINGS'), true) ?: []; */ echo 'Loading MadelineProto...'.PHP_EOL; -try { - $MadelineProto = new \danog\MadelineProto\API(getcwd().'/testing.madeline', $settings); -} catch (\danog\MadelineProto\Exception $e) { - echo $e.PHP_EOL; - unlink(getcwd().'/testing.madeline'); - $MadelineProto = new \danog\MadelineProto\API(getcwd().'/testing.madeline', $settings); -} +$MadelineProto = new \danog\MadelineProto\API(getcwd().'/testing.madeline', $settings); /* * If this session is not logged in, login