diff --git a/README.md b/README.md index 0d13962..069fd4f 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,6 @@ Tools set for messenger managing. Allows you to send any content via Telegram, V Install the latest version with ```bash -// Not published on Packagist yet $ composer require he110/communication-tools ``` @@ -72,6 +71,40 @@ $pool->sendScreen($screen); ``` + +### Work with events +```php +setAccessToken(YOUR_TOKEN_HERE); + +// Action for simple incoming messages +$messenger->onMessage(function(Request $request) use ($messenger) { + // Your code here... + $text = $request->getMessage(); + /** @var MessengerUser $user $user */ + $user = $request->getUser(); + $messenger->setTargetUser($user->getUserId()); + $messenger->sendMessage("We've got your message: '$text'"); +}); + +// Action for buttons click +$messenger->onButtonClick(function(Request $request) use ($messenger) { + // Your code here... + $payload = $request->getPayload(); +}); + +// Required!!! Run this method to check if events are triggered +$messenger->checkEvents(); + +``` + ## About ### Requirements