Telegram bot with dialogs support and session management
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 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.
Via Composer
$ composer require prowebcraft/telebot
See example Telegram Id Bot. This bot in Telegram - @identybot
<?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
The MIT License (MIT). Please see License File for more information.