Skip to content
This repository has been archived by the owner on Jan 3, 2025. It is now read-only.

Commit

Permalink
[feature] Added automatic ad watching functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
WubbaLubbaDubDubDev committed Nov 28, 2024
1 parent 3af2d8e commit 08674dd
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 36 deletions.
1 change: 1 addition & 0 deletions .env-example
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ AUTO_UPGRADE = True
JOIN_SQUAD = True
USE_SECRET_WORDS = True
SECRET_WORDS = ["happy halloween"]
WATCH_ADS = True

REF_ID = 'f411905106'

Expand Down
59 changes: 31 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,36 +25,39 @@
| Automatically selects the least popular template for painting to maximize the chances of earning a 3x reward 🆕 ||
| Night mode, which puts the script to sleep during a defined period for a specified duration 🆕 ||
| Action randomization 🆕 ||
| Automatic input of pre-defined secret words 🆕 ||
| Automatic ad watching 🆕 ||

## Settings
| **Parameter** | **Description** |
|---------------------------------|:---------------------------------------------------------------------------|
| **API_ID / API_HASH** | Your API_ID / API_HASH |
| **SLEEP_TIME** | Sleep time between cycles (default - [426, 4260]) |
| **NIGHT_MODE** | Enable night mode to avoid actions during specified hours (default - True) |
| **NIGHT_SLEEP_START_HOURS** | Night sleep start hours (default - [22, 2]) |
| **NIGHT_SLEEP_DURATION** | Duration of night sleep in hours (default - [4, 8]) |
| **START_DELAY** | Delay before starting actions (default - [30, 60]) |
| **AUTO_TASK** DANGEROUS | Automatically execute tasks (default - False) |
| **TASKS_TO_DO** AUTOTASK | List of tasks to perform automatically |
| **AUTO_DRAW** | Enable automatic pixel drawing (default - True) |
| **JOIN_TG_CHANNELS** | Automatically join Telegram channels (default - True) |
| **CLAIM_REWARD** | Automatically claim rewards (default - True) |
| **AUTO_UPGRADE** | Automatically upgrade items or settings (default - True) |
| **JOIN_SQUAD** | Automatically join squad (default - True) |
| **USE_SECRET_WORDS** | Enable secret words usage (default - True) |
| **SECRET_WORDS** | List of secret words |
| **REF_ID** | Referral ID |
| **IN_USE_SESSIONS_PATH** | Path to the file where used sessions are stored |
| **AUTO_BIND_PROXIES_FROM_FILE** | Automatically bind proxies from file (default - False) |
| **DRAW_IMAGE** | Perform image drawing (default - False) |
| **DRAWING_START_COORDINATES** | Starting coordinates for drawing (default - [0, 0]) |
| **IMAGE_PATH** | Path to the image file for drawing (default - "10x10.png") |
| **PALETTE** | List of colors used for drawing |
| **DAW_MAIN_TEMPLATE** | Enable 3x rewards (default - True) |
| **USE_UNPOPULAR_TEMPLATE** | Use an unpopular template for drawing (default - True) |
| **USE_SPECIFIED_TEMPLATES** | Enable using a predefined list of templates for drawing (default - False) |
| **SPECIFIED_TEMPLATES_ID_LIST** | List of template IDs to use when **USE_SPECIFIED_TEMPLATES** is enabled |
| **Parameter** | **Description** |
|---------------------------------|:----------------------------------------------------------------------------------|
| **API_ID / API_HASH** | Your API_ID / API_HASH |
| **SLEEP_TIME** | Sleep time between cycles (default - [426, 4260]) |
| **NIGHT_MODE** | Enable night mode to avoid actions during specified hours (default - True) |
| **NIGHT_SLEEP_START_HOURS** | Night sleep start hours (default - [22, 2]) |
| **NIGHT_SLEEP_DURATION** | Duration of night sleep in hours (default - [4, 8]) |
| **START_DELAY** | Delay before starting actions (default - [30, 60]) |
| **AUTO_TASK** DANGEROUS | Automatically execute tasks (default - False) |
| **TASKS_TO_DO** AUTOTASK | List of tasks to perform automatically |
| **AUTO_DRAW** | Enable automatic pixel drawing (default - True) |
| **JOIN_TG_CHANNELS** | Automatically join Telegram channels (default - True) |
| **CLAIM_REWARD** | Automatically claim rewards (default - True) |
| **AUTO_UPGRADE** | Automatically upgrade items or settings (default - True) |
| **JOIN_SQUAD** | Automatically join squad (default - True) |
| **USE_SECRET_WORDS** | Enable secret words usage (default - True) |
| **SECRET_WORDS** | List of secret words |
| **WATCH_ADS** | Enable automatically watching ads when available |
| **REF_ID** | Referral ID |
| **IN_USE_SESSIONS_PATH** | Path to the file where used sessions are stored |
| **AUTO_BIND_PROXIES_FROM_FILE** | Automatically bind proxies from file (default - False) |
| **DRAW_IMAGE** | Perform image drawing (default - False) |
| **DRAWING_START_COORDINATES** | Starting coordinates for drawing (default - [0, 0]) |
| **IMAGE_PATH** | Path to the image file for drawing (default - "10x10.png") |
| **PALETTE** | List of colors used for drawing |
| **DAW_MAIN_TEMPLATE** | Enable 3x rewards (default - True) |
| **USE_UNPOPULAR_TEMPLATE** | Use an unpopular template for drawing (default - True) |
| **USE_SPECIFIED_TEMPLATES** | Enable using a predefined list of templates for drawing (default - False) |
| **SPECIFIED_TEMPLATES_ID_LIST** | List of template IDs to use when **USE_SPECIFIED_TEMPLATES** is enabled |


