public function getChatId($chat_id = null) {
        try {
            if ($chat_id)
                return $chat_id;

            if( isset($this->result->message) ) {
                return $this->result->message->chat->id;
            } elseif ( isset($this->result->inline_query) ) {
                return $this->result->inline_query->from->id;
            } else {
                throw new \Exception("Error Processing Request", 1);
            }
        } catch (\Exception $e) {
            error_log($e->getMessage());
        }
    }