MCPcopy Create free account
hub / github.com/HiddenCodeDevs/BlumTelegramBot / Tapper

Class Tapper

bot/core/tapper.py:26–349  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24
25
26class Tapper:
27
28 play_passes: int
29 farming_data: dict | None
30 _log: SessionLogger
31 _session: CloudflareScraper
32 _api: BlumApi
33 _balance: float
34
35 def __init__(self, tg_client: Client, log: SessionLogger):
36 self.tg_client = tg_client
37 self._log = log
38
39 async def auth(self, session: aiohttp.ClientSession):
40 self._api = BlumApi(session, self._log)
41 web_data_params = await get_tg_web_data(self.tg_client, self._log)
42 self._log.trace("Got init data for auth.")
43 if not web_data_params:
44 self._log.error("Auth error, not init_data from tg_web_data")
45 return
46 await self._api.login(web_data_params=web_data_params)
47 self._log.info("Account login successfully")
48
49 async def check_tribe(self):
50 try:
51 my_tribe = await self._api.get_my_tribe()
52 self._log.trace(f"my_tribe got: {my_tribe}")
53 if not isinstance(my_tribe, dict):
54 self._log.warning(f"Unknown my tribe data: {my_tribe}")
55 return
56 if my_tribe.get("blum_bug"):
57 return self._log.warning("<r>Blum or TG Bug!</r> Account in tribe, but tribe not loading and leaving.")
58 if my_tribe.get("title"):
59 self._log.info(f"My tribe <g>{my_tribe.get('title')}</g> ({my_tribe.get('chatname')})")
60
61 chat_name = settings.TRIBE_CHAT_TAG
62 if not chat_name or my_tribe.get("chatname") == chat_name:
63 return
64 await asyncio.sleep(uniform(0.1, 0.5))
65
66 chat_tribe = await self._api.search_tribe(chat_name)
67
68 if not chat_tribe or not chat_tribe.get("id"):
69 self._log.warning(f"Tribe chat tag from config '{chat_name}' not found")
70 settings.TRIBE_CHAT_TAG = None
71 return
72
73 if my_tribe.get('id') != chat_tribe.get('id'):
74 await asyncio.sleep(uniform(0.1, 0.5))
75 if my_tribe.get("title"):
76 await self._api.leave_tribe()
77 self._log.info(f"<r>Leave tribe {my_tribe.get('title')}</r>")
78 if await self._api.join_tribe(chat_tribe.get('id')):
79 self._log.success(f'Joined to tribe {chat_tribe["title"]}')
80 except Exception as error:
81 self._log.error(f"{traceback.format_exc()}")
82
83 async def get_tasks(self):

Callers 1

run_tapperFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected