Longman\TelegramBot\Telegram::handle PHP Method

handle() public method

Handle bot request from webhook
public handle ( ) : boolean
return boolean
    public function handle()
    {
        $this->input = Request::getInput();
        if (empty($this->input)) {
            throw new TelegramException('Input is empty!');
        }
        $post = json_decode($this->input, true);
        if (empty($post)) {
            throw new TelegramException('Invalid JSON!');
        }
        if ($response = $this->processUpdate(new Update($post, $this->bot_name))) {
            return $response->isOk();
        }
        return false;
    }

Usage Example

 /**
  * @test
  */
 public function execute()
 {
     $result = $this->telegram->handle();
     $this->assertEquals('4', $result['text']);
     $this->assertEquals($this->message_id, $result['reply_to_message_id']);
     $this->assertEquals($this->chat_id, $result['chat_id']);
 }