Rubot is a PHP framework for building Rubika bots. It uses the official Rubika APIs to create bots efficiently and reliably. Rubot is optimized for performance and ease of use, offering all supported methods for messaging, media, and user interactions.
Whether you need a simple chatbot or a more advanced assistant, Rubot makes development faster, smarter, and more maintainable.
V 2.1.0 PHP 8.1+
Update v2.1.0
Overall changes
- Optimization of core classes
- Using Guzzle for sending requests, downloading, and uploading
- Updated filters in the Message class
- Optimized upload and download
- Added support for receiving updates via long polling
- Added button links for joining channels and opening URLs
- Simplified retrieval and usage of file IDs
- Added new filters
- Added progress tracking for downloads and uploads
- Added the Rubino class
Minor changes
- Added ENV file support
- Added retry count for failed requests
- Added timeout setting
- Added debugger
- Added automatic token retrieval from ENV
-
Get your token from the @BotFather bot.
-
Install the Library Download the library using one of the following methods:
Using Composer
composer require sanf/rubot
# Or Install the Beta Version
composer require sanf/rubot:dev-mainClone from GitHub
git clone https://github.com/sanf-dev/rubot
composer dump-autoload- Create a File and Run a Simple Bot
require "vendor/autoload.php";
use Rubot\Bot;
use Rubot\Tools\Message;
$bot = new Bot("YOUR_BOT_TOKEN");
$run = function (Message $update) use ($bot) {
$update->reply("Hello, user");
};
$bot->onMessage($run); // run webhook- Set a Webhook for Your Bot
$bot->setWebHook("WEBHOOK_URL");- Congratulations 🎉 You have successfully set up your bot!
Simple example of sending a message with the Bot class
$bot->sendMessage(
"CHAT_ID",
"TEXT",
"REPLY_MESSAGE_ID",
"DISABLE_NOTIFICATION",
["OTHER_METHOD"]
);CHAT_ID–string→ The target chat ID.TEXT–string→ The text message you want to send.REPLY_MESSAGE_ID–string→ The message ID to reply to (optional).DISABLE_NOTIFICATION–bool→ Additional options:OTHER_METHOD–array→ Additional options:inline_keypad:arraychat_keypad:arraychat_keypad_type:string
Get familiar with the different methods
sendFile:Send a file to a chatsendPoll:Send a poll to the chatsendLocation:Send a temporary locationsendContact:Send a contact (phone number & name)forwardMessage:Forward a message from one chat to another
editMessage:Edit the content of a previously sent messagedeleteMessage:Delete a message from a chateditChatKeypad:Edit an existing chat keyboard
getFile:Get file information using its file IDsendFile:Upload a media file to Rubika serversdownload:Download a file from its file ID to a specified path
getMe:Get bot account detailsgetChat:Get chat information (user, group, or channel)getUpdates:Receive incoming updates (polling method)setCommands:Set bot commands
setSecretKey:Set a security key to protect webhook accesscheckSecretKey:Check if the incoming webhook request contains the correct keysetWebHook:Automatically set webhook to a given URLonMessage:Handle incoming messages from the webhook with a callback functiononUpdate:Receive updates using long polling
text:get Messagechat_id:get Chat Idmessage_id:get Message Id
MIT © Sanf-Dev