Skip to content

Commit

Permalink
added wallets manager & full tasks support
Browse files Browse the repository at this point in the history
  • Loading branch information
Desamod committed Nov 1, 2024
1 parent 2e615fa commit f143725
Show file tree
Hide file tree
Showing 17 changed files with 114 additions and 41 deletions.
4 changes: 3 additions & 1 deletion .env-example
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ SLEEP_TIME=
START_DELAY=
AUTO_TASK=
JOIN_TG_CHANNELS=
REF_ID=
REF_ID=
CONNECT_TON_WALLET=
DISCONNECT_TON_WALLET=
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ __pycache__

*.cpython-310.pyc

registered_sessions.txt
registered_sessions.txt

wallets.*
26 changes: 17 additions & 9 deletions README-RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,25 @@
| Привязка прокси к сессии ||
| Привязка User-Agent к сессии ||
| Авторегистрация в боте ||
| Авто-выполнение заданий ||
| Генерация Ton кошельков ||
| Подключение кошелька к PAWS боту ||
| Отключение кошелька от PAWS бота ||
| Полная поддержка тасок ||




## [Настройки](https://github.com/Desamod/PawsBot/blob/master/.env-example/)
| Настройка | Описание |
|-------------------------|:----------------------------------------------------------:|
| **API_ID / API_HASH** | Данные платформы, с которой запускать сессию Telegram |
| **SLEEP_TIME** | Время сна между циклами (по умолчанию - [7200, 10800]) |
| **START_DELAY** | Задержка между сессиями на старте (по умолчанию - [5, 25]) |
| **AUTO_TASK** | Автовыполнение тасок (по умолчанию - True) |
| **JOIN_CHANNELS** | Авто-подписка на ТГ каналы из тасок (по умолчанию - False) |
| **REF_ID** | Реф. ссылка для регистрации в боте |
| Настройка | Описание |
|---------------------------|:---------------------------------------------------------------------------:|
| **API_ID / API_HASH** | Данные платформы, с которой запускать сессию Telegram |
| **SLEEP_TIME** | Время сна между циклами (по умолчанию - [7200, 10800]) |
| **START_DELAY** | Задержка между сессиями на старте (по умолчанию - [5, 25]) |
| **AUTO_TASK** | Автовыполнение тасок (по умолчанию - True) |
| **JOIN_CHANNELS** | Авто-подписка на ТГ каналы из тасок (по умолчанию - False) |
| **REF_ID** | Реф. ссылка для регистрации в боте |
| **CONNECT_TON_WALLET** | Подключение Ton кошелька из wallets.json к боту PAWS (по умолчанию - False) |
| **DISCONNECT_TON_WALLET** | Отключение Ton кошелька от PAWS (по умолчанию - False) |

## Быстрый старт 📚

Expand Down Expand Up @@ -79,6 +85,7 @@ python3 main.py

# 1 - Запускает кликер
# 2 - Создает сессию (pyrogram)
# 3 - Генерирует Ton кошельки
```

# Windows ручная установка
Expand All @@ -99,6 +106,7 @@ python main.py

# 1 - Запускает кликер
# 2 - Создает сессию (pyrogram)
# 3 - Генерирует Ton кошельки
```
### Использование
При первом запуске бота создайте для него сессию с помощью команды «2». В процессе будет создана папка 'sessions', в которой хранятся все сессии, а также файл accounts.json с конфигурациями.
Expand Down
41 changes: 24 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,32 @@
> 🇷 🇺 README in russian available [here](README-RU.md)
## Features
| Feature | Supported |
|----------------------------------------------------|:---------:|
| Multithreading ||
| Proxy binding to session ||
| User-Agent binding to session ||
| Support for pyrogram .session / telethon .session ||
| Registration in bot ||
| Auto-tasks ||
| Daily rewards ||
| Feature | Supported |
|---------------------------------------------------|:---------:|
| Multithreading ||
| Proxy binding to session ||
| User-Agent binding to session ||
| Support for pyrogram .session / telethon .session ||
| Registration in bot ||
| Ton wallets generation ||
| Wallets connection to PAWS ||
| Wallets disconnection from PAWS ||
| Full-tasks support ||
| Daily rewards ||



