|
|
@ -18,6 +18,8 @@ class Client: |
|
|
|
|
|
|
|
prices = {} |
|
|
|
|
|
|
|
backend_checker_enabled = False |
|
|
|
|
|
|
|
convert_map = { |
|
|
|
"month":30*24*60*60, |
|
|
|
"week":7*24*60*60, |
|
|
@ -43,7 +45,16 @@ class Client: |
|
|
|
print(await self.wallet.get_balance()) |
|
|
|
await self.backend.pulse() |
|
|
|
await self.update_prices_from_server() |
|
|
|
#Добавить фоновую проверку живности бека |
|
|
|
asyncio.ensure_future(self.backend_checker(60)) |
|
|
|
|
|
|
|
async def backend_checker(self, timeout = 60): |
|
|
|
if not self.backend_checker_enabled: |
|
|
|
self.backend_checker_enabled = True |
|
|
|
info(f"check backend every {timeout} seconds") |
|
|
|
while True: |
|
|
|
await self.backend.pulse(True) |
|
|
|
await self.update_prices_from_server() |
|
|
|
await asyncio.sleep(timeout) |
|
|
|
|
|
|
|
def build_handler(self): |
|
|
|
@self.qiwi_dp.transaction_handler() |
|
|
@ -94,7 +105,7 @@ class Client: |
|
|
|
if not self.prices: |
|
|
|
error("cannot get prices from server") |
|
|
|
sys.exit(228) |
|
|
|
info(f"prices: {self.prices}") |
|
|
|
#info(f"prices: {self.prices}") |
|
|
|
|
|
|
|
def price_checker(self, amount): |
|
|
|
seconds2give = 0 |
|
|
|