Skip to content

Commit b1ba00e

Browse files
committed
Readme update
1 parent 4ac8093 commit b1ba00e

File tree

1 file changed

+43
-5
lines changed

1 file changed

+43
-5
lines changed

README.md

+43-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
21
# Symfony bundle for Telegram Bot API
32

4-
A symfony bundle for `luzrain/telegram-bot-api`
3+
[![PHP ^8.2](https://img.shields.io/badge/PHP-^8.2-777bb3.svg?style=flat)](https://www.php.net/releases/8.2/en.php)
4+
![Symfony ^6.3](https://img.shields.io/badge/Symfony-^6.3-374151.svg?style=flat)
5+
[![Tests Status](https://img.shields.io/github/actions/workflow/status/luzrain/telegram-bot-api/tests.yaml?branch=master)](../../actions/workflows/tests.yaml)
6+
7+
A symfony bundle for [luzrain/telegram-bot-api](https://github.com/luzrain/telegram-bot-api) library.
58

69
## Installation
710
### Install composer package
811
``` bash
9-
$ composer require luzrain/telegram-bot-bundle (TODO)
12+
$ composer require luzrain/telegram-bot-bundle
1013
```
14+
1115
### Enable the Bundle
1216
```php
1317
<?php
@@ -47,9 +51,43 @@ telegram_webhook:
4751
```
4852
4953
### Set webhook url
54+
Install webhook url using the console command:
5055
``` bash
51-
$ bin/console telegram:set-webhook-url
56+
$ bin/console telegram:webhook:set --url=https://domain.xyz/telagram-webhook
57+
```
58+
59+
## Example of usage
60+
### Command controller
61+
```php
62+
use Luzrain\TelegramBotApi\Method;
63+
use Luzrain\TelegramBotApi\Type;
64+
use Luzrain\TelegramBotBundle\Attribute\OnCommand;
65+
use Luzrain\TelegramBotBundle\TelegramBot\TelegramCommand;
66+
67+
final class StartCommandController extends TelegramCommand
68+
{
69+
#[OnCommand('/start')]
70+
public function __invoke(Type\Message $message, string $argument = ''): Method
71+
{
72+
return $this->reply('Hello from symfony bot');
73+
}
74+
}
5275
```
5376

54-
..... TODO
77+
### Message controller
78+
```php
79+
use Luzrain\TelegramBotApi\Event;
80+
use Luzrain\TelegramBotApi\Method;
81+
use Luzrain\TelegramBotApi\Type;
82+
use Luzrain\TelegramBotBundle\Attribute\OnEvent;
83+
use Luzrain\TelegramBotBundle\TelegramBot\TelegramCommand;
5584

85+
final class OnMessageController extends TelegramCommand
86+
{
87+
#[OnEvent(Event\Message::class)]
88+
public function __invoke(Type\Message $message): Method
89+
{
90+
return $this->reply('You write: ' . $message->text);
91+
}
92+
}
93+
```

0 commit comments

Comments
 (0)