Skip to content

Commit b1d9ee0

Browse files
committed
add SLEEP_MINUTES_BEFORE_ITERATIONS config and logging to check tribe
1 parent 4957c6f commit b1d9ee0

File tree

4 files changed

+28
-16
lines changed

4 files changed

+28
-16
lines changed

.env-example

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ AUTO_TASKS=
1313
USE_RANDOM_DELAY_IN_RUN=
1414
RANDOM_DELAY_IN_RUN=
1515

16+
SLEEP_MINUTES_BEFORE_ITERATIONS=
17+
1618
# text after @
1719
TRIBE_CHAT_TAG=
1820

README.md

+14-12
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,20 @@
2121

2222

2323
## [Settings](https://github.com/HiddenCodeDevs/BlumTelegramBot/blob/main/.env-example/)
24-
| Settings | Description |
25-
|:---------------------------:|:----------------------------------------------------------------------------:|
26-
| **API_ID / API_HASH** | Platform data from which to run the Telegram session (default - android) |
27-
| **PLAY_GAMES** | Play games or just start farming (default is True) |
28-
| **POINTS** | Points per game (default is [190, 230] ((That is, 190 to 230) |
29-
| **AUTO_TASKS** | Do tasks or not (default is True) |
30-
| **TRIBE_CHAT_TAG** | Your tribe telegram tag for auto join |
31-
| **USE_RANDOM_DELAY_IN_RUN** | Name saying itself |
32-
| **RANDOM_DELAY_IN_RUN** | Random seconds delay for ^^^ (default is [5, 30] |
33-
| **USE_REF** | Register accounts with ur referral or not (default - False) |
34-
| **REF_ID** | Your referral argument (comes after app/startapp? in your referral link) |
35-
| **USE_PROXY_FROM_FILE** | Whether to use a proxy from the `bot/config/proxies.txt` file (True / False) |
24+
| Settings | Description |
25+
|:-----------------------------------:|:----------------------------------------------------------------------------:|
26+
| **API_ID / API_HASH** | Platform data from which to run the Telegram session (default - android) |
27+
| **PLAY_GAMES** | Play games or just start farming (default is True) |
28+
| **POINTS** | Points per game (default is [190, 230] ((That is, 190 to 230) |
29+
| **AUTO_TASKS** | Do tasks or not (default is True) |
30+
| **TRIBE_CHAT_TAG** | Your tribe telegram tag for auto join |
31+
| **USE_RANDOM_DELAY_IN_RUN** | Name saying itself |
32+
| **RANDOM_DELAY_IN_RUN** | Random seconds delay for ^^^ (default is [5, 30] |
33+
| **USE_REF** | Register accounts with ur referral or not (default - False) |
34+
| **REF_ID** | Your referral argument (comes after app/startapp? in your referral link) |
35+
| **USE_PROXY_FROM_FILE** | Whether to use a proxy from the `bot/config/proxies.txt` file (True / False) |
36+
| **SLEEP_MINUTES_BEFORE_ITERATIONS** | Sleep minutes between checks (default is [120, 600] ((That is, 120 to 600) |
37+
| **DEBUG** | Disable random delay in run and change log level to DEBUG |
3638

3739
## Quick Start 📚
3840

bot/config/config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Settings(BaseSettings):
2727
USE_PROXY_FROM_FILE: bool = False
2828

2929
DEBUG: bool = False
30-
SLEEP_SEC_BEFORE_ITERATIONS: int = 60 * 60 * 2
30+
SLEEP_MINUTES_BEFORE_ITERATIONS: list[int] = [120, 600]
3131

3232
try:
3333
settings = Settings()

bot/core/tapper.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ async def auth(self, session: CloudflareScraper):
4545
async def check_tribe(self):
4646
try:
4747
my_tribe = await self._api.get_my_tribe()
48+
self._log.debug(f"my_tribe got: {my_tribe}")
49+
if not isinstance(my_tribe, dict):
50+
self._log.warning(f"Unknown my tribe data: {my_tribe}")
51+
return
4852
if my_tribe.get("blum_bug"):
4953
return self._log.warning("<r>Blum or TG Bug!</r> Account in tribe, but tribe not loading and leaving.")
5054
if my_tribe.get("title"):
@@ -70,7 +74,7 @@ async def check_tribe(self):
7074
if await self._api.join_tribe(chat_tribe.get('id')):
7175
self._log.success(f'Joined to tribe {chat_tribe["title"]}')
7276
except Exception as error:
73-
self._log.error(f"Join tribe {error}")
77+
self._log.error(f"{traceback.format_exc()}")
7478

7579
async def get_tasks(self):
7680
try:
@@ -260,8 +264,12 @@ async def run(self, proxy: Proxy | None) -> None:
260264
timer = 0
261265
while True:
262266
delta_time = time() - timer
263-
if delta_time <= settings.SLEEP_SEC_BEFORE_ITERATIONS:
264-
sleep_time = settings.SLEEP_SEC_BEFORE_ITERATIONS - delta_time
267+
sleep_time = uniform(
268+
settings.SLEEP_MINUTES_BEFORE_ITERATIONS[0],
269+
settings.SLEEP_MINUTES_BEFORE_ITERATIONS[1]
270+
) * 60
271+
if delta_time <= sleep_time:
272+
sleep_time = sleep_time - delta_time
265273
self._log.info(f"Sleep <y>{format_duration(sleep_time)}</y> before next checks...")
266274
await asyncio.sleep(sleep_time)
267275
try:

0 commit comments

Comments
 (0)