|
|
@ -7,6 +7,7 @@ from db_driver import Database |
|
|
|
from json import load |
|
|
|
from discord_alarm import DiscordAlarm |
|
|
|
from post_effect import PostEffect |
|
|
|
import asyncio |
|
|
|
|
|
|
|
class TradeChecker: |
|
|
|
APP_ID = 440 |
|
|
@ -60,6 +61,8 @@ class SteamClient(SteamPy.Client): |
|
|
|
discord_alarm = None |
|
|
|
post_effect = None |
|
|
|
|
|
|
|
trade_tracker = {} |
|
|
|
|
|
|
|
async def on_ready(self): |
|
|
|
info(f"Logged in as: {self.user}") |
|
|
|
|
|
|
@ -103,10 +106,28 @@ class SteamClient(SteamPy.Client): |
|
|
|
info(f"[{trade.id}] Try accept trade") |
|
|
|
await send_msg(trade, "Попытка принять трейд...") |
|
|
|
await trade.accept() |
|
|
|
#Force on trade accept |
|
|
|
asyncio.sleep(3) |
|
|
|
if not trade.id in self.trade_tracker: |
|
|
|
self.trade_tracker[trade.id] = 60 |
|
|
|
|
|
|
|
while self.trade_tracker[trade.id] > 2: |
|
|
|
asyncio.sleep(1) |
|
|
|
self.trade_tracker[trade.id] -= 1 |
|
|
|
await self.on_trade_accept(trade) |
|
|
|
return |
|
|
|
|
|
|
|
#Принятый трейд |
|
|
|
async def on_trade_accept(self, trade: SteamPy.TradeOffer): |
|
|
|
if trade.id in self.trade_tracker and self.trade_tracker[trade.id] == 0: |
|
|
|
return |
|
|
|
|
|
|
|
if trade.id in self.trade_tracker and self.trade_tracker[trade.id] > 0: |
|
|
|
self.trade_tracker[trade.id] = 0 |
|
|
|
|
|
|
|
if not trade.id in self.trade_tracker: |
|
|
|
self.trade_tracker[trade.id] = 0 |
|
|
|
|
|
|
|
if not trade.is_gift(): |
|
|
|
return |
|
|
|
|
|
|
|