iTelegram
PHP Telegram Bot based on the official Telegram Bot API
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.
Installation & Usage:
use iTelegram\Bot;
if (!file_exists('iTelegram.php')) {
copy('https://raw.githubusercontent.com/iNeoTeam/iTelegram/main/iTelegram.phar', 'iTelegram.php');
}
require_once('iTelegram.php');
$bot = new Bot();
$bot->Authentification("BOT_ACCESS_TOKEN");
Example PHP Bot:
error_reporting(0);
if(!file_exists("iTelegram.php")){
copy('https://raw.githubusercontent.com/iNeoTeam/iTelegram/main/iTelegram.phar', 'iTelegram.php');
}
require_once('iTelegram.php');
use iTelegram\Bot;
define('API_KEY', "BOT_ACCESS_TOKEN");
$bot = new Bot();
$bot->Authentification(API_KEY);
$text = $bot->Text();
$chat_id = $bot->getChatId();
$username = $bot->getChatUsername();
$firstname = $bot->getChatFirstname();
$message_id = $bot->MessageId();
if($text == "/start"){
$r = $bot->sendMessage($chat_id, "Hello $firstname !\n\nSpecial Thanks for using iNeoTeam Telegram Bot Class.\n\nGitHub: https://github.com/iNeoTeam\iTelegram\nPowered By @iNeoTeam.", "HTML", true);
}elseif($text == "/update"){
$r = $bot->sendMessage($chat_id, "*Please wait ...*", "MarkDown", true);
unlink("iTelegram.php");
copy("https://raw.githubusercontent.com/iNeoTeam/iTelegram/main/iTelegram.phar", "iTelegram.php");
sleep(2); // for example
$bot->deleteMessage($chat_id, $r->result->message_id);
$bot->sendMessage($chat_id, "New class loaded successfully.", "HTML", true, $message_id);
}else{
$bot->sendMessage($chat_id, "*Command not found.*", "MarkDown");
}
unlink("error_log");
?>