## [Settings](https://github.com/Desamod/PawsBot/blob/master/.env-example/)
| Settings | Description |
|-------------------------|:---------------------------------------------------------------------------:|
| **API_ID / API_HASH** | Platform data from which to run the Telegram session (by default - android) |
| **SLEEP_TIME** | Sleep time between cycles (by default - [7200, 10800]) |
| **START_DELAY** | Delay between sessions at start (by default - [5, 25]) |
| **AUTO_TASK** | Auto tasks (default - True) |
| **JOIN_CHANNELS** | Auto-join for tg channels tasks (default - False) |
| **REF_ID** | Ref link for registration |
| Settings | Description |
|---------------------------|:---------------------------------------------------------------------------:|
| **API_ID / API_HASH** | Platform data from which to run the Telegram session (by default - android) |
| **SLEEP_TIME** | Sleep time between cycles (by default - [7200, 10800]) |
| **START_DELAY** | Delay between sessions at start (by default - [5, 25]) |
| **AUTO_TASK** | Auto tasks (default - True) |
| **JOIN_CHANNELS** | Auto-join for tg channels tasks (default - False) |
| **REF_ID** | Ref link for registration |
| **CONNECT_TON_WALLET** | Connect Ton Wallet from wallets.json to PAWS bot (default - False) |
| **DISCONNECT_TON_WALLET** | Disconnect Ton Wallet from PAWS (default - False) |

## Quick Start 📚

Expand Down Expand Up @@ -80,6 +85,7 @@ You can also use arguments for quick start, for example:

# 1 - Run clicker
# 2 - Creates a session (pyrogram)
# 3 - Generate TON wallets
```

# Windows manual installation
Expand All @@ -100,6 +106,7 @@ You can also use arguments for quick start, for example:

# 1 - Run clicker
# 2 - Creates a session
# 3 - Generate TON wallets
```

### Usages
Expand Down
4 changes: 3 additions & 1 deletion bot/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ class Settings(BaseSettings):
AUTO_TASK: bool = True
JOIN_TG_CHANNELS: bool = False
REF_ID: str = 'idqtVYZG'
DISABLED_TASKS: list[str] = ['wallet']
DISABLED_TASKS: list[str] = []
CONNECT_TON_WALLET: bool = False
DISCONNECT_TON_WALLET: bool = False


settings = Settings()
Binary file added bot/core/TgManager/tg_manager.cp310-win_amd64.pyd
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
48 changes: 41 additions & 7 deletions bot/core/tapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@

from ..utils.api_checker import is_valid_endpoints
from ..utils.tg_manager.TGSession import TGSession

from bot.core.WalletManager.WalletManager import get_valid_wallet, set_wallet

class Tapper:
def __init__(self, tg_session: TGSession):
self.tg_session = tg_session
self.session_name = tg_session.session_name
self.start_param = ''
self.name = ''
self.name = '',
self.wallet = ''

