levkopo / dribots
Chat bot library for VK, Viber, Telegram and other platforms
1.2
2021-10-03 08:08 UTC
Requires
- php: >=8.0
- monolog/monolog: ^2.2
Requires (Dev)
- phpunit/phpunit: ^9.5
- roave/security-advisories: dev-latest
README
Chat bot library for VK.com, Telegram and other platforms
Installing
To install dribots you need composer and PHP 8.0 and higher (if you have, of course xD)
composer require levkopo/dribots
Installing platform libraries
In addition, to use DriBots for other platforms, you need the required platform libraries.
For Telegram:
composer require levkopo/dribots-telegram
For VK.com:
composer require levkopo/dribots-vk
Usage
Example bot resend sended message for VK.com and Telegram:
use DriBots\Bot; use DriBots\Data\Message; use DriBots\DriBotsHandler; use DriBots\Platforms\TelegramPlatform; use DriBots\Platforms\VKPlatform; const TELEGRAM_BOT_TOKEN = "<telegram token>"; const VK_ACCESS_TOKEN = "<vk token>"; const VK_GROUP_ID = <vk group id>; include_once __DIR__."/./vendor/autoload.php"; DriBotsHandler::new(new class extends Bot { public function onNewMessage(Message $message): void { $this->platformProvider->sendMessage($message->fromId, $message->text, $message->attachment?->save($message->fromId.$message->id)); } })->addPlatform(new VKPlatform(VK_ACCESS_TOKEN, VK_GROUP_ID)) ->addPlatform(new TelegramPlatform(TELEGRAM_BOT_TOKEN)) ->handle();