$button3 = (new InlineKeyboardButton('Show text'))->setCallbackData('text'); $button4 = (new InlineKeyboardButton('Show alert'))->setCallbackData('alert'); $markupData = [[$button1], [$button3, $button4]]; $this->inlineKeyboardMarkup = new InlineKeyboardMarkup($markupData); } else { $this->inlineKeyboardMarkup = null; } $method = new EditMessageReplyMarkup(); $method->setMessageId($this->message->messageId); $method->setChatId($this->message->chat->id); $method->setReplyMarkup($this->inlineKeyboardMarkup); $this->message = (yield from $this->api->execute($method)); } protected function endCommand() : \Generator { $this->state = self::STATE_WAITING_MESSAGE; $method = new SendMessage($this->message->chat->id, "Edit mode cancelled"); $this->message = null; yield from $this->api->execute($method); } } $bot = new Bot(); $coroutine = new Coroutine($bot->coroutine()); $coroutine->done(null, function (\Throwable $exception) { echo "Exception catched:\n"; echo " Code: {$exception->getCode()}\n"; echo " Message: {$exception->getMessage()}\n"; echo " File: {$exception->getFile()}\n"; echo " Line: {$exception->getLine()}\n"; }); Loop\run();