diff --git a/bot.php b/bot.php index 7651388c..36d1959f 100755 --- a/bot.php +++ b/bot.php @@ -13,7 +13,7 @@ If not, see . set_include_path(get_include_path().':'.realpath(dirname(__FILE__).'/MadelineProto/')); require 'vendor/autoload.php'; -$settings = ['app_info' => ['api_id' => 6, 'api_hash' => 'eb06d4abfb49dc3eeb1aeb98ae0f581e'], 'connection_settings' => ['all' => ['protocol' => 'tcp_abridged', 'pfs' => true]]]; +$settings = ['app_info' => ['api_id' => 6, 'api_hash' => 'eb06d4abfb49dc3eeb1aeb98ae0f581e']];//, 'connection_settings' => ['all' => ['test_mode' => true]]]; try { $MadelineProto = new \danog\MadelineProto\API('bot.madeline'); diff --git a/src/danog/MadelineProto/API.php b/src/danog/MadelineProto/API.php index 25535703..d82289e2 100644 --- a/src/danog/MadelineProto/API.php +++ b/src/danog/MadelineProto/API.php @@ -49,9 +49,7 @@ class API extends APIFactory } catch (\danog\MadelineProto\Bug74586Exception $e) { $unserialized = \danog\Serialization::unserialize($tounserialize); } catch (\danog\MadelineProto\Exception $e) { - if (Logger::$constructed) { - Logger::log([(string) $e], Logger::ERROR); - } + Logger::log([(string) $e], Logger::ERROR); if (strpos($e->getMessage(), "Erroneous data format for unserializing 'phpseclib\Math\BigInteger'") === 0) { $tounserialize = str_replace('phpseclib\Math\BigInteger', 'phpseclib\Math\BigIntegor', $unserialized); } diff --git a/src/danog/MadelineProto/Exception.php b/src/danog/MadelineProto/Exception.php index 85b43a48..ad02a107 100644 --- a/src/danog/MadelineProto/Exception.php +++ b/src/danog/MadelineProto/Exception.php @@ -37,9 +37,7 @@ class Exception extends \Exception } parent::__construct($message, $code, $previous); - if (\danog\MadelineProto\Logger::$constructed) { - \danog\MadelineProto\Logger::log([$message.' in '.basename($this->file).':'.$this->line], \danog\MadelineProto\Logger::FATAL_ERROR); - } + \danog\MadelineProto\Logger::log([$message.' in '.basename($this->file).':'.$this->line], \danog\MadelineProto\Logger::FATAL_ERROR); if (in_array($message, ['The session is corrupted!', 'Re-executing query...', 'I had to recreate the temporary authorization key', 'This peer is not present in the internal peer database', "Couldn't get response", 'Chat forbidden', 'The php-libtgvoip extension is required to accept and manage calls. See daniil.it/MadelineProto for more info.', 'File does not exist', 'Please install this fork of phpseclib: https://github.com/danog/phpseclib'])) { return; } diff --git a/src/danog/MadelineProto/Logger.php b/src/danog/MadelineProto/Logger.php index bc689726..d385a590 100644 --- a/src/danog/MadelineProto/Logger.php +++ b/src/danog/MadelineProto/Logger.php @@ -83,7 +83,6 @@ class Logger public static $storage = []; public static $mode = 1; public static $optional = null; - public static $constructed = false; public static $prefix = ''; public static $level = 3; public static $has_thread = false; @@ -150,7 +149,6 @@ class Logger } self::$mode = $mode; self::$optional = $optional; - self::$constructed = true; self::$prefix = $prefix === '' ? '' : ', '.$prefix; self::$level = $level; self::class_exists(); @@ -164,9 +162,7 @@ class Logger if ($level > self::$level) { return false; } - if (!self::$constructed) { -// throw new Exception(\danog\MadelineProto\Lang::$current_lang['constructor_function_uncalled']); - } + $prefix = self::$prefix; if (\danog\MadelineProto\Logger::$has_thread && is_object(\Thread::getCurrentThread())) { $prefix .= ' (t)'; diff --git a/src/danog/MadelineProto/Serialization.php b/src/danog/MadelineProto/Serialization.php index 4ffe88dc..6f6f828f 100644 --- a/src/danog/MadelineProto/Serialization.php +++ b/src/danog/MadelineProto/Serialization.php @@ -103,9 +103,7 @@ class Serialization } catch (\danog\MadelineProto\Bug74586Exception $e) { $unserialized = \danog\Serialization::unserialize($tounserialize); } catch (\danog\MadelineProto\Exception $e) { - if (Logger::$constructed) { - Logger::log([(string) $e], Logger::ERROR); - } + Logger::log([(string) $e], Logger::ERROR); if (strpos($e->getMessage(), "Erroneous data format for unserializing 'phpseclib\Math\BigInteger'") === 0) { $tounserialize = str_replace('phpseclib\Math\BigInteger', 'phpseclib\Math\BigIntegor', $unserialized); }