src/AbstractWrapperCommands.php
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;
    }
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;
    }
Executes a command on the telegram-cli. Line-breaks will be escaped, as telgram-cli does not support them.

@param string $command The command, including all arguments

@return boolean|string Returns the answer as string or true on success, false if there was an error.