From caccecd999fdfff1a21d9ff2bf8ad9ff9dc6b3c3 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Wed, 12 Jun 2019 18:32:15 +0200 Subject: [PATCH] Remove rollbar dependency --- composer.json | 9 ++++----- src/danog/MadelineProto/Exception.php | 2 +- src/danog/MadelineProto/MTProto.php | 2 +- src/danog/MadelineProto/RPCErrorException.php | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 369606d8..004276ec 100644 --- a/composer.json +++ b/composer.json @@ -15,17 +15,16 @@ "phpseclib/phpseclib": "dev-master#27370df as 2.0.15", "vlucas/phpdotenv": "^3", "erusev/parsedown": "^1.6", - "rollbar/rollbar": "dev-master", "ext-mbstring": "*", "ext-json": "*", "ext-xml": "*", "ext-fileinfo": "*", "amphp/amp": "^2.0", - "amphp/websocket": "dev-master", - "amphp/websocket-client": "dev-master", + "amphp/websocket": "dev-master as 1", + "amphp/websocket-client": "dev-master as 1", "amphp/socket": "^0.10", "amphp/dns": "dev-master#aa1892bdf13b787d759df6f2523e8027a434d927 as v0.9.x-dev", - "amphp/artax": "dev-master", + "amphp/artax": "dev-master as 3.0.99", "amphp/file": "^0.3", "amphp/uri": "^0.1.4", "amphp/byte-stream": "^1.6", @@ -62,4 +61,4 @@ "url": "https://github.com/danog/dns" } ] -} \ No newline at end of file +} diff --git a/src/danog/MadelineProto/Exception.php b/src/danog/MadelineProto/Exception.php index 98a81616..0456ea26 100644 --- a/src/danog/MadelineProto/Exception.php +++ b/src/danog/MadelineProto/Exception.php @@ -67,7 +67,7 @@ class Exception extends \Exception if (strpos($message, 'pg_query') !== false || strpos($message, 'Undefined variable: ') !== false || strpos($message, 'socket_write') !== false || strpos($message, 'socket_read') !== false || strpos($message, 'Received request to switch to DC ') !== false || strpos($message, "Couldn't get response") !== false || strpos($message, 'Re-executing query...') !== false || strpos($message, "Couldn't find peer by provided") !== false || strpos($message, 'id.pwrtelegram.xyz') !== false || strpos($message, 'Please update ') !== false || strpos($message, 'posix_isatty') !== false) { return; } - if (self::$rollbar) { + if (self::$rollbar && class_exists('\\Rollbar\\Rollbar')) { \Rollbar\Rollbar::log(\Rollbar\Payload\Level::error(), $this, debug_backtrace(0)); } } diff --git a/src/danog/MadelineProto/MTProto.php b/src/danog/MadelineProto/MTProto.php index c8dff2a7..4e040dfd 100644 --- a/src/danog/MadelineProto/MTProto.php +++ b/src/danog/MadelineProto/MTProto.php @@ -819,7 +819,7 @@ class MTProto extends AsyncConstruct implements TLCallback public function setup_logger() { - if (isset($this->settings['logger']['rollbar_token']) && $this->settings['logger']['rollbar_token'] !== '') { + if (isset($this->settings['logger']['rollbar_token']) && $this->settings['logger']['rollbar_token'] !== '' && class_exists('\\Rollbar\\Rollbar')) { @\Rollbar\Rollbar::init(['environment' => 'production', 'root' => __DIR__, 'access_token' => isset($this->settings['logger']['rollbar_token']) && !in_array($this->settings['logger']['rollbar_token'], ['f9fff6689aea4905b58eec73f66c791d', '300afd7ccef346ea84d0c185ae831718', '11a8c2fe4c474328b40a28193f8d63f5', 'beef2d426496462ba34dcaad33d44a14']) || $this->settings['pwr']['pwr'] ? $this->settings['logger']['rollbar_token'] : 'c07d9b2f73c2461297b0beaef6c1662f'], false, false); } else { Exception::$rollbar = false; diff --git a/src/danog/MadelineProto/RPCErrorException.php b/src/danog/MadelineProto/RPCErrorException.php index 72b45f29..9e513840 100644 --- a/src/danog/MadelineProto/RPCErrorException.php +++ b/src/danog/MadelineProto/RPCErrorException.php @@ -191,7 +191,7 @@ class RPCErrorException extends \Exception if ($this->rpc !== $message) { $this->fetched = true; } - if (!self::$rollbar) { + if (!self::$rollbar || !class_exists('\\Rollbar\\Rollbar')) { return; } if (in_array($this->rpc, ['CHANNEL_PRIVATE', -404, -429, 'USERNAME_NOT_OCCUPIED', 'ACCESS_TOKEN_INVALID', 'AUTH_KEY_UNREGISTERED', 'SESSION_PASSWORD_NEEDED', 'PHONE_NUMBER_UNOCCUPIED', 'PEER_ID_INVALID', 'CHAT_ID_INVALID', 'USERNAME_INVALID', 'CHAT_WRITE_FORBIDDEN', 'CHAT_ADMIN_REQUIRED', 'PEER_FLOOD'])) {