async def login(self, http_client: aiohttp.ClientSession, tg_web_data: str, retry=0):
try:
Expand All @@ -39,11 +40,11 @@ async def login(self, http_client: aiohttp.ClientSession, tg_web_data: str, retr
response_json = await response.json()
auth_token = None
if response_json.get('success', False):
auth_token = response_json.get('data', [])[0]
auth_token = response_json.get('data', None)
return auth_token

except Exception as error:
if retry < 5:
if retry < 3:
logger.warning(f"{self.session_name} | Can't logging | Retry attempt: {retry}")
await asyncio.sleep(delay=randint(5, 10))
return await self.login(http_client, tg_web_data=tg_web_data, retry=retry + 1)
Expand Down Expand Up @@ -101,6 +102,11 @@ async def processing_tasks(self, http_client: aiohttp.ClientSession):
elif task['code'] == 'twitter' or task['code'] == 'linked':
logger.info(f"{self.session_name} | Performing <lc>{task['title']}</lc> task")
result = await self.verify_task(http_client, task['_id'])
elif task['code'] == 'wallet':
if self.wallet is not None and len(self.wallet) > 0:
logger.info(f"{self.session_name} | Performing wallet task: <lc>{task['title']}</lc>")
result = await self.verify_task(http_client, task['_id'])

if result is not None:
await asyncio.sleep(delay=randint(5, 10))
is_claimed = await self.claim_task_reward(http_client, task['_id'])
Expand Down Expand Up @@ -214,7 +220,8 @@ async def run(self, user_agent: str, proxy: str | None) -> None:
else:
logger.info(f"{self.session_name} | Antidetect: endpoints successfully checked")

auth_token = await self.login(http_client=http_client, tg_web_data=tg_web_data)
auth_data = await self.login(http_client=http_client, tg_web_data=tg_web_data)
auth_token = auth_data[0]
if auth_token is None:
token_live_time = 0
await asyncio.sleep(randint(100, 180))
Expand All @@ -224,9 +231,36 @@ async def run(self, user_agent: str, proxy: str | None) -> None:
token_live_time = randint(3500, 3600)

http_client.headers['Authorization'] = f'Bearer {auth_token}'
user_info = await self.get_user_info(http_client=http_client)
user_info = auth_data[1]
balance = user_info['gameData']['balance']
logger.info(f"{self.session_name} | Balance: <e>{balance}</e> PAWS")
wallet = user_info['userData'].get('wallet', None)
self.wallet = wallet
is_wallet_connected = wallet is not None and len(wallet) > 0
wallet_status = f"Wallet: <y>{wallet}</y>" if is_wallet_connected else 'Wallet not connected'
logger.info(f"{self.session_name} | Balance: <e>{balance}</e> PAWS | {wallet_status}")

if not is_wallet_connected and settings.CONNECT_TON_WALLET:
await asyncio.sleep(randint(5, 10))
valid_wallet = get_valid_wallet()
if valid_wallet is not None:
ton_wallet_address = valid_wallet['address']
logger.info(f'{self.session_name} | Found valid wallet: <y>{ton_wallet_address}</y>')
result = await set_wallet(self.session_name, http_client, ton_wallet_address)
if result:
logger.success(f'{self.session_name} | '
f'Wallet: <y>{ton_wallet_address}</y> successfully connected')
self.wallet = ton_wallet_address
else:
logger.warning(f'{self.session_name} | A valid wallet was not found. '
f'Try adding new wallets manually or generating them using command 3')

elif is_wallet_connected and settings.DISCONNECT_TON_WALLET:
await asyncio.sleep(randint(5, 10))
result = await set_wallet(self.session_name, http_client, self.wallet, connect=False)
if result:
logger.success(f'{self.session_name} | '
f'Wallet: <y>{self.wallet}</y> successfully disconnected')
self.wallet = None

if settings.AUTO_TASK:
await asyncio.sleep(delay=randint(5, 10))
Expand Down
Binary file removed bot/core/tg_manager.cp310-win_amd64.pyd
Binary file not shown.
Binary file removed bot/core/tg_manager.cpython-310-darwin.so
Binary file not shown.
Binary file removed bot/core/tg_manager.cpython-310-x86_64-linux-gnu.so
Binary file not shown.
24 changes: 20 additions & 4 deletions bot/utils/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from bot.core.tapper import run_tapper
from bot.core.registrator import register_sessions
from bot.utils.accounts import Accounts
from bot.core.tg_manager import SessionManager
from bot.core.TgManager.tg_manager import SessionManager
from bot.core.WalletManager.WalletManager import generate_wallets, get_not_connected_wallets


start_text = """
Expand All @@ -25,6 +26,7 @@
1. Run bot
2. Create session
3. Generate TON wallets
"""


Expand All @@ -45,13 +47,22 @@ async def process() -> None:

if not action.isdigit():
logger.warning("Action must be number")
elif action not in ["1", "2"]:
logger.warning("Action must be 1 or 2")
elif action not in ["1", "2", "3"]:
logger.warning("Action must be 1, 2 or 3")
else:
action = int(action)
break

if action == 2:
if action == 3:
count = input("Enter the number of wallets to generate: ")
try:
count = int(count)
generate_wallets(count)
logger.success('Wallets successfully generated, check wallets.txt file')
except ValueError:
logger.warning("Please enter a valid number.")
return
elif action == 2:
await register_sessions()
elif action == 1:
accounts = await Accounts().get_accounts()
Expand All @@ -66,6 +77,11 @@ async def run_tasks(accounts: [Any, Any, list]):
short_name='PAWS',
start_param=settings.REF_ID,
check_first_run=True)

if settings.CONNECT_TON_WALLET:
valid_wallets = get_not_connected_wallets()
logger.info(f'Found <e>{len(valid_wallets)}</e> not connected wallet/s')

for account in accounts:
session_name, user_agent, raw_proxy = account.values()
tg_session = await manager.get_tg_session(session_name=session_name, proxy=raw_proxy)
Expand Down
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ aiofiles~=24.1.0
Brotli~=1.1.0
opentele~=1.15.1
requests==2.32.3
Telethon~=1.37.0
Telethon~=1.37.0
tonsdk==1.0.15
tqdm==4.66.5

0 comments on commit f143725

Please sign in to comment.