From 5e5bab91f2bf84badff95b11a34c87201c19aca0 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 16 Jul 2026 13:39:37 +0500 Subject: [PATCH] fix(api): handle None merchant_id in lolzteam initialization --- tgbot/routers/admin/admin_payments.py | 2 +- tgbot/services/api_lolzteam.py | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/tgbot/routers/admin/admin_payments.py b/tgbot/routers/admin/admin_payments.py index 6d90e15..e035aab 100644 --- a/tgbot/routers/admin/admin_payments.py +++ b/tgbot/routers/admin/admin_payments.py @@ -272,7 +272,7 @@ async def payments_lolzteam_get(message: Message, bot: Bot, state: FSM, arSessio update=message, skipping_error=True, token=get_token, - merchant_id=None, + merchant_id="None", ) ).check() diff --git a/tgbot/services/api_lolzteam.py b/tgbot/services/api_lolzteam.py index abe383f..02b464f 100644 --- a/tgbot/services/api_lolzteam.py +++ b/tgbot/services/api_lolzteam.py @@ -62,13 +62,16 @@ class LolzteamAPI: ) -> "LolzteamAPI": adding = token is not None - if token is None: + if token is None or merchant_id is None: payments = await Paymentsx().get() adding = False if token is None: token = payments.lolzteam_token + if merchant_id is None: + merchant_id = payments.lolzteam_merchant_id + return cls( bot=bot, arSession=arSession, @@ -100,7 +103,17 @@ class LolzteamAPI: async def check(self) -> Tuple[bool, str]: status, response = await self._request("me", method="GET") - if status and "errors" not in response and self.merchant_id: + if status and "errors" not in response and self.merchant_id == "None": + return True, ded( + f""" + 🟢 Lolzteam функционирует ✅ + ➖➖➖➖➖➖➖➖➖➖ + ▪️ Токен: {self.token} + ▪️ Айди: {response['user']['user_id']} + """ + ) + + elif status and "errors" not in response: # ! Проверка этим способом не работает для мерчантов, у которых нет отдельного # ! баланса на маркете, и поэтому используется способ ниже # balances = response["user"]["balances"] @@ -125,16 +138,6 @@ class LolzteamAPI: """ ) - elif status and "errors" not in response: - return True, ded( - f""" - 🟢 Lolzteam функционирует ✅ - ➖➖➖➖➖➖➖➖➖➖ - ▪️ Токен: {self.token} - ▪️ Айди: {response['user']['user_id']} - """ - ) - return False, "🟢 Не удалось проверить Lolzteam ❌" # Получение баланса