Hi, I have several Bot in my application but there is only one set of configurations in the config file.
I think it should be possible to set multiple bots, like what we do when Using Multiple Database Connections
return [
/*
|--------------------------------------------------------------------------
| Default Bot
|--------------------------------------------------------------------------
|
*/
'default' => 'bot1',
/*
|--------------------------------------------------------------------------
| Bot Connections
|--------------------------------------------------------------------------
|
*/
'connections' => [
'bot1' => [
'bot_token' => env('TELEGRAM_BOT_TOKEN', '1:eff'),
'async_requests' => env('TELEGRAM_ASYNC_REQUESTS', true),
'http_client_handler' => null,
'commands' => [
Telegram\Bot\Commands\HelpCommand::class,
],
],
'bot2' => [
'bot_token' => env('TELEGRAM_BOT_TOKEN', '2:eff'),
'async_requests' => env('TELEGRAM_ASYNC_REQUESTS', false),
'http_client_handler' => null,
'commands' => [
Telegram\Bot\Commands\HelpCommand::class,
],
],
'bot3' => [
'bot_token' => env('TELEGRAM_BOT_TOKEN', '3:eff'),
'async_requests' => env('TELEGRAM_ASYNC_REQUESTS', true),
'http_client_handler' => null,
'commands' => [
Telegram\Bot\Commands\HelpCommand::class,
],
],
],
Hi, Yes! Multi-bot is supported.
You can work on it using Telegram::bot('bot1')->sendMessage() like so. Where bot1 is your keyname of the config.
Your webhook should be dynamic. Something like /bot/{bot}/secret/webhook and then pass the {bot} value to Telegram::bot($bot)->getWebhookUpdate() and so on.
Let me know if you have any questions. All the methods work the same as it works for a single bot. And ofc the commands can be either shared or registered separately for each of them.
how about config file? How should I write it? was my sample correct?
You can refer the config file. Obviously, you need to use the v3 (unstable) or dev-develop branch + publish the config file (If on Laravel).
Most helpful comment
You can refer the config file. Obviously, you need to use the v3 (unstable) or
dev-developbranch + publish the config file (If on Laravel).