Implementing the Library into your Bot - Hitmare/unlockPTB GitHub Wiki

To use this Library you have to add the following into every Command file you want to get 'locked'

At top of the File under your Namespace add

use Hitmare\UnlockPTB\Unlock;

eg:

namespace Longman\TelegramBot\Commands\UserCommands;
use Hitmare\UnlockPTB\Unlock;
use Longman\TelegramBot\Commands\Command;
use Longman\TelegramBot\Commands\UserCommand;
use Longman\TelegramBot\Request;

Then you have to add this Code into your execute() function

$message = $this->getMessage();
$chat_id = $message->getChat()->getId();
$locktext = 'This Command is locked in this Chat';

if(!Unlock::isUnlocked($chat_id)){
$data = ['chat_id' => $chat_id,'text' => $locktext];
return Request::sendMessage($data);
}

eg:

public function execute()
{
$message = $this->getMessage();
$chat_id = $message->getChat()->getId();
$locktext = 'This Command is locked in this Chat';

if(!Unlock::isUnlocked($chat_id)){
$data = ['chat_id' => $chat_id,'text' => $locktext];
return Request::sendMessage($data);
}

// your command code eg:
$data = ['chat_id' => $chat_id,'text' => 'Hello'];
return Request::sendMessage($data);
}

You also have to import the chat_unlock.sql into your PHP Telegram Bot Database