diff --git a/paybot.facti13.py b/paybot.facti13.py index 7d137f9..beb4165 100644 --- a/paybot.facti13.py +++ b/paybot.facti13.py @@ -9,7 +9,7 @@ from glQiwiApi.qiwi.exceptions import QiwiAPIError from backend_integration import BackendClient from colors import * -import os, sys +import os, sys, asyncio prices = { 20.0: 1*24*60*60, @@ -37,7 +37,6 @@ class Client: error("QIWI_APIKEY or QIWI_PHONENUMBER in not setted!") sys.exit(2) - self.backend = BackendClient() self.qiwi_dp = QiwiDispatcher() self.wallet = QiwiWallet(api_access_token=os.getenv("QIWI_APIKEY"), phone_number=os.getenv("QIWI_PHONENUMBER")) self.build_handler() @@ -48,6 +47,7 @@ class Client: async def on_startup(self, ctx: Context): print(await self.wallet.get_balance()) await self.backend.pulse() + #Добавить фоновую проверку живности бека def build_handler(self): @self.qiwi_dp.transaction_handler() @@ -80,9 +80,17 @@ class Client: ######################################## # add vip info(f"Add vip {steam2}, amount {seconds}") - await self.backend.vip(steam2, seconds, f"rub={int(money)}") + await self.backend.vip(steam2, seconds, f"rub={int(money)};") if __name__ == "__main__": print("Build date: "+os.getenv("BUILDDATE", "not setted")) + + backend = BackendClient() + asyncio.get_event_loop().run_until_complete(backend.pulse()) + if not backend.up: + print("backend not working down bot") + sys.exit(200) + client = Client() + client.backend = backend client.run() \ No newline at end of file