From cc84816ed1c623878edf2ce5a0ef1e568595480a Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Fri, 3 May 2019 21:10:56 +0200 Subject: [PATCH] Async docs and bugfixes --- README.md | 15 ++++++++++----- bot.php | 7 ++++--- build_docs.php | 1 + docs | 2 +- src/danog/MadelineProto/Wrappers/Loop.php | 2 +- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index dbdceebf..81e398c8 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,16 @@ Tip: if you receive an error (or nothing), [send us](https://t.me/pwrtelegramgro ## Documentation +* [Async](https://docs.madelineproto.xyz/docs/ASYNC.html) + * [Usage](https://docs.madelineproto.xyz/docs/ASYNC.html#usage) + * [Loading the latest version of MadelineProto](https://docs.madelineproto.xyz/docs/ASYNC.html#loading-the-latest-version-of-madelineproto) + * [Enabling the MadelineProto async API](https://docs.madelineproto.xyz/docs/ASYNC.html#enabling-the-madelineproto-async-api) + * [Using the MadelineProto async API](https://docs.madelineproto.xyz/docs/ASYNC.html#using-the-madelineproto-async-api) + * [Async in event handler](https://docs.madelineproto.xyz/docs/ASYNC.html#async-in-event-handler) + * [Async in callback handler](https://docs.madelineproto.xyz/docs/ASYNC.html#async-in-callback-handler) + * [Wrapped async](https://docs.madelineproto.xyz/docs/ASYNC.html#wrapped-async) + * [Ignored async](https://docs.madelineproto.xyz/docs/ASYNC.html#ignored-async) + * [MadelineProto and AMPHP async APIs](https://docs.madelineproto.xyz/docs/ASYNC.html#madelineproto-and-amphp-async-apis) * [Creating a client](https://docs.madelineproto.xyz/docs/CREATING_A_CLIENT.html) * [Logging in](https://docs.madelineproto.xyz/docs/LOGIN.html) * [Automatic](https://docs.madelineproto.xyz/docs/LOGIN.html#automatic) @@ -63,13 +73,8 @@ Tip: if you receive an error (or nothing), [send us](https://t.me/pwrtelegramgro * [Composer from existing project](https://docs.madelineproto.xyz/docs/INSTALLATION.html#composer-from-existing-project) * [Handling updates](https://docs.madelineproto.xyz/docs/UPDATES.html) * [Event driven](https://docs.madelineproto.xyz/docs/UPDATES.html#event-driven) - * [Event driven multithreaded](https://docs.madelineproto.xyz/docs/UPDATES.html#event-driven-multithreaded) * [Multi-account: Combined Event driven update handling](https://docs.madelineproto.xyz/docs/UPDATES.html#combined-event-driven) - * [Webhook](https://docs.madelineproto.xyz/docs/UPDATES.html#webhook) - * [Webhook multithreaded](https://docs.madelineproto.xyz/docs/UPDATES.html#webhook-multithreaded) - * [Long polling (getupdates)](https://docs.madelineproto.xyz/docs/UPDATES.html#long-polling) * [Callback](https://docs.madelineproto.xyz/docs/UPDATES.html#callback) - * [Callback multithreaded](https://docs.madelineproto.xyz/docs/UPDATES.html#callback-multithreaded) * [Noop](https://docs.madelineproto.xyz/docs/UPDATES.html#noop) * [Settings](https://docs.madelineproto.xyz/docs/SETTINGS.html) * [Getting info about the current user](https://docs.madelineproto.xyz/docs/SELF.html) diff --git a/bot.php b/bot.php index e65f57ca..cc192c3e 100755 --- a/bot.php +++ b/bot.php @@ -56,8 +56,9 @@ class EventHandler extends \danog\MadelineProto\EventHandler } $MadelineProto = new \danog\MadelineProto\API('bot.madeline', ['logger' => ['logger_level' => 5]]); - -$MadelineProto->start(); $MadelineProto->async(true); -$MadelineProto->setEventHandler('\EventHandler'); +$MadelineProto->loop(function () use ($MadelineProto) { + yield $MadelineProto->start(); + yield $MadelineProto->setEventHandler('\EventHandler'); +}); $MadelineProto->loop(); diff --git a/build_docs.php b/build_docs.php index 0e2f6f5a..df3186c9 100755 --- a/build_docs.php +++ b/build_docs.php @@ -85,6 +85,7 @@ chdir(__DIR__); $orderedfiles = []; $order = [ + 'ASYNC', 'CREATING_A_CLIENT', 'LOGIN', 'FEATURES', diff --git a/docs b/docs index 6d9ffce3..62a451db 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 6d9ffce34a50e6400dba4a516c78062e5dc2f346 +Subproject commit 62a451db2f92da8034b7b9535c3c89dd5e0179da diff --git a/src/danog/MadelineProto/Wrappers/Loop.php b/src/danog/MadelineProto/Wrappers/Loop.php index 0fff7116..32347a95 100644 --- a/src/danog/MadelineProto/Wrappers/Loop.php +++ b/src/danog/MadelineProto/Wrappers/Loop.php @@ -36,7 +36,7 @@ trait Loop public function loop_async($max_forks = 0) { if (is_callable($max_forks)) { - return $max_forks(); + return yield $max_forks(); } if (in_array($this->settings['updates']['callback'], [['danog\\MadelineProto\\API', 'get_updates_update_handler'], 'get_updates_update_handler'])) { return true;