prowebcraft / telebot
Telegram bot with dialogs and session management
Installs: 351
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Type:package
Requires
- ext-curl: *
- ext-json: *
- monolog/monolog: ~2.1
- prowebcraft/php-json-db: ~0.1
- symfony/console: ^5.0
- symfony/translation: ^5.0
- telegram-bot/api: ~2.3.13
README
Telegram bot with dialogs support and session management
PHP Telegram Bot Api
Based on php wrapper for Telegram Bot API, telebot provides flexible diablogs system (inlines and buttons mode), ability to track responses. Telebot can work in daemon or webhook mode.
Bots: An introduction for developers
Bots are special Telegram accounts designed to handle messages automatically. Users can interact with bots by sending them command messages in private or group chats.
You control your bots using HTTPS requests to bot API.
The Bot API is an HTTP-based interface created for developers keen on building bots for Telegram. To learn how to create and set up a bot, please consult Introduction to Bots and Bot FAQ.
Install
Via Composer
$ composer require prowebcraft/telebot
Usage
See example Telegram Id Bot. This bot in Telegram - @identybot
Create your bot YourBot.php class extended of \Prowebcraft\Telebot\Telebot
<?php class YourBot extends \Prowebcraft\Telebot\Telebot { }
####Create some public methods with Command suffix
/** * Welcome message based on context */ public function hiCommand() { if ($this->isChatGroup()) { $this->reply('Hey everybody in this chat!'); } else { $this->reply('Hello, human!'); } }
####Run your bot in daemon mode. Create daemon.php
<?php require_once './vendor/autoload.php'; require_once "YourBot.php"; $config = []; $bot = new YourBot('YourBotName', []); $bot->start();
And run it in console
$ php daemon.php
At first run data.json will be created with some template options:
{ "config": { "api": "TELEGRAM_BOT_API_KEY", "globalAdmin": 70863438, "admins": [], "trust": [], "whiteGroups": [] } }
Set your bot token to config.api
Set yourself as global admin (you can get your id from @identybot)
Send /hi to your bot
Credits
License
The MIT License (MIT). Please see License File for more information.