Core: Restrict using commands from the other chats

Created on 9 Nov 2017  路  2Comments  路  Source: php-telegram-bot/core

Is it possible to restrict the use of ALL commands for just one chat ID? How can I do this?
Sorry for my English.

Most helpful comment

You could extend Telegram class and ovewrite executeCommand()

use Longman\TelegramBot\Telegram;
use Longman\TelegramBot\Request;

class MyTelegram extends Telegram {
  public function executeCommand($command) {
    if($this->update->getMessage()) {
      if($this->update->getMessage()->getChat()->getId() == 123456) {
        return Request::emptyResponse();
      }
    }
    return parent::executeCommand($command);
  }
}

All 2 comments

You could extend Telegram class and ovewrite executeCommand()

use Longman\TelegramBot\Telegram;
use Longman\TelegramBot\Request;

class MyTelegram extends Telegram {
  public function executeCommand($command) {
    if($this->update->getMessage()) {
      if($this->update->getMessage()->getChat()->getId() == 123456) {
        return Request::emptyResponse();
      }
    }
    return parent::executeCommand($command);
  }
}

Thankee!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TheSleepySlee picture TheSleepySlee  路  3Comments

Recouse picture Recouse  路  3Comments

sayjeyhi picture sayjeyhi  路  3Comments

marcolino7 picture marcolino7  路  3Comments

noplanman picture noplanman  路  3Comments