From e44490c9dce88994398746b579c0debabd0f1e4a Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Wed, 26 Feb 2020 12:45:46 +0100 Subject: [PATCH] Update docs --- docs/docs/ASYNC.md | 1 + docs/docs/LOGGING.md | 34 ++++++++++++++++++++++++++++++++++ docs/docs/UPDATES.md | 2 +- docs/index.md | 2 +- 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/docs/docs/ASYNC.md b/docs/docs/ASYNC.md index 31fe10de..567495ef 100644 --- a/docs/docs/ASYNC.md +++ b/docs/docs/ASYNC.md @@ -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 + Next section \ No newline at end of file diff --git a/docs/docs/LOGGING.md b/docs/docs/LOGGING.md index 689452eb..ba8334f1 100644 --- a/docs/docs/LOGGING.md +++ b/docs/docs/LOGGING.md @@ -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. + Next section \ No newline at end of file diff --git a/docs/docs/UPDATES.md b/docs/docs/UPDATES.md index d622d906..746c72d6 100644 --- a/docs/docs/UPDATES.md +++ b/docs/docs/UPDATES.md @@ -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) diff --git a/docs/index.md b/docs/index.md index 377b2fce..ddf9ad80 100644 --- a/docs/index.md +++ b/docs/index.md @@ -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)