-
-
Save greenplugin/09179bee606aa01b1ee00d049ab78fc4 to your computer and use it in GitHub Desktop.
| parameters: | |
| telegram.token: '%env(TELEGRAM_TOKEN)%' | |
| telegram.webhook_secret: '%env(TELEGRAM_WEBHOOK_SECRET)%' | |
| services: | |
| GuzzleHttp\Client: | |
| arguments: | |
| - { timeout: 120} | |
| Http\Factory\Guzzle\RequestFactory: | |
| Http\Factory\Guzzle\StreamFactory: | |
| Psr\Http\Message\RequestFactoryInterface: '@Http\Factory\Guzzle\RequestFactory' | |
| Psr\Http\Message\StreamFactoryInterface: '@Http\Factory\Guzzle\StreamFactory' | |
| Http\Adapter\Guzzle6\Client: | |
| arguments: | |
| - '@GuzzleHttp\Client' | |
| Psr\Http\Client\ClientInterface: '@Http\Adapter\Guzzle6\Client' | |
| TgBotApi\BotApiBase\BotApiNormalizer: | |
| TgBotApi\BotApiBase\NormalizerInterface: '@TgBotApi\BotApiBase\BotApiNormalizer' | |
| TgBotApi\BotApiBase\ApiClientInterface: | |
| class: TgBotApi\BotApiBase\ApiClient | |
| arguments: | |
| - '@Psr\Http\Message\RequestFactoryInterface' | |
| - '@Psr\Http\Message\StreamFactoryInterface' | |
| - '@Psr\Http\Client\ClientInterface' | |
| TgBotApi\BotApiBase\WebhookFetcherInterface: | |
| class: TgBotApi\BotApiBase\WebhookFetcher | |
| arguments: | |
| - '@TgBotApi\BotApiBase\NormalizerInterface' | |
| TgBotApi\BotApiBase\BotApiInterface: | |
| class: TgBotApi\BotApiBase\BotApiComplete | |
| arguments: | |
| - '%telegram.token%' | |
| - '@TgBotApi\BotApiBase\ApiClientInterface' | |
| - '@TgBotApi\BotApiBase\NormalizerInterface' |
How to create a new bot
This config can be simplified with autowire option and Guzzle can be replaced with Symfony HttpClient. If it makes sense I can write a manual how to prepare this library with Symfony framework.
Yep, it can be simplified, I'ts old example. Please, write if you will have a time, I'll update readme.
We have a symfony flex receipe.
I think we can add another readme to repository named like README.SYMFONY.md and add link to main readme.
How to create a new bot
$botKey = '';
$requestFactory = new Http\Factory\Guzzle\RequestFactory();
$streamFactory = new Http\Factory\Guzzle\StreamFactory();
$client = new Http\Adapter\Guzzle6\Client();
$apiClient = new \TgBotApi\BotApiBase\ApiClient($requestFactory, $streamFactory, $client);
$bot = new \TgBotApi\BotApiBase\BotApi($botKey, $apiClient, new \TgBotApi\BotApiBase\BotApiNormalizer());
$userId = '';
$bot->send(\TgBotApi\BotApiBase\Method\SendMessageMethod::create($userId, 'Hi'));
How to create a new bot