Skip to content

fix: исправление зацикливание при ошибке 400 #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions bot/core/tapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"<light-yellow>{self.session_name}</light-yellow> | Successfully account register")
Expand Down Expand Up @@ -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"<light-yellow>{self.session_name}</light-yellow> | "
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)
Expand Down Expand Up @@ -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"<light-yellow>{self.session_name}</light-yellow> | Going sleep 1 hour")
logger.info(f"<light-yellow>{self.session_name}</light-yellow> | 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"<light-yellow>{self.session_name}</light-yellow> | 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 <c>{start_sleep:,}</c> 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")
23 changes: 14 additions & 9 deletions bot/utils/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import asyncio
import argparse
from itertools import cycle
import random

from pyrogram import Client
from better_proxy import Proxy
Expand Down Expand Up @@ -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)