Skip to content

Commit

Permalink
Simplify examples
Browse files Browse the repository at this point in the history
  • Loading branch information
alies-dev committed May 12, 2024
1 parent 72096e9 commit 7bd91ce
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ final class HelloCommand extends Command

public function handle(): void
{
$bot = $this->getTelegram();
Dialogs::activate(new HelloExampleDialog($this->update->getChat()->id, $bot));
Dialogs::activate(new HelloExampleDialog($this->update->getChat()->id));
}
}
```
Expand All @@ -115,17 +114,13 @@ final class TelegramWebhookController
{
public function handle(DialogManager $dialogs, BotsManager $botsManager): void
{
$bot = $botsManager->bot('your-bot-name');
$update = $bot->commandsHandler(true);

// optional, for multi-bot applications only, when a given bot is not a default one
$dialogs->setBot($bot);

$dialogs->exists($update)
? $dialogs->proceed($update)
: $botsManager->bot('your-bot-name')->sendMessage([ // fallback message
? $dialogs->proceed($update) // proceed an active dialog (activated in HelloCommand)
: $botsManager->sendMessage([ // fallback message
'chat_id' => $update->getChat()->id,
'text' => 'There is no active dialog at this moment.',
'text' => 'There is no active dialog at this moment. Type /hello to start a new dialog.',
]);
}
}
Expand Down

0 comments on commit 7bd91ce

Please sign in to comment.