This commit is contained in:
Daniil Gentili 2017-07-26 08:54:13 +02:00
commit c6114c6c71
8 changed files with 26 additions and 9 deletions

View File

@ -15,9 +15,12 @@ namespace danog\MadelineProto;
class Exception extends \Exception
{
use TL\PrettyException;
public function __toString() {
public function __toString()
{
return $this->file === 'MadelineProto' ? $this->message : '\danog\MadelineProto\Exception'.($this->message !== '' ? ': ' : '').$this->message.' in '.$this->file.':'.$this->line.PHP_EOL.'TL Trace:'.PHP_EOL.$this->getTLTrace();
}
public function __construct($message = null, $code = 0, Exception $previous = null, $file = null, $line = null)
{
$this->prettify_tl();

View File

@ -111,7 +111,7 @@ class Logger
throw new \danog\MadelineProto\Exception(hex2bin('506c656173652075706461746520746f20746865206c61746573742076657273696f6e206f66204d6164656c696e6550726f746f2e'), 0, null, 'MadelineProto', 1);
}
if (class_exists('\danog\MadelineProto\VoIP')) {
if (!defined('\danog\MadelineProto\VoIP::PHP_LIBTGVOIP_VERSION') || \danog\MadelineProto\VoIP::PHP_LIBTGVOIP_VERSION !== "1.1") {
if (!defined('\danog\MadelineProto\VoIP::PHP_LIBTGVOIP_VERSION') || \danog\MadelineProto\VoIP::PHP_LIBTGVOIP_VERSION !== '1.1') {
throw new \danog\MadelineProto\Exception(hex2bin('506c6561736520757064617465207068702d6c69627467766f6970'), 0, null, 'MadelineProto', 1);
}
try {

View File

@ -273,7 +273,7 @@ class MTProto extends \Volatile
foreach ($this->calls as $id => $controller) {
if (!is_object($controller)) {
unset($this->calls[$id]);
} else if ($controller->getCallState() === \danog\MadelineProto\VoIP::CALL_STATE_ENDED) {
} elseif ($controller->getCallState() === \danog\MadelineProto\VoIP::CALL_STATE_ENDED) {
$controller->setMadeline($this);
$controller->discard();
} else {

View File

@ -249,7 +249,7 @@ trait CallHandler
$server_answer = [$server_answer];
foreach ($message_chunks as $message) {
$args['message'] = $message;
$server_answer[]= $this->method_call($method, $args, $aargs);
$server_answer[] = $this->method_call($method, $args, $aargs);
}
}

View File

@ -15,7 +15,12 @@ namespace danog\MadelineProto;
class RPCErrorException extends \Exception
{
use TL\PrettyException;
public function __toString() { return 'Telegram returned an RPC error: '.$this->message.' ('.$this->rpc.'), caused by '.$this->file.':'.$this->line.PHP_EOL.PHP_EOL.'TL trace:'.PHP_EOL.$this->getTLTrace().PHP_EOL; }
public function __toString()
{
return 'Telegram returned an RPC error: '.$this->message.' ('.$this->rpc.'), caused by '.$this->file.':'.$this->line.PHP_EOL.PHP_EOL.'TL trace:'.PHP_EOL.$this->getTLTrace().PHP_EOL;
}
public function __construct($message = null, $code = 0, Exception $previous = null)
{
$this->rpc = $message;

View File

@ -62,7 +62,8 @@ class Serialization
$unserialized = \danog\Serialization::unserialize($unserialized);
/*} catch (Exception $e) {
$unserialized = \danog\Serialization::unserialize($unserialized);
*/} catch (\Error $e) {
*/
} catch (\Error $e) {
$unserialized = \danog\Serialization::unserialize($unserialized);
}
} else {

View File

@ -232,7 +232,9 @@ trait BotAPI
return $data;
case 'messageMediaPhoto':
if (isset($data['caption'])) $res['caption'] = $data['caption'];
if (isset($data['caption'])) {
$res['caption'] = $data['caption'];
}
$res['photo'] = [];
foreach ($data['photo']['sizes'] as $key => $photo) {
$res['photo'][$key] = $this->photosize_to_botapi($photo, $data['photo']);

View File

@ -15,8 +15,14 @@ namespace danog\MadelineProto\TL;
class Exception extends \Exception
{
use PrettyException;
public function __toString() { return get_class($this).($this->message !== '' ? ': ' : '').$this->message.PHP_EOL.'TL Trace'.PHP_EOL.PHP_EOL.$this->getTLTrace().PHP_EOL; }
public function __construct($message, $file = '') {
public function __toString()
{
return get_class($this).($this->message !== '' ? ': ' : '').$this->message.PHP_EOL.'TL Trace'.PHP_EOL.PHP_EOL.$this->getTLTrace().PHP_EOL;
}
public function __construct($message, $file = '')
{
parent::__construct($message);
$this->prettify_tl($file);
}