diff --git a/src/danog/MadelineProto/Exception.php b/src/danog/MadelineProto/Exception.php index 0fe97048..257951dc 100644 --- a/src/danog/MadelineProto/Exception.php +++ b/src/danog/MadelineProto/Exception.php @@ -28,7 +28,7 @@ class Exception extends \Exception if (\danog\MadelineProto\Logger::$constructed) { \danog\MadelineProto\Logger::log([$errstr.' in '.basename($errfile).':'.$errline], \danog\MadelineProto\Logger::FATAL_ERROR); } - $e = new \danog\MadelineProto\Exception($errstr, $errno); + $e = new self($errstr, $errno); $e->file = $errfile; $e->line = $errline; throw $e; diff --git a/src/danog/MadelineProto/MTProtoTools/PeerHandler.php b/src/danog/MadelineProto/MTProtoTools/PeerHandler.php index 15840e39..627d4f49 100644 --- a/src/danog/MadelineProto/MTProtoTools/PeerHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/PeerHandler.php @@ -180,13 +180,13 @@ trait PeerHandler } if (preg_match('/^channel#/', $id)) { - $id = str_replace('channel#', '-100', $id); + $id = preg_replace('|\D+|', '-100', $id); } if (preg_match('/^chat#/', $id)) { - $id = str_replace('chat#', '-', $id); + $id = preg_replace('|\D+|', '-', $id); } if (preg_match('/^user#/', $id)) { - $id = str_replace('user#', '', $id); + $id = preg_replace('|\D+|', '', $id); } if (is_numeric($id)) { diff --git a/src/danog/MadelineProto/TL/Extension.php b/src/danog/MadelineProto/TL/Extension.php index 4d39fbf0..65c4583d 100644 --- a/src/danog/MadelineProto/TL/Extension.php +++ b/src/danog/MadelineProto/TL/Extension.php @@ -419,6 +419,7 @@ trait Extension { $this->switch_dc($location['dc_id']); $res = $this->method_call('upload.getFile', ['location' => $location, 'offset' => 0, 'limit' => 1], ['heavy' => true]); + if (!isset($res['type']['_'])) return $default; switch ($res['type']['_']) { case 'storage.fileJpeg': return '.jpg'; case 'storage.fileGif': return '.gif';