Async docs and bugfixes

This commit is contained in:
Daniil Gentili 2019-05-03 21:10:56 +02:00
parent 4c52776de9
commit cc84816ed1
5 changed files with 17 additions and 10 deletions

View File

@ -48,6 +48,16 @@ Tip: if you receive an error (or nothing), [send us](https://t.me/pwrtelegramgro
## Documentation ## 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) * [Creating a client](https://docs.madelineproto.xyz/docs/CREATING_A_CLIENT.html)
* [Logging in](https://docs.madelineproto.xyz/docs/LOGIN.html) * [Logging in](https://docs.madelineproto.xyz/docs/LOGIN.html)
* [Automatic](https://docs.madelineproto.xyz/docs/LOGIN.html#automatic) * [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) * [Composer from existing project](https://docs.madelineproto.xyz/docs/INSTALLATION.html#composer-from-existing-project)
* [Handling updates](https://docs.madelineproto.xyz/docs/UPDATES.html) * [Handling updates](https://docs.madelineproto.xyz/docs/UPDATES.html)
* [Event driven](https://docs.madelineproto.xyz/docs/UPDATES.html#event-driven) * [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) * [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](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) * [Noop](https://docs.madelineproto.xyz/docs/UPDATES.html#noop)
* [Settings](https://docs.madelineproto.xyz/docs/SETTINGS.html) * [Settings](https://docs.madelineproto.xyz/docs/SETTINGS.html)
* [Getting info about the current user](https://docs.madelineproto.xyz/docs/SELF.html) * [Getting info about the current user](https://docs.madelineproto.xyz/docs/SELF.html)

View File

@ -56,8 +56,9 @@ class EventHandler extends \danog\MadelineProto\EventHandler
} }
$MadelineProto = new \danog\MadelineProto\API('bot.madeline', ['logger' => ['logger_level' => 5]]); $MadelineProto = new \danog\MadelineProto\API('bot.madeline', ['logger' => ['logger_level' => 5]]);
$MadelineProto->start();
$MadelineProto->async(true); $MadelineProto->async(true);
$MadelineProto->setEventHandler('\EventHandler'); $MadelineProto->loop(function () use ($MadelineProto) {
yield $MadelineProto->start();
yield $MadelineProto->setEventHandler('\EventHandler');
});
$MadelineProto->loop(); $MadelineProto->loop();

View File

@ -85,6 +85,7 @@ chdir(__DIR__);
$orderedfiles = []; $orderedfiles = [];
$order = [ $order = [
'ASYNC',
'CREATING_A_CLIENT', 'CREATING_A_CLIENT',
'LOGIN', 'LOGIN',
'FEATURES', 'FEATURES',

2
docs

@ -1 +1 @@
Subproject commit 6d9ffce34a50e6400dba4a516c78062e5dc2f346 Subproject commit 62a451db2f92da8034b7b9535c3c89dd5e0179da

View File

@ -36,7 +36,7 @@ trait Loop
public function loop_async($max_forks = 0) public function loop_async($max_forks = 0)
{ {
if (is_callable($max_forks)) { 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'])) { if (in_array($this->settings['updates']['callback'], [['danog\\MadelineProto\\API', 'get_updates_update_handler'], 'get_updates_update_handler'])) {
return true; return true;