mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-30 07:38:58 +01:00
Improve examples
This commit is contained in:
parent
2c83a555fc
commit
2cb4e80620
7
bot.php
7
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->start();
|
||||
$MadelineProto->setEventHandler('\EventHandler');
|
||||
$MadelineProto->loop();
|
||||
|
@ -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->start();
|
||||
|
||||
if (!isset($MadelineProto->programmed_call)) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
* If this session is not logged in, login
|
||||
|
Loading…
Reference in New Issue
Block a user