Update docs

This commit is contained in:
Daniil Gentili 2020-02-26 12:45:46 +01:00
parent 7a8bc74239
commit e44490c9dc
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
4 changed files with 37 additions and 2 deletions

View File

@ -653,4 +653,5 @@ $loop->start();
Unlike `GenericLoop`, the callback will **not** be bound to the GenericLoop instance.
You can still command the loop by using the pause/waitSignal methods from the outside or by capturing the loop instance in a closure like shown above.
s
<a href="https://docs.madelineproto.xyz/docs/USING_METHODS.html">Next section</a>

View File

@ -62,4 +62,38 @@ $MadelineProto->logger($message, $level);
By default, `$level` is `\danog\MadelineProto\Logger::NOTICE`.
## Error reporting
MadelineProto now can report errors automatically to the bot admin.
Simply use the following method:
```php
// $message = (string) $exception, for example
$MadelineProto->report($message);
```
This will automatically report the error (and send the logfile!) to the bot admin, set using the `setReportPeers` method:
```php
$MadelineProto->setReportPeers(['danogentili']);
```
**OR** using the `getReportPeers` method of [the event handler](https://docs.madelineproto.xyz/docs/UPDATES.html#async-event-driven).
```php
/**
* Get peer(s) where to report errors
*
* @return int|string|array
*/
public function getReportPeers()
{
return [self::ADMIN];
}
```
If you use the [`startAndLoop`](https://docs.madelineproto.xyz/docs/UPDATES.html#async-event-driven) method to start update handling, all errors surfacing from the loop will be reported automatically.
<a href="https://docs.madelineproto.xyz/docs/CALLS.html">Next section</a>

View File

@ -9,7 +9,7 @@ Update handling can be done in different ways:
* [Self-restart on webhosts](#self-restart-on-webhosts)
* [Async Event driven](#async-event-driven)
* [Multi-account: Async Combined Event driven update handling](#async-combined-event-driven)
* [Multi-account: Async Event driven](#async-event-driven)
* [Async Callback](#async-callback)
* [Noop (default)](#noop)
* [Fetch all updates from the beginning](#fetch-all-updates-from-the-beginning)

View File

@ -91,7 +91,7 @@ You can find examples for nearly every MadelineProto function in
* [Handling updates (new messages)](https://docs.madelineproto.xyz/docs/UPDATES.html)
* [Self-restart on webhosts](https://docs.madelineproto.xyz/docs/UPDATES.html#self-restart-on-webhosts)
* [Async Event driven](https://docs.madelineproto.xyz/docs/UPDATES.html#async-event-driven)
* [Multi-account: Async Combined Event driven update handling](https://docs.madelineproto.xyz/docs/UPDATES.html#async-combined-event-driven)
* [Multi-account: Async Event driven](https://docs.madelineproto.xyz/docs/UPDATES.html#async-event-driven)
* [Async Callback](https://docs.madelineproto.xyz/docs/UPDATES.html#async-callback)
* [Noop (default)](https://docs.madelineproto.xyz/docs/UPDATES.html#noop)
* [Fetch all updates from the beginning](https://docs.madelineproto.xyz/docs/UPDATES.html#fetch-all-updates-from-the-beginning)