## Quick Start 📚
Expand Down
1 change: 1 addition & 0 deletions bot/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Settings(BaseSettings):
JOIN_SQUAD: bool = True # Automatically join squad
USE_SECRET_WORDS: bool = True # Enable secret words usage
SECRET_WORDS: list[str] = [] # List of secret words
WATCH_ADS: bool = True # Enable automatically watching ads when available
SUBSCRIBE_TOURNAMENT_TEMPLATE: bool = False # Automatically subscribe to tournament templates

REF_ID: str = 'f411905106' # Referral ID
Expand Down
84 changes: 77 additions & 7 deletions bot/core/tapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from aiocfscrape import CloudflareScraper
from aiohttp import ClientError, ClientSession, TCPConnector
from colorama import Style, init
from urllib.parse import unquote, quote, urlparse
from urllib.parse import unquote, quote, urlparse, urlencode
from PIL import Image
from yarl import URL

Expand Down Expand Up @@ -88,6 +88,7 @@ def __init__(self, tg_client: Client, first_run: bool, pixel_chain=None, memory_
self.websocket_token = None
self.auth_token = None
self.init_data = None
self.chat_instance = None
self.user_info = None
self.tg_client = tg_client
self.first_run = first_run
Expand Down Expand Up @@ -146,7 +147,7 @@ async def get_tg_web_data(self, proxy: str | None, ref: str, bot_peer: str, shor
'signature': re.findall(r'signature=([^&]+)', tg_web_data)[0],
'user': quote(re.findall(r'user=([^&]+)', tg_web_data)[0]),
}

self.chat_instance = init_data['chat_instance']
if start_param:
start_param = start_param[0]
init_data['start_param'] = start_param
Expand Down Expand Up @@ -286,7 +287,7 @@ async def login(self, http_client: aiohttp.ClientSession, attempt: int = 1) -> d
return await self.login(http_client, attempt + 1) # Call the function again with incremented attempt count

async def check_proxy(self, http_client: aiohttp.ClientSession) -> None:
timeout = aiohttp.ClientTimeout(total=5)
timeout = aiohttp.ClientTimeout(total=10)
try:
async with aiohttp.ClientSession(timeout=timeout) as client_without_proxy:
real_response = await client_without_proxy.get(
Expand Down Expand Up @@ -986,7 +987,7 @@ async def paint(self, http_client: aiohttp.ClientSession):
opposite_color = f"\033[38;2;{opposite_r};{opposite_g};{opposite_b}m"
logger.success(
f"{self.session_name} | Painted on (x={x}, y={y}) with color {ansi_color}{opposite_color}{color}"
f"{Style.RESET_ALL}, reward: <e>{delta}</e>"
f"{Style.RESET_ALL}| Reward: <e>{delta}</e>"
)
if (delta == 0) and settings.USE_UNPOPULAR_TEMPLATE and option.USER_TEMPLATE:
if not settings.RANDOM_PIXEL_MODE:
Expand Down Expand Up @@ -1038,8 +1039,8 @@ async def upgrade(self, http_client: aiohttp.ClientSession):
f'https://notpx.app/api/v1/mining/boost/check/{name}')
upgrade_req.raise_for_status()
logger.success(f"{self.session_name} | Upgraded boost: {name}")
else:
logger.warning(f"{self.session_name} | Not enough money to keep upgrading {name}")
#else:
# logger.warning(f"{self.session_name} | Not enough money to keep upgrading {name}")
await asyncio.sleep(delay=randint(5, 10))
except Exception as error:
logger.error(f"{self.session_name} | Unknown error when upgrading {name}: {error}.")
Expand Down Expand Up @@ -1116,6 +1117,73 @@ async def choose_and_subscribe_template(self, http_client):
elif settings.USE_UNPOPULAR_TEMPLATE:
await self.subscribe_unpopular_template(http_client=http_client)


async def watch_ads(self, http_client):
headers_ = {
'Accept': '*/*',
'Accept-Encoding': 'gzip, deflate, br, zstd',
'Accept-Language': 'en,en-GB;q=0.9,uk-UA;q=0.8,uk;q=0.7,ru-UA;q=0.6,ru;q=0.5,en-US;q=0.4',
'Cache-Control': 'no-cache',
'Connection': 'keep-alive',
'Host': 'api.adsgram.ai',
'Origin': 'https://app.notpx.app',
'Pragma': 'no-cache',
'Referer': 'https://app.notpx.app/',
'Sec-CH-UA': '"Chromium";v="130", "Android WebView";v="130", "Not?A_Brand";v="99"',
'Sec-CH-UA-Mobile': '?1',
'Sec-CH-UA-Platform': '"Android"',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'cross-site',
'User-Agent': 'Mozilla/5.0 (Linux; Android 15; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.107 '
'Mobile Safari/537.36 Telegram-Android/11.4.3 (Google Pixel 6; Android 15; SDK 35; HIGH)',
'X-Requested-With': 'org.telegram.messenger.web'
}
try:
params = {
"blockId": 4853,
"tg_id": self.user_info["id"],
"tg_platform": "android",
"platform": "Linux aarch64",
"language": self.tg_client.lang_code,
"chat_type": "sender",
"chat_instance": int(self.chat_instance),
"top_domain": "app.notpx.app",
"connectiontype": 1
}
#Trackings
while True:
base_url = "https://api.adsgram.ai/adv"
full_url = f"{base_url}?{urlencode(params)}"
adv_response = await http_client.get(full_url, headers=headers_)
adv_response.raise_for_status()
adv_data = await adv_response.json()
if adv_data:
logger.info(f"{self.session_name} | A new advertisement has been found for viewing! | Title: {adv_data['banner']['bannerAssets'][1]['value']} | Type: {adv_data['bannerType']}")
previous_balance = await self.get_balance(http_client=http_client)
render_url = adv_data['banner']['trackings'][0]['value']
render_response = await http_client.get(render_url, headers=headers_)
render_response.raise_for_status()
await asyncio.sleep(random.randint(1, 5))
show_url = adv_data['banner']['trackings'][1]['value']
show_response = await http_client.get(show_url, headers=headers_)
show_response.raise_for_status()
await asyncio.sleep(random.randint(10, 15))
reward_url = adv_data['banner']['trackings'][4]['value']
reward_response = await http_client.get(reward_url, headers=headers_)
reward_response.raise_for_status()
await asyncio.sleep(random.randint(1, 5))
await self.update_status(http_client=http_client)
current_balance = await self.get_balance(http_client=http_client)
delta = round(current_balance - previous_balance, 1)
logger.success(f"{self.session_name} | Ad view completed successfully. | Reward: <e>{delta}</e>")
await asyncio.sleep(random.randint(30, 35))
else:
logger.info(f"{self.session_name} | No ads are available for viewing at the moment.")
break
except Exception as e:
logger.error(e)

async def join_squad_if_not_in(self, user_agent):
if not await self.in_squad(self.user_info):
http_client, connector = await self.create_session_with_retry(user_agent)
Expand Down Expand Up @@ -1230,7 +1298,6 @@ async def run(self, user_agent: str, start_delay: int, proxy: str | None) -> Non
#await self.check_response(http_client=http_client)

tasks = []

if settings.AUTO_DRAW:
tasks.append(self.subscribe_and_paint(http_client=http_client))

Expand All @@ -1252,6 +1319,9 @@ async def run(self, user_agent: str, start_delay: int, proxy: str | None) -> Non
if settings.SUBSCRIBE_TOURNAMENT_TEMPLATE:
tasks.append(self.choose_and_subscribe_tournament_template(http_client=http_client))

if settings.WATCH_ADS:
tasks.append(self.watch_ads(http_client=http_client))

random.seed(os.urandom(8))
random.shuffle(tasks)

Expand Down
2 changes: 1 addition & 1 deletion bot/utils/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
logger.add(sink=sys.stdout, format="<white>NotPixel</white>"
" | <white>{time:YYYY-MM-DD HH:mm:ss}</white>"
" | <level>{level: <8}</level>"
" | <cyan><b>{line}</b></cyan>"
" | <cyan>{file}: <b>{line}</b></cyan>"
" - <white><b>{message}</b></white>")
logger = logger.opt(colors=True)

0 comments on commit 08674dd

Please sign in to comment.