private function commandReply($message) { $telegramId = $message['from']['id']; $tg = TelegramUser::findByTelegramId($telegramId); $params = array('chat_id' => $telegramId); if ($tg->status == 'revoke_access') { $clientId = preg_replace('/[^0-9,.]/', '', $message['text']); try { $app = App::findByClientId($clientId); $auth = Auth::findByAppAndTelegramUser($app, $tg); $auth->active = false; $auth->save(); $text = 'Access to this app has been revoked.'; $tg->status = 'access_revoked'; $params['reply_markup'] = json_encode(['hide_keyboard' => true]); } catch (ModelNotFoundException $e) { $text = 'Unknown app. Please choose an app from the given list:'; } } else { $text = 'Unknown command.'; $tg->status = 'unknown_command'; $params['reply_markup'] = json_encode(['hide_keyboard' => true]); } $params['text'] = $text; $this->send($params); $tg->save(); }