PHPackages                             hitmare/unlockptb - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. hitmare/unlockptb

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

hitmare/unlockptb
=================

PHP Telegram Bot Lock and Unlock

1.2.2(8y ago)1722MITPHPPHP ^5.5|^7.0

Since Sep 19Pushed 8y ago2 watchersCompare

[ Source](https://github.com/Hitmare/unlockPTB)[ Packagist](https://packagist.org/packages/hitmare/unlockptb)[ Docs](https://github.com/Hitmare/unlockPTB)[ RSS](/packages/hitmare-unlockptb/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (1)Versions (12)Used By (0)

unlockPTB
=========

[](#unlockptb)

Table of Contents
-----------------

[](#table-of-contents)

- [Introduction](#introduction)
- [Instructions](#instructions)
    - [Installation](#installation)
    - [Add the Lockstatus Check to your Files](#add-the-lockstatus-check-to-your-files)
    - [How to use](#how-to-use)
    - [Aviable Commands](#aviable-commands)
        - [Installation of the Commands](#installation-of-the-commands)

Introduction
------------

[](#introduction)

This is unlock Class for the PHP Telegram Bot Libary to lock an unlock the Bot in Private and Group Channels

Instructions
------------

[](#instructions)

### Installation

[](#installation)

Install this package through \[Composer\]\[composer\]. Edit your project's `composer.json` file to require `hitmare/unlockptb`.

Edit *composer.json* file and add `hitmare/unlockptb` under require

```
{
    "name": "yourproject/yourproject",
    "type": "project",
    "require": {
        "php": ">=5.5",
        "longman/telegram-bot": "*",
        "hitmare/unlockptb": "*"
    }
}
```

and run `composer update`

**or**

run this command in your command line:

```
composer require hitmare/unlockptb
```

- Then you have to import the `chat_unlock.sql` file into your existend Telegram Database
- Add the following into the `hook.php` where `$telegram->setCommandConfig` is located

```
    $unlockptb = array('private','group','supergroup');
    $telegram->setCommandConfig('lockstatus', ['lockChat' => $unlockptb]);
    $telegram->setCommandConfig('lock', ['lockChat' => $unlockptb]);
    $telegram->setCommandConfig('unlock', ['lockChat' => $unlockptb]);
```

You also have to add for every Command what you want to lock a CommandConfig line in the `hook.php`
eg

```
    $telegram->setCommandConfig('lockedcommand', ['lockChat' => $unlockptb]);
```

### Add the Lockstatus Check to your Files

[](#add-the-lockstatus-check-to-your-files)

To use the Libary you have to add the Code for checking the Lockstatus in every Command File where you want to include the Lock function. At the Moment it is, as far as i know, the only way to implement this without editing the Main Code of the Bot

- Add the required Namespace

```
    use Hitmare\UnlockPTB\Unlock;
```

- Add the Lockstatus Check as first inside the `execute()` funciton

```
    $message    = $this->getMessage();
    $chat_id    = $message->getChat()->getId();
    $isUnlocked = Unlock::isUnlocked($chat_id);

    $lockChat = $this->getConfig('lockChat');
    $thisChat = $message->getChat()->getType();
    //Check if the lock applys to this Chat Type
    if (in_array($thisChat,$lockChat)) {
      //Check if Command is unlocked
      if (!$isUnlocked) {
        $data = ['chat_id' => $chat_id, 'text' => 'This Command is locked inside this Chat'];
        return Request::sendMessage($data);
      }
    }

    // Your Code down here
```

To define in wich Type of Chat the Lock should applys, just add or delete the Chat type in the `hoop.php`

```
    $unlockptb = array('private','group','supergroup');
```

The Lock applys to every Chat that matches the type of the Array above.

### How to use

[](#how-to-use)

1. Generate the Authkey

To generate the Authkey there are two ways:
Get the wanted Chat or User ID through the `/chats *` Command and execute `/getAutchkey ` directly to the Bot

**OR**

*(Only for Group Chats)* Execute `/getAutchkey` inside of the Group Chat and the Bot will send the Botadmin who send the Command the Authkey

2. Unlock the Bot For Private Chat:
    - Execute `/unlock ` and the Bot will be unlocked. For Group Chats:
    - Execute `/unlock ` as an **Bot Admin** or as an **Channel Owner** and the Bot will be unlocked.

To Lock the Bot execute `/lock`. In Group Chats only the Bot Admin and the Group Chat Owner can use it
To Show the Lockstatus execute `/lockstatus`. In Group Chats only the Bot Admin and the Group Chat Owner can use it

### Aviable Commands

[](#aviable-commands)

This Library includes four (4) Commands

- `/getAuthkey` - Generates the Unlock Authkey. Can only be used from Bot Admin
- `/unlock` - Unlocks the Bot. In Group Chats only the Bot Admin and the Group Chat Owner can use it
- `/lock` - Locks the Bot. In Group Chats only the Bot Admin and the Group Chat Owner can use it
- `/lockstatus` - Shows the Lockstatus of the Bot. In Group Chats only the Bot Admin and the Group Chat Owner can use it

#### Installation of the Commands

[](#installation-of-the-commands)

You can copy all four Commands into your custom Command folder or add the following path to your custom Command array inside of your `hook.php` to stay up to date with your Commandfiles

```
/vendor/hitmare/unlockptb/Commands/

```

eg:

```
$commands_path = [
__DIR__ . '/Commands/',
__DIR__ . '/vendor/hitmare/unlockptb/Commands/',
];

```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 94% 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 ~3 days

Total

11

Last Release

3131d ago

### Community

Maintainers

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

---

Top Contributors

[![Hitmare](https://avatars.githubusercontent.com/u/4587594?v=4)](https://github.com/Hitmare "Hitmare (63 commits)")[![noplanman](https://avatars.githubusercontent.com/u/9423417?v=4)](https://github.com/noplanman "noplanman (4 commits)")

---

Tags

bottelegramunlock

### Embed Badge

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

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

###  Alternatives

[php-telegram-bot/telegram-bot-manager

PHP Telegram Bot Manager

22014.5k](/packages/php-telegram-bot-telegram-bot-manager)[formapro/telegram-bot

PHP Telegram Bot

2532.5k](/packages/formapro-telegram-bot)[onmotion/yii2-telegram

Support chat for site based on Telegram bot

526.3k](/packages/onmotion-yii2-telegram)

PHPackages © 2026

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