botfire / botfire
Telegram Robot Library
Requires
- php: >=8.1.0
- dev-master
- 2.0.0.beta2
- 2.0.0.beta1
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 0.0.8
- 0.0.7
- 0.0.6
- 0.0.5
- 0.0.4
- 0.0.3
- 0.0.2
- 0.0.1
- dev-17-add-sendanimation-method-to-bot
- dev-16-implement-the-send-method-for-all-message-sending-functions
- dev-support-sending-local-file-from-server
- dev-send-photo
This package is auto-updated.
Last update: 2026-03-07 20:55:26 UTC
README
Botfire is a modern library that is used to build different types of Telegram bot projects. Likewise, a dedicated framework has been created for this purpose, which doubles the simplicity of construction and development
Install Botfire Library
composer require botfire/botfire
use
use botfire\botfire\bot;
Set Token
bot::token('your-bot-token'); bot::autoInput();
Webhook
Set Webhook
$result = bot::webhook()->url( $url )->set();
Get Webhook
$get = bot::webhook()->getInfo(); echo $get;
Message
Send Message
bot::id($chat_id)->message('...')->send(); // auto set chat_id bot::this()->message('...')->send();
Send Photo
bot::id($chat->id)->photo($file_id)->send();
Send Audio
bot::id($chat->id)->audio($file_id)->send();
Send Voice
bot::id($chat->id)->voice($file_id)->send();
Send Video Note
bot::id($chat->id)->videoNote($file_id)->send();
Send Video
bot::id($chat->id)->video($file_id)->send();
Send Animation
bot::id($chat->id)->animation($file_id)->send();
Send Document
bot::id($chat->id)->document($file_id)->send();
Send Contact
bot::id($chat->id)->contact($phone_number,$first_name,$last_name)->send();
Send chat action
bot::id($chat->id)->chatAction($action)->send();
'typing','upload_photo','record_video','upload_video','record_audio','upload_audio','upload_document','find_location','record_video_note','upload_video_note'
Send MediaGroup docs
Edit Message
Edit message
bot::id($chat->id)->editMessage('new text')->message_id($msg_id)->send();
Edit caption
bot::id($chat->id)->editCaption('caption text')->message_id($msg_id)->send();
Edit reply markup
$k = bot::keyboard(); $k->btn('hello inline button','callback data')->row(); bot::id($chat->id)->editReplyMarkup()->keyboard( $k )->send();
Delete message
bot::id($chat->id)->deleteMessage()->message_id($msg_id)->send();
Receive user messages via webhook
Get message text
$text = bot::text();
get message caption
$caption = bot::caption();
Get callback data
$data = bot::data();
Get message id
$msg_id = bot::message_id();
Get all message Object
$msg = bot::getMessage();
Get All receive Object
$get = bot::json(); // object $get = bot::input(); // text
User Type
if( bot::isUser() ){ // Receive private messages } else if( bot::isGroup() ){ // Receive from super group } else if( ! bot::isGroup() && bot::isGroup(true) ){ // Receive from normal group } else if( bot::isChannel() ){ // Receive channel post }
Request Type
if( bot::getCallback() ){ // When I click on the inline button $data = bot::data(); //... } else { // When I send normal text // ... }
Receive edited message
if (bot::getEditedMessage()) { // ... } // for channel if(bot::getEditedChannelPost()){ // ... }
Answer Callback
Answer
bot::this()->answerCallback()->send();
Answer and send alert
bot::this()->answerCallback(true)->text('hello')->send();
Sender
Get chat info
$chat = bot::chat();
Get From
$from = bot::from();
Keyboard
inline keyboard
$k = bot::keyboard(); $k ->btn('btn name 1','data callback 1') ->btn('btn name 2','data callback 2') ->row() ->btnUrl('btn name 3','https://github.com') ->row(); bot::id(bot::chat()->id)->message('...')->keyboard($k)->send();
markup keyboard
markup($resize_keyboard,$one_time_keyboard,$selective)
example
$k = bot::keyboard(); $k->markup(true)->btn('button name')->row(); bot::id(bot::chat()->id)->message('...')->keyboard($k)->send();
can use autoRow method
$k = bot::keyboard(); foreach($list as $item){ $k->btn($item->name,$item->value); } // Creates two buttons in each row $k->autoRow(2); bot::this()->message(...)->keyboard($k)->send(); /* out: ______________ | btn1 | btn2 | _______________ | btn3 | btn4 | */
send user contatc
$k = bot::keyboard()->markup(true)->contact('Send Phone')->row(); bot::id(bot::chat()->id)->message('Click Send Phone Button')->keyboard($k)->send();
Bot Info
$info = bot::getMe(); bot::id($chat_id)->message($info)->send();
User Profile
method : getUserProfilePhotos($user_id,$offset=null,$limit=null)
sample
$profile = bot::getUserProfilePhotos(bot::chat()->id);
Available message method
usage
bot::this()->photo($file_id)->caption($text)->send();
| method | *** |
|---|---|
| caption($text) | media message caption |
| message_id($msg_id) | |
| inline_message_id($inline_msg_id) | |
| callback_query_id($query_id) | |
| parse_mode($type) | Send Markdown or HTML |
| vcard($vcard) | |
| disable_web_page_preview($bool) | |
| disable_notification($bool) | |
| live_period($int) | should be between 60 and 86400 |
| reply_to($message_id) | |
| duration($duration) | |
| performer($performer) | |
| title($title) | |
| width($int) | |
| height($int) | |
| supports_streaming($bool) | |
| thumb($thumb) | |
| length($int) | |
| latitude($latitude) | |
| longitude($longitude) | |
| foursquare_id($foursquare_id) | |
| foursquare_type($foursquare_type) |
Permissions
setChatPermissions
Use this method to set default chat permissions for all members
bot::this() ->setChatPermissions() ->can_change_info(false) ->send(); /* | methods : | | can_send_messages(true|false) | can_send_media_messages(true|false) | can_send_polls(true|false) | can_send_other_messages(true|false) | can_add_web_page_previews(true|false) | can_change_info(true|false) | can_invite_users(true|false) | can_pin_messages(true|false) | */
restrictChatMember($user_id,$until_date=null)
Use this method to restrict a user in a supergroup
bot::this() ->restrictChatMember(chat_id) ->can_send_polls(false) ->send(); /* | methods : | | can_send_messages(true|false) | can_send_media_messages(true|false) | can_send_polls(true|false) | can_send_other_messages(true|false) | can_add_web_page_previews(true|false) | can_change_info(true|false) | can_invite_users(true|false) | can_pin_messages(true|false) | */