|
|
@ -75,11 +75,11 @@ class SteamClient(SteamPy.Client): |
|
|
|
items = None |
|
|
|
trade_tracker = {} |
|
|
|
backend : BackendClient = None |
|
|
|
backend_checker_enable = False |
|
|
|
|
|
|
|
async def on_ready(self): |
|
|
|
info(f"Logged in as: {self.user}") |
|
|
|
prices = await self.backend.prices() |
|
|
|
self.items = TradeChecker(prices) |
|
|
|
asyncio.ensure_future(self.backend_checker) |
|
|
|
|
|
|
|
async def on_connect(self): |
|
|
|
await self.backend.pulse() |
|
|
@ -89,12 +89,24 @@ class SteamClient(SteamPy.Client): |
|
|
|
await self.backend.pulse() |
|
|
|
ok("Disconnect from steam") |
|
|
|
|
|
|
|
async def update_prices(self, exit_if_error = False): |
|
|
|
prices = await self.backend.prices(exit_if_error) |
|
|
|
self.items = TradeChecker(prices) |
|
|
|
|
|
|
|
async def backend_checker(self, timeout=60): |
|
|
|
if not self.backend_checker_enable: |
|
|
|
info(f"Check backend stats every {timeout} seconds") |
|
|
|
self.backend_checker_enable = True |
|
|
|
while True: |
|
|
|
await self.backend.pulse(True) |
|
|
|
await self.update_prices(True) |
|
|
|
await asyncio.sleep(timeout) |
|
|
|
|
|
|
|
#Проверка шмота на леквид |
|
|
|
async def on_trade_receive(self, trade: SteamPy.TradeOffer): |
|
|
|
if not self.items: |
|
|
|
info("prices is not setup") |
|
|
|
prices = await self.backend.prices() |
|
|
|
self.items = TradeChecker(prices) |
|
|
|
await self.update_prices() |
|
|
|
|
|
|
|
info(f"[{trade.id}] Incoming trade from [{trade.partner.id}] {trade.partner.name}") |
|
|
|
|
|
|
@ -181,7 +193,7 @@ class SteamClient(SteamPy.Client): |
|
|
|
if __name__ == "__main__": |
|
|
|
print(f"Build date: {os.getenv('BUILDDATE', 'not set')}") |
|
|
|
backend = BackendClient() |
|
|
|
asyncio.get_event_loop().run_until_complete(backend.pulse()) |
|
|
|
asyncio.get_event_loop().run_until_complete(backend.pulse(True)) |
|
|
|
if not backend.up: |
|
|
|
print("backend not working down bot") |
|
|
|
sys.exit(200) |
|
|
|