Improve examples

This commit is contained in:
Daniil Gentili 2018-03-29 11:53:27 +00:00
parent 2c83a555fc
commit 2cb4e80620
3 changed files with 4 additions and 22 deletions

View File

@ -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();

View File

@ -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)) {

View File

@ -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