🎬 Initilize SDK
Before you can start building a Bale Bot, you need to configure Bale Bot SDK with your Bot Token that was provided by BotFather. Once you do that, you'll get access to all the available Bot API Methods to make requests to the Bale Bot API.
- Standalone
- Laravel
Here is how you can quickly set up and initialize a single bot operation:
require __DIR__.'/vendor/autoload.php';
use EFive\Bale\Api;
$bale = new Api('YOUR BOT TOKEN');
// Example usage
$response = $bale->getMe();
🦾 Managing Multiple Bots
If you want to manage multiple bots, you can take advantage of the BotsManager
like this:
use EFive\Bale\BotsManager;
$config = [
'bots' => [
'mybot' => [
'token' => '123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11',
],
]
];
$bale = new BotsManager($config);
// Example usage
$response = $bale->bot('mybot')->getMe();
FYI, $config
can get large when handling multiple configurations. To avoid problems, create a dedicated file like config.php
and require it in your code to return the array separately. You can use SDK's Laravel config file as a starting point.
The configuration guide provides further information on how to register multiple bots.
Open the config/bale.php
configuration file and set the token
with your Bale Bot Token or you can also set an environment variable BALE_BOT_TOKEN
with the appropriate value.
In Laravel, you don't have to initilize the SDK as its taken care for you in the service provider and ships with multibot support by default.
You can make use of the EFive\Bale\Laravel\Facades\Bale
Facade to make API requests.
Example:
use EFive\Bale\Laravel\Facades\Bale;
$response = Bale::bot('mybot')->getMe();
The configuration guide provides further information on how to register multiple bots.
You can now get started to write your Bale Bot.
Refer the configuration guide to know more about the available options with detailed information.