A complete PHP SDK for building bots on Rubika Messenger using the official Rubika Bot API.
✅ Complete API Coverage - 48+ API methods
✅ Advanced Button Types - Calendar, Number/String Picker, Textbox, Location
✅ Text Formatting - Markdown formatting (Bold, Italic, Code, Links, Mentions)
✅ Group Management - User ban\unban
✅ Media Support - Files
✅ Flexible Updates - Polling or Webhook modes
✅ Type-Safe - PHP 8.0+ with strong typing
✅ Well Tested - 100+ unit tests with 100% pass rate
✅ PSR-4 Compliant - Modern autoloading
##installation:
git clone https://github.com/AbolfazlMirzae/RubikaPhp.git
cd RubikaPhp
composer installuse RubikaPhp\Core\Bot;
$bot = new Bot('YOUR_BOT_TOKEN');$bot->chatId('c12345')
->text('Hello from RubikaPhp!')
->sendMessage();$bot->chatId('c12345')
->filePath('/path/to/file.pdf')
->sendFile();use RubikaPhp\Filters\Filters;
$bot->onUpdate(Filters::text(), function($bot, $update) {
$bot->chatId($update->new_message->chat_id)
->text('Echo: ' . $update->new_message->text)
->sendMessage();
});
$bot->run();Calendar Selection
use RubikaPhp\Models\ButtonCalendar;
use RubikaPhp\Enums\ButtonCalendarTypeEnum;
$calendar = new ButtonCalendar(
type: ButtonCalendarTypeEnum::DATEPERSIAN,
min_year: '1400',
max_year: '1410',
title: 'Select Date'
);Number Picker
use RubikaPhp\Models\ButtonNumberPicker;
$picker = new ButtonNumberPicker(
min_value: '1',
max_value: '100',
title: 'Choose a number'
);Location Picker
use RubikaPhp\Models\ButtonLocation;
use RubikaPhp\Models\Location;
use RubikaPhp\Enums\ButtonLocationTypeEnum;
$location = new ButtonLocation(
type: ButtonLocationTypeEnum::PICKER,
title: 'Share your location'
);// Ban a user
$bot->banUser('group_chat_id', 'user_id');
// Unban a user
$bot->unbanUser('group_chat_id', 'user_id')// Command filter
$bot->onUpdate(Filters::command('start'), $handler);
// Text with prefix
$bot->onUpdate(Filters::text('/help'), $handler);
// Combined filters
$bot->onUpdate(
Filters::text()->and(Filters::isForwarded()),
$handler
);
// File/Media filters
$bot->onUpdate(Filters::hasFile(), $handler);
$bot->onUpdate(Filters::hasLocation(), $handler);
$bot->onUpdate(Filters::hasSticker(), $handler);use RubikaPhp\Utils\Markdown;
$text = "Bold
$bot->chatId('c123')->text($text)->sendMessage();Supported formats:
Bold("**text**")→ textItalic("__text__")→ _textCode("```php code```")→textHyperlink("[text](link)")→ textMention("[text](guid)")→ textSpoiler("||text||")→ ||text||Strike("~~text~~")→textUnderline("--text--")→ --text--Mono(``text``)→text
- FEATURES.md - Complete feature documentation
- CHANGELOG.md - Version history
- examples/basic_bot.php - Simple example
- examples/advanced_bot.php - Advanced features
- examples/webhook_bot.php - Webhook setup
Run the test suite:
./vendor/bin/phpunit tests/Current status: 80/80 tests passing ✅
sendMessage()- Send text with optional keyboardsendFile()- Send file/documentsendPoll()- Send poll/quizsendLocation()- Send locationsendContact()- Send contact info
editMessageText()- Update message texteditMessageKeypad()- Update inline keyboarddeleteMessage()- Delete messageforwardMessage()- Forward message
getMe()- Get bot informationgetChat()- Get chat details
banUser()- Ban userunbanUser()- Remove ban
setCommands()- Set command listupdateBotEndpoints()- Configure webhooksetEndpoint()- Setup endpoint for all typeseditChatKeypad()- Update keyboard layout
getUpdates()- Long pollingrun()- Start bot (polling or webhook)
- PHP >= 8.0
- Composer
- cURL extension
- JSON extension
- GuzzleHttp 7.x
lib/
├── Core/Bot.php # Main bot class
├── Api/RubikaAPI.php # API client
├── Models/ # Data models
├── Filters/Filters.php # Message filters
├── Enums/Enums.php # Enumerations
└── Exceptions/ # Custom exceptions
Contributions welcome! Please follow PSR-12 standards and add tests for new features.
MIT License - See LICENSE file
For API documentation, visit: https://rubika.ir/botapi
Current: 2.0.0
Last Updated: 1404/12/3
Test Coverage: 100% (80/80 tests passing)