diff --git a/bot/core/tapper.py b/bot/core/tapper.py index a3f224f..8da938d 100644 --- a/bot/core/tapper.py +++ b/bot/core/tapper.py @@ -576,9 +576,9 @@ async def run(self, proxy: str | None) -> None: init_data = await self.get_tg_web_data(proxy=proxy) - http_client.headers['Authorization'] = await self.auth(http_client=http_client, init_data=init_data) while True: try: + http_client.headers['Authorization'] = await self.auth(http_client=http_client, init_data=init_data) status = await self.register(http_client=http_client, init_data=init_data) if status is True: logger.success(f"{self.session_name} | Successfully account register") @@ -622,13 +622,15 @@ async def run(self, proxy: str | None) -> None: if settings.AUTO_MISSION: missions = await self.get_missions(http_client=http_client) + if missions is None: + continue missions.sort() for id in missions: status = await self.do_mission(http_client=http_client, id=id) if status: logger.info(f"{self.session_name} | " f"Successfully done mission {id}") - await asyncio.sleep(0.1) + await asyncio.sleep(5) if settings.AUTO_LVL_UP: info = await self.get_balance(http_client=http_client) @@ -676,21 +678,24 @@ async def run(self, proxy: str | None) -> None: if settings.PLAY_HURTMEPLEASE_GAME: await self.play_game_6(http_client=http_client) - logger.info(f"{self.session_name} | Going sleep 1 hour") + logger.info(f"{self.session_name} | Going sleep 1,5 hour") - await asyncio.sleep(3600) + await asyncio.sleep(5400) except InvalidSession as error: raise error except Exception as error: logger.error(f"{self.session_name} | Unknown error: {error}") - await asyncio.sleep(delay=3) + await asyncio.sleep(delay=600) continue -async def run_tapper(tg_client: Client, proxy: str | None): +async def run_tapper(tg_client: Client, proxy: str | None, start_sleep: int): try: + logger.warning(f"{tg_client.name} | Start sleep {start_sleep:,} sec.") + await asyncio.sleep(start_sleep) + await Tapper(tg_client=tg_client).run(proxy=proxy) except InvalidSession: logger.error(f"{tg_client.name} | Invalid Session") diff --git a/bot/utils/launcher.py b/bot/utils/launcher.py index af93596..0194045 100644 --- a/bot/utils/launcher.py +++ b/bot/utils/launcher.py @@ -3,6 +3,7 @@ import asyncio import argparse from itertools import cycle +import random from pyrogram import Client from better_proxy import Proxy @@ -110,15 +111,19 @@ async def process() -> None: async def run_tasks(tg_clients: list[Client]): proxies = get_proxies() - proxies_cycle = cycle(proxies) if proxies else None - tasks = [ - asyncio.create_task( - run_tapper( - tg_client=tg_client, - proxy=next(proxies_cycle) if proxies_cycle else None, + proxies_cycle = cycle(proxies) if proxies else None + time: int = 0 + for tg_client in tg_clients: + tasks = [ + asyncio.create_task( + run_tapper( + tg_client=tg_client, + proxy=next(proxies_cycle) if proxies_cycle else None, + start_sleep=time + ) ) - ) - for tg_client in tg_clients - ] + + ] + time = time + 60 + random.randint(0, 60) await asyncio.gather(*tasks)