Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/levkopo/dribots
Chat bot library for VK, Viber, Telegram and other platforms
https://github.com/levkopo/dribots
Last synced: 3 days ago
JSON representation
Chat bot library for VK, Viber, Telegram and other platforms
- Host: GitHub
- URL: https://github.com/levkopo/dribots
- Owner: levkopo
- License: mit
- Created: 2021-04-28T13:34:56.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-10-03T15:26:26.000Z (over 3 years ago)
- Last Synced: 2024-11-11T00:37:43.321Z (2 months ago)
- Language: PHP
- Size: 72.3 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DriBots
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:
```php
use DriBots\Bot;
use DriBots\Data\Message;
use DriBots\DriBotsHandler;
use DriBots\Platforms\TelegramPlatform;
use DriBots\Platforms\VKPlatform;const TELEGRAM_BOT_TOKEN = "";
const VK_ACCESS_TOKEN = "";
const 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();
```