From 1a6e2972a235f6a2efa3ae326815aa82e9c4100d Mon Sep 17 00:00:00 2001 From: gsd Date: Sat, 18 Apr 2026 22:22:16 +0300 Subject: [PATCH] alive pusher --- tradebot.facti13.external.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tradebot.facti13.external.py b/tradebot.facti13.external.py index ca0eead..68c9ac9 100644 --- a/tradebot.facti13.external.py +++ b/tradebot.facti13.external.py @@ -6,6 +6,7 @@ from colors import * from json import load import asyncio from steam.errors import Forbidden as STEAM_FORBIDDEN +import aiohttp from backend_integration import BackendClient @@ -77,9 +78,13 @@ class SteamClient(SteamPy.Client): backend : BackendClient = None backend_checker_enable = False + backend_checker_is_runned = False + alive_checker_is_runned = False + async def on_ready(self): info(f"Logged in as: {self.user}") asyncio.ensure_future(self.backend_checker(60)) + asyncio.ensure_future(self.alive_pusher()) async def on_connect(self): await self.backend.pulse() @@ -93,7 +98,27 @@ class SteamClient(SteamPy.Client): prices = await self.backend.prices(exit_if_error) self.items = TradeChecker(prices) + async def alive_pusher(self): + if self.alive_checker_is_runned: + return + else: + self.alive_checker_is_runned = True + + url = os.getenv("ALIVE_PUSH") + while url: + try: + async with aiohttp.ClientSession() as session: + async with session.get(os.getenv("ALIVE_PUSH") + f'${round(self.latency * 1000)}', ssl = False) as response: + tmp = await response.text() + except: + pass + async def backend_checker(self, timeout=60): + if self.backend_checker_is_runned: + return + else: + self.backend_checker_is_runned = True + if not self.backend_checker_enable: info(f"Check backend stats every {timeout} seconds") self.backend_checker_enable = True