PHPackages                             rubikalib/rubikalib - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. rubikalib/rubikalib

ActiveLibrary

rubikalib/rubikalib
===================

A library for working with rubika API from PHP source code

v2.3.12(1y ago)11131[1 PRs](https://github.com/AmirrezaFiroz/RubikaLib/pulls)MITPHPPHP &gt;= 8.1.0

Since Aug 21Pushed 1y ago1 watchersCompare

[ Source](https://github.com/AmirrezaFiroz/RubikaLib)[ Packagist](https://packagist.org/packages/rubikalib/rubikalib)[ Docs](https://RubikaLib-PHP.github.io)[ RSS](/packages/rubikalib-rubikalib/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (6)Versions (7)Used By (0)

Rubika Library
==============

[](#rubika-library)

A library for working with rubika API from PHP source. **use this client to make bots, games and ...**

Usage
=====

[](#usage)

```
composer require rubikalib/rubikalib
```

1. create a new php file in current directory
2. require vendor and **Main** class in file

```
require_once __DIR__ . '/vendor/autoload.php';

use RubikaLib\Main;
```

3. now you can send messages

```
$bot = new Main(9123456789);
$bot->Messages->sendMessage('u0FFeu...', 'سلام');
```

Get Updates From API
====================

[](#get-updates-from-api)

for getting updates, you must create new class with a name and call it

```
require_once __DIR__ . '/vendor/autoload.php';

use RubikaLib\enums\ChatActivities;
use RubikaLib\interfaces\Runner;
use RubikaLib\{
    Failure,
    Main
};

try {
    $app = new Main(9123456789);

    $app->proccess(
        new class implements Runner
        {
            # when this class declared as update getter on Main, this method get called
            public function onStart(array $mySelf): void
            {
            }

            # All updates will pass to this method (not action updates)
            public function onMessage(array $updates, Main $class): void
            {
            }

            # All action updates (Typing, Recording, uploading) will pass to this method
            public function onAction(ChatActivities $activitie, string $guid, string $from, Main $class): void
            {
            }
        }
    )->RunAndLoop();

} catch (Failure $e) {
    echo $e->getMessage() . "\n";
}
```

`update example:`

```
{
    "chat_updates": [
        {
            "object_guid": "u0HMRZI03...",
            "action": "Edit",
            "chat": {
                "time_string": "172329480300001076130340791385",
                "last_message": {
                    "message_id": "1076130340791385",
                    "type": "Text",
                    "text": "hello dear",
                    "author_object_guid": "u0HMRZI03...",
                    "is_mine": true,
                    "author_title": "\u0634\u0645\u0627",
                    "author_type": "User"
                },
                "last_seen_my_mid": "1076130340791385",
                "last_seen_peer_mid": "0",
                "status": "Active",
                "time": 1723294803,
                "last_message_id": "1076130340791385"
            },
            "updated_parameters": [
                "last_message_id",
                "last_message",
                "status",
                "time_string",
                "last_seen_my_mid",
                "last_seen_peer_mid",
                "time"
            ],
            "timestamp": "1723294804",
            "type": "User"
        }
    ],
    "message_updates": [
        {
            "message_id": "1076130340791385",
            "action": "New",
            "message": {
                "message_id": "1076130340791385",
                "text": "hello dear",
                "time": "1723294803",
                "is_edited": false,
                "type": "Text",
                "author_type": "User",
                "author_object_guid": "u0HMRZI03...",
                "allow_transcription": false
            },
            "updated_parameters": [],
            "timestamp": "1723294804",
            "prev_message_id": "1076130340663385",
            "object_guid": "u0HMRZI03...",
            "type": "User",
            "state": "1723294744"
        }
    ],
    "user_guid": "u0HMRZI03..."
}
```

[Methods](https://github.com/AmirrezaFiroz/RubikaLib?tab=readme-ov-file#methods)
================================================================================

[](#methods)

methoddescribtionexample of return datalogoutlogout and terminate session[logout.json](examples/logout.json)getMySessionsget account sessions[getMySessions.json](examples/getMySessions.json)TerminateSession(string $session\_key)terminate sessions which are got by getMySessions() ---&gt; session\['key'\][terminateSession.json](examples/terminateSession.json)getMySelfget account's self info[getMySelf.json](examples/getMySelf.json)ChangeUsername(string $newUserName): arrayset new username[ChangeUsername.json](examples/ChangeUsername.json)sendMessage(string $guid, string $text, int $reply\_to\_message\_id = 0)send text message to guid[sendMessage.json](examples/sendMessage.json)EditMessage(string $guid, string $newText, string $message\_id)edit message in guid chat[EditMessage.json](examples/EditMessage.json)ForwardMessages(string $from\_object\_guid, array $message\_ids, string $to\_object\_guid)forward message to guid ----&gt; array of message-ids: \['11916516161', '85626232', ...\][forwardMessages.json](examples/forwardMessages.json)deleteMessages(string $object\_guid, arrayint $message\_id, DeleteType $type = DeleteType::Local)delete message in guid ----&gt; DeleteType = {Global, Local}sendChatActivity(string $guid, ChatActivities $activity)send an activitie on top of chat ----&gt; ChatActivities = {Typing, Uploading,Recording}[sendChatActivity.json](examples/sendChatActivity.json)getChats(int $start\_id = 0)get list of chatsnot researched yetjoinChat(string $enterKey)join to channel or group using guid or join link[joinChat.json](examples/joinChat.json)leaveChat(string $guid)leave channel or group using guid[leaveChat.json](examples/leaveChat.json)deleteGroup(string $group\_guid)delete group for all usersnot researched yetgetMyStickerSetsget stickers list[getMyStickerSets.json](examples/getMyStickerSets.json)getFoldersget folders list[getFolders.json](examples/getFolders.json)DeleteFolderdelete a folder[DeleteFolder.json](examples/DeleteFolder.json)AddFolderdelete a foldernot researched yetgetChatsUpdates(int $state = 0)get all chat updates from $state time to now[getChatsUpdates.json](examples/getChatsUpdates.json)getMessagesInterval(string $guid, int $middle\_message\_id)not researched yetnot researched yetgetGroupOnlineCount(string $group\_guid)get group online users count[getGroupOnlineCount.json](examples/getGroupOnlineCount.json)seenChat(string $guid, string $last\_message\_id)seen chat messages[seenChat.json](examples/seenChat.json)seenChatsArray(array $guids, array $last\_message\_ids)seen chats -&gt; seenChatsArray(\['u0UBF88...', 'g0UKLD66...'\], \['91729830180', '9798103900'\]);[seenChats.json](examples/seenChats.json)getContactsget contact list[getContacts.json](examples/getContacts.json)AddContact(int $phone\_number, string $first\_name, string $last\_name = '')add new contact[AddContact.json](examples/AddContact.json)DeleteContact(string $user\_guid)remove contact by guid[DeleteContact.json](examples/DeleteContact.json)sendContact(string $guid, string $first\_name, int $phone\_number, string $contact\_guid = '', string $last\_name = '', string $reply\_to\_message\_id = '0')send contsct to some one[sendContact.json](examples/sendContact.json)getChatInfo(string $guid)get chat info[getChatInfo.json](examples/getChatInfo.json)getChatInfoByUsername(string $username)get chat info by username ---&gt; exmample: @someone[getChatInfoByUsername.json](examples/getChatInfoByUsername.json)EditProfile(string $first\_name = '', string $last\_name = '', string $bio = '')change account parameters[EditProfile.json](examples/EditProfile.json)RequestDeleteAccountsend request to delete this account[RequestDeleteAccount.json](examples/RequestDeleteAccount.json)turnOffTwoStepturn off the two-step confirmation[turnOffTwoStep.json](examples/turnOffTwoStep.json)getAvatars(string $object\_guid)get guid avatars[getAvatars.json](examples/getAvatars.json)getGroupAllMembers(string $group\_guid, string $search\_for = '', int $start\_id = 0)get group members list[getGroupAllMembers.json](examples/getGroupAllMembers.json)DownloadFile(string $access\_hash\_rec, string $file\_id, string $path, int $DC)download a file`true` or `false` (depended on API file finding)UploadNewProfileAvatar(string $file\_path)upload new account profile picture[UploadNewProfileAvatar.json](examples/UploadNewProfileAvatar.json)uploadNewGroupAvatar(string $group\_guid, string $file\_path)upload new account profile picture[uploadNewGroupAvatar.json](examples/uploadNewGroupAvatar.json)DeleteMyAvatar(string $avatar\_id)delete account profile picture[DeleteMyAvatar.json](examples/DeleteMyAvatar.json)createGroup(string $title, array $members)create new group[createGroup.json](examples/createGroup.json)addGroupMembers(string $group\_guid, array $members)add group members[addGroupMembers.json](examples/addGroupMembers.json)deleteGroupAvatar(string $group\_guid, string $avatar\_id)delete group profile picture[deleteGroupAvatar.json](examples/deleteGroupAvatar.json)sendPhoto(string $guid, string $path, bool $isLink = false, string $caption = '', strXing $thumbnail = '')send photo to guid[sendPhoto.json](examples/sendPhoto.json)sendDocument(string $guid, string $path, bool $isLink = false, string $caption = '')send file to guid[sendDocument.json](examples/sendDocument.json)addMessageReaction(string $guid, string $message\_id, ReactionsEmoji or ReactionsString $reaction)add reaction to message[addMessageReaction.json](examples/addMessageReaction.json)removeMessageReaction(string $guid, string $message\_id)remove reaction from message[removeMessageReaction.json](examples/removeMessageReaction.json)setGroupDefaultAccess(string $group\_guid, GroupDefaultAccesses $settings = new GroupDefaultAccesses)set group members default accesses[setGroupDefaultAccess.json](examples/setGroupDefaultAccess.json)getGroupLink(string $group\_guid)get group join link[getGroupLink.json](examples/getGroupLink.json)getNewGroupLink(string $group\_guid)reset and get group new join link[getNewGroupLink.json](examples/getNewGroupLink.json)getGroupAdminMembers(string $group\_guid)get group admins list[getGroupAdminMembers.json](examples/getGroupAdminMembers.json)editGroupHistoryForNewMembers(string $group\_guid, HistoryForNewMembers $chat\_history\_for\_new\_members)show group chat gistory for new members --&gt; Visible or Hidden[editGroupHistoryForNewMembers.json](examples/editGroupHistoryForNewMembers.json)setGroupEventMessages(string $group\_guid, bool $EventMssages)show event messages in chat[setGroupEventMessages.json](examples/setGroupEventMessages.json)editGroupProfile(string $group\_guid, string $title = '', string $description = '')edit group profile info[editGroupProfile.json](examples/editGroupProfile.json)banGroupMember(string $group\_guid, string $member\_guid)ban group member[banGroupMember.json](examples/banGroupMember.json)unBanGroupMember(string $group\_guid, string $member\_guid)unban group member (delete from group block list to joining)[unBanGroupMember.json](examples/unBanGroupMember.json)setGroupAdmin(string $group\_guid, string $member\_guid, array $access\_list)set member as group admin : example -&gt; setGroupAdmin('g0UBD989...', 'u0YUB78...', \[GroupAdminAccessList::BanMember, ...\])[setGroupAdmin.json](examples/setGroupAdmin.json)removeGroupAdmin(string $group\_guid, string $member\_guid)remove group admin (set as just member)[removeGroupAdmin.json](examples/removeGroupAdmin.json)getGroupAdminAccessList(string $group\_guid, string $admin\_guid)get group admin access list[getGroupAdminAccessList.json](examples/getGroupAdminAccessList.json)setGroupSlowModeTime(string $group\_guid, int $time)set group slow time ---&gt;(in seconds). just allowed -&gt; 0, 10, 30, 60, 300, 900, 3600[setGroupSlowModeTime.json](examples/setGroupSlowModeTime.json)AcceptRequestObjectOwning(string $object\_guid)accept owning a chat[AcceptRequestObjectOwning.json](examples/AcceptRequestObjectOwning.json)RejectRequestObjectOwning(string $object\_guid)reject owning a chat[RejectRequestObjectOwning.json](examples/RejectRequestObjectOwning.json)getBannedGroupMembers(string $group\_guid)get group block list for joining[getBannedGroupMembers.json](examples/getBannedGroupMembers.json)SetGroupReactions(string $group\_guid, SetGroupReactions $mode, array $selects = \[\])set group's which reactions can used[SetGroupReactions.json](examples/SetGroupReactions.json)requestChangeObjectOwner(string $group\_guid, string $new\_owner\_user\_guid)set another admin to group owner[requestChangeObjectOwner.json](examples/requestChangeObjectOwner.json)sendVideo(string $guid, string $path, bool $isLink = false, string $caption = '', string $thumbnail = '', string $reply\_to\_message\_id = '')send video[sendVideo.json](examples/sendVideo.json)sendGif(string $guid, string $path, bool $isLink = false, string $caption = '', string $thumbnail = '', string $reply\_to\_message\_id = '')send gif[sendGif.json](examples/sendGif.json)sendMusic(string $guid, string $path, bool $isLink = false, string $caption = '', string $thumbnail = '', string $reply\_to\_message\_id = '')send music[sendMusic.json](examples/sendMusic.json)createPoll(string $guid,string $question,array $options,pollType $type,bool $is\_anonymous = false,string $explanation = '',int $correct\_option\_index = 0,bool $allows\_multiple\_answers = false,string $reply\_to\_message\_id = '')send poll[createPoll.json](examples/createPoll.json)getPollStatus(string $poll\_id)get poll info[getPollStatus.json](examples/getPollStatus.json)getPollOptionVoters(string $poll\_id, int $selection\_index)get poll option voters[getPollOptionVoters.json](examples/getPollOptionVoters.json)sendLocation(string $guid, float $latitude, float $longitude)send location get poll option voters[sendLocation.json](examples/sendLocation.json)getMyGifSetget gifs list[getMyGifSet.json](examples/getMyGifSet.json)getStickersBySetIDs(string $sticker\_set\_ids)get stickers by set id[getStickersBySetIDs.json](examples/getStickersBySetIDs.json)votePoll(string $poll\_id, int ...$selection\_indexs)vote a poll[votePoll.json](examples/votePoll.json)Use As Shad
===========

[](#use-as-shad)

you can use library for [Shad](https://shad.ir) API.

```
use RubikaLib\interfaces\MainSettings;
use RubikaLib\Main;
use RubikaLib\enums\AppType;

$settings = new MainSettings();
$settings->AppType = AppType::Shad;

$app = new Main(9123456789, settings: $settings);

$app->Messages->sendMessage(
    guid: $app->Account->getMySelf()['user_guid'],
    text: '**hello wolrd!**'
);
```

Example
=======

[](#example)

here as base of one bot you can run

```
declare(strict_types=1);
require_once 'vendor/autoload.php';

use RubikaLib\enums\ChatActivities;
use RubikaLib\interfaces\Runner;
use RubikaLib\{
    Failure,
    Main
};

$app = new Main(9123456789, 'test-app');

$app->proccess(
    new class implements Runner
    {
        private ?array $me;
        private array $userData = [];

        public function onStart(array $mySelf): void
        {
            $this->me = $mySelf;
            echo "bot is running...\n";
        }

        public function onMessage(array $updates, Main $class): void
        {
            if (isset($updates['message_updates'])) {
                foreach ($updates['message_updates'] as $update) {
                    if ($update['action'] == 'New') {
                        $guid = $update['object_guid']; # chat guid
                        $message_id = $update['message_id'];
                        $from = $update['message']['author_object_guid']; # message from who?
                        $author_type = $update['message']['author_type']; # Group, Channel, User, Bot, ...
                        $action = $update['action'];
                        $text = $update['message']['text'];

                        echo "new message: $from => $text\n";

                        if ($text == 'شروع' && $author_type == 'User' && $from != $this->me['user_guid']) {
                            $this->setUp($from);
                            $class->Messages->sendMessage($guid, "به منوی اصلی خوش آمدید 😎\n\nگزینه مورد نظر را ارسال کنید:\n\nراهنما 📚(5) |  پشتیبانی 🆘(6)", $message_id);
                        }
                    }
                }
            }
        }

        public function onAction(ChatActivities $activitie, string $guid, string $from, Main $class): void
        {
        }

        private function setUp(string $guid)
        {
            $this->userData = [
                'step' => 'none'
            ];
            file_put_contents("users/$guid.json", json_encode($this->userData));
        }
    }
);

$app->RunAndLoop();
```

see more about methods result: [here](examples)

Error Handling
==============

[](#error-handling)

we wrote an Exceptions class called **Failure** that specialy used for library errors. here is an example of some futures:

```
try {
    $app = new Main(9123456789);

    // ...

    $app->RunAndLoop();
} catch (Failure $error) {
    echo $error->getMessage() . "\n";

    if ($error->obj != array()) {
        var_dump($error->obj);

        echo PHP_EOL;
    }
}
```

Library Settings
================

[](#library-settings)

we maked an settings class that you can set allowed parameters in and pass it to Main class here is an example:

```
use RubikaLib\interfaces\MainSettings;

$settings = new MainSettings();
$settings->userAgent = ...;
$settings->tmp_session = ...;

$app = new Main(9123456789, $settings);
```

**Note !** : you can chain setting parameters by this pattern:

```
// ...

(new MainSettings())->
    setUserAgent('Chrome ...')->
    setAuth('a829skm32knk...');

// ...
```

`parameters:`

parameterdescribtionUserAgentdefault useragent for library (it just used in login and will save in session for next uses)tmp\_sessiondefault tmp\_session for library (it just used in login and will save in session for next uses)Optimallower RAM and CPU usage(true by default (recommanded))BaseworkDir (by default: 'lib/')AppTypewhich API to use (Shad or Rubika(default))ShowProgressesshow download or upload progress precentKeepUpdatedkeep everythink updated(true by default)Links
=====

[](#links)

[rubika ✅](https://rubika.ir/RubikaLibPHP)

[telegram ✅](https://t.me/rubika_lib)

[documentation🔰](https://Rubikalib-PHP.github.io)

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance42

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~33 days

Total

6

Last Release

460d ago

Major Versions

v1.2.2 → v2.0.12024-09-12

### Community

Maintainers

![](https://www.gravatar.com/avatar/e474af35cac59ff7c45a211aa38262bcc6315673750eaa843bf9f3306d5d773a?d=identicon)[AmirrezaFiroz](/maintainers/AmirrezaFiroz)

---

Top Contributors

[![AmirrezaFiroz](https://avatars.githubusercontent.com/u/121334966?v=4)](https://github.com/AmirrezaFiroz "AmirrezaFiroz (80 commits)")

---

Tags

rubikarubikalibrubika-lib

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rubikalib-rubikalib/health.svg)

```
[![Health](https://phpackages.com/badges/rubikalib-rubikalib/health.svg)](https://phpackages.com/packages/rubikalib-rubikalib)
```

###  Alternatives

[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k96.9M674](/packages/laravel-socialite)[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k85.0M531](/packages/laravel-passport)[statamic/cms

The Statamic CMS Core Package

4.8k3.2M720](/packages/statamic-cms)[aporat/store-receipt-validator

PHP receipt validator for Apple App Store and Amazon Appstore

6503.9M9](/packages/aporat-store-receipt-validator)[team-reflex/discord-php

An unofficial API to interact with the voice and text service Discord.

1.1k379.4k24](/packages/team-reflex-discord-php)[paragonie/ciphersweet

Searchable field-level encryption library for relational databases

4641.2M21](/packages/paragonie-ciphersweet)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
