public function exec($command)
    {
        fwrite($this->_fp, str_replace("\n", '\n', $command) . PHP_EOL);

        $answer = fgets($this->_fp); //"ANSWER $bytes" if there is a return value or \n if not
        if (is_string($answer)) {
            if (substr($answer, 0, 7) === 'ANSWER ') {
                $bytes = (int) substr($answer, 7);
                if ($bytes > 0) {
                    $jsonObj = json_decode(trim(fread($this->_fp, $bytes + 1)));

                    if (is_null($jsonObj)) {
                        return 'You must enable the json flag on the telegram daemon to get proper response messages here.';
                    }

                    return $jsonObj;
                }
            } else {
                return $answer;
            }
        }

        return false;
    }