dev-master
9999999-devSymfony service wrapper for irazasyed/telegram-bot-sdk
MIT
The Requires
by Igor Demishev
Wallogit.com
2017 © Pedro Peláez
Symfony service wrapper for irazasyed/telegram-bot-sdk
TDSTelegramBundle is just a service wrapper for Telegram Bot API PHP SDK, (*1)
WARNING Not all features of the original SDK are supported (although the main features are working). See the TODOs section for more info., (*2)
Step 1: Download Bundle using composer, (*3)
Require the bundle with composer:, (*4)
$ composer require tds/telegram-bundle "dev-master"
Composer will install the bundle to your project's vendor directory., (*5)
Step 2: Enable the bundle, (*6)
Enable the bundle in the kernel:, (*7)
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new TDS\TelegramBundle\TelegramBundle(),
// ...
);
}
Step 3: Configure your application's config.yml, (*8)
tds_telegram:
default: 'default'
async_requests: false
http_client_handler: ~
bots:
default:
username: 'SampleBot'
token: 'YOUR TOKEN HERE'
Step 4: Create your commands, (*9)
app.telegram_command.start_command:
class: AppBundle\Telegram\Command\StartCommand
tags:
- { name: 'tds_telegram.command', bot: 'default' }
As you can notice 'bot' parameter is the same as bot, defined at main config's bots section. It tells the BotManager where it should inject this command, defined as a an ordinary symfony service., (*10)
Step 5: Use the library, (*11)
Simple example of getting BotsManager service, fetching from it the desired bot and processing updates with commands:, (*12)
$manager = $this->getContainer()->get('tds_telegram.bot.bots_manager');
$bot = $manager->bot('default');
while (1) {
$upd = $bot->commandsHandler();
}
Step 6: Read the docs, (*13)
Investigate the SDK documentation, (*14)
This section here is a reminder of the current bundle's minimalistic composition. Feel free to contribute!, (*15)
This bundle is under the MIT license. See the complete license in the bundle:, (*16)
LICENSE, (*17)
Symfony service wrapper for irazasyed/telegram-bot-sdk
MIT