From 54bc8a35cd122a6f7d05ed52dd7d0a98dc26d181 Mon Sep 17 00:00:00 2001 From: Tii Date: Fri, 18 Mar 2022 09:37:15 +0100 Subject: [PATCH 1/2] #1295 Make sure setCustomBotApiUri has an effect if Telegram object was already instantiated. --- src/Request.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Request.php b/src/Request.php index de663f41..599a437a 100644 --- a/src/Request.php +++ b/src/Request.php @@ -327,6 +327,10 @@ public static function setCustomBotApiUri(string $api_base_uri, string $api_base if ($api_base_download_uri !== '') { self::$api_base_download_uri = $api_base_download_uri; } + + if (self::$telegram) { + self::initialize(self::$telegram); + } } /** From dece5d2f4adc18e12ba0b52f4ce4a3c2f8e31274 Mon Sep 17 00:00:00 2001 From: Tii Date: Sun, 20 Mar 2022 16:46:41 +0100 Subject: [PATCH 2/2] Changed to an exception so it is at least understandable why it's not working. --- src/Request.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Request.php b/src/Request.php index 599a437a..6d90b614 100644 --- a/src/Request.php +++ b/src/Request.php @@ -323,14 +323,14 @@ public static function setClient(ClientInterface $client): void */ public static function setCustomBotApiUri(string $api_base_uri, string $api_base_download_uri = ''): void { + if (self::$client) { + throw new TelegramException('setCustomBotApiUri() needs to be called before the Telegram object gets instantiated.'); + } + self::$api_base_uri = $api_base_uri; if ($api_base_download_uri !== '') { self::$api_base_download_uri = $api_base_download_uri; } - - if (self::$telegram) { - self::initialize(self::$telegram); - } } /**