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

Method run

bot/core/tapper.py:292–349  ·  view source on GitHub ↗
(self, proxy: str | None)

Source from the content-addressed store, hash-verified

290 await self.update_user_balance()
291
292 async def run(self, proxy: str | None) -> None:
293 if not settings.DEBUG:
294 await self.random_delay()
295
296 ssl_context = TLSv1_3_BYPASS.create_ssl_context()
297 proxy_conn = ProxyConnector().from_url(url=str(proxy), ssl=ssl_context) if proxy \
298 else aiohttp.TCPConnector(ssl=ssl_context)
299 headers = default_headers.copy()
300 headers.update({'User-Agent': check_user_agent(self.tg_client.name)})
301 async with aiohttp.ClientSession(headers=headers, connector=proxy_conn) as session:
302 if proxy:
303 ip = await check_proxy(session)
304 if not ip:
305 self._log.warning(f"Proxy {proxy} not available. Waiting for the moment when it will work...")
306 ip = await wait_proxy(session)
307 self._log.info(f"Used proxy <y>{proxy}</y>. Real ip: <g>{ip}</g>")
308 set_proxy_for_tg_client(self.tg_client, proxy)
309 else:
310 self._log.warning("Proxy not installed! This may lead to account ban! Be careful.")
311 try:
312 await self.auth(session)
313 except TelegramProxyError:
314 return self._log.error(f"<r>The selected proxy cannot be applied to the Telegram client.</r>")
315 except Exception as e:
316 self._log.error(f"{traceback.format_exc()}")
317 return self._log.critical(f"Stop Tapper. Reason: {e}")
318
319 timer = 0
320 while True:
321 delta_time = time() - timer
322 sleep_time = uniform(
323 settings.SLEEP_MINUTES_BEFORE_ITERATIONS[0],
324 settings.SLEEP_MINUTES_BEFORE_ITERATIONS[1]
325 ) * 60
326 if delta_time <= sleep_time:
327 sleep_time = sleep_time - delta_time
328 self._log.info(f"Sleep <y>{format_duration(sleep_time)}</y> before next checks...")
329 await asyncio.sleep(sleep_time)
330 try:
331 await self.check_daily_reward()
332 await self.update_user_balance()
333 await self.update_points_balance(with_log=True)
334 await self.check_farming()
335 await self.check_friends_balance()
336 await self._api.elig_dogs()
337 # todo: add "api/v1/wallet/my/balance?fiat=usd", "api/v1/tribe/leaderboard" and another human behavior
338 await self.check_tribe()
339 need_recheck_tasks = await self.check_tasks()
340 await self.play_drop_game()
341 if need_recheck_tasks:
342 await self.check_tasks()
343 except NeedReLoginError:
344 await self.auth(session)
345 except Exception:
346 self._log.error(f"{traceback.format_exc()}")
347 self._log.error(f"<r>Unhandled error</r>")
348 await asyncio.sleep(delay=3)
349 timer = time()

Callers 2

main.pyFile · 0.80
run_tapperFunction · 0.80

Calls 15

random_delayMethod · 0.95
authMethod · 0.95
check_daily_rewardMethod · 0.95
update_user_balanceMethod · 0.95
update_points_balanceMethod · 0.95
check_farmingMethod · 0.95
check_friends_balanceMethod · 0.95
check_tribeMethod · 0.95
check_tasksMethod · 0.95
play_drop_gameMethod · 0.95
check_user_agentFunction · 0.90
check_proxyFunction · 0.90

Tested by

no test coverage detected