Code play 1 account
Code play game
import requests, random
from time import sleep
def countdown(seconds):
"""Countdown timer to create a delay between requests."""
while seconds:
mins, secs = divmod(seconds, 60)
time_format = '{:02d}:{:02d}'.format(mins, secs)
print(' ⏱ Waiting...', time_format, 'seconds', end='\r')
sleep(1)
seconds -= 1
class Vana:
def __init__(self) -> None:
self.game_url = 'https://www.vanadatahero.com/api'
def common_header(self, query):
"""Sets the common headers for each request."""
return {
'Host': 'www.vanadatahero.com',
'content-type': 'application/json',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0',
'accept': '*/*',
'x-telegram-web-app-init-data': query,
'sec-fetch-site': 'same-origin',
'sec-fetch-mode': 'cors',
'sec-fetch-dest': 'empty',
'referer': f'https://www.vanadatahero.com/challenges',
'accept-language': 'en-US,en;q=0.9',
'priority': 'u=1, i',
}
def _send_request(
self,
session: requests.Session,
method: str,
url: str,
headers: dict,
proxies: dict,
json_data: dict = {},
params: dict = {},
):
"""Performs HTTP requests with error handling."""
try:
response = session.request(method=method, url=url, headers=headers, proxies=proxies, json=json_data, params=params, timeout=60)
if response.status_code == 200:
if 'https://www.vanadatahero.com/api/tasks/1' in url:
return 'Ok'
try:
return response.json()
except ValueError:
if url == 'https://www.vanadatahero.com/_vercel/insights/view': pass
else: print(f"it returned non-JSON response: {url}\n {response.text}")
return response.text
else:
if "not found" in response.text:
return False
elif 'Telegram data has expired' in response.text:
return "Telegram data has expired"
elif '!DOCTYPE' in response.text:
print("ERROR: '!DOCTYPE'")
return False
elif "EDGE_FUNCTION_INVOCATION_TIMEOUT" in response.text:
print(f" ❌ Fail.. Server lag..")
return False
elif response.status_code == 504:
print(f" ❌ ERROR 504: Server took too long to respond.")
return False
print(f" ❌ ERROR: {url}\n {response.text}")
return False
except requests.exceptions.RequestException as e:
print(f" ❌ Request Exception: {e}")
return False
def post_request(self, session: requests.Session, url: str, headers: dict = None, proxies: dict = {}, json_data: dict = None, params: dict = None):
return self._send_request(session, 'POST', url, headers, proxies, json_data, params)
def get_request(self, session: requests.Session, url: str, headers: dict = None, proxies: dict = {}, json_data: dict = None, params: dict = None):
return self._send_request(session, 'GET', url, headers, proxies, json_data, params)
def getPlayer(self, session: requests.Session):
"""Fetch player information from the API."""
url = f'{self.game_url}/player'
player_info = self.get_request(session=session, url=url)
if isinstance(player_info, dict):
print(f"\n 😗 Player: {player_info['tgUsername']} - Total Points: {int(player_info['points'])}🌸")
return player_info['tgUsername']
if isinstance(player_info, str) and "expired" in player_info:
return player_info
return False
def play(self, session: requests.Session, point: int, player_name):
"""Execute a play task in the game."""
url = f'{self.game_url}/tasks/1'
json_data = {
'status': 'completed',
'points': point,
}
play_info = self.post_request(session=session, url=url, json_data=json_data)
if play_info:
print(f" 🎲 Player: {player_name} - Play: {play_info}: +{point} Points 🌸")
else: print(f" ❌ Player: {player_name} - Play: {play_info}")
return
def start(self, query: str, total: int, proxies: dict):
"""Starts the game process with the provided token and proxy."""
try:
if not query: return
query = query.replace("'", "")
_header = self.common_header(query=query)
session = requests.Session()
session.headers.update(_header)
session.proxies.update(proxies) # Update session with proxy settings
player_name = self.getPlayer(session=session)
print('')
if not player_name:
print(f"ERROR: {player_name}")
return
if isinstance(player_name, str) and "expired" in player_name:
print("\n❌ QUERY_TOKEN IS EXPIRED. PLEASE RELOAD THE GAME AND GET YOUR TOKEN BACK")
return
for i in range(total):
print(f"\n ➡️ Round: {i+1}/{total}")
_point = round(random.uniform(600, 800), 1)
self.play(session=session, point=_point, player_name=player_name)
countdown(20)
print('')
self.getPlayer(session=session)
except Exception as e:
print(f" ❌ ERROR: {e}")
if __name__ == "__main__":
try:
# Enter proxy in the format: proxy_ip:proxy_port:proxy_user:proxy_pass
proxy_input = input("\n🌐 Enter Proxy (proxy_ip:proxy_port:proxy_user:proxy_pass): ")
# Split the proxy information
proxy_ip, proxy_port, proxy_user, proxy_pass = proxy_input.split(':')
# Set up proxy in dictionary format (use HTTP proxy for both HTTP and HTTPS)
proxies = {
'http': f'http://{proxy_user}:{proxy_pass}@{proxy_ip}:{proxy_port}',
'https': f'http://{proxy_user}:{proxy_pass}@{proxy_ip}:{proxy_port}', # Using HTTP proxy for HTTPS too
}
# Enter the number of rounds
total = int(input("\n🎮 Number of rounds to play: \n ➡️ "))
print(" - OK")
# Enter the token
query = input("\n🔑 Enter QUERY_TOKEN: \n ➡️ ")
print(" - OK\n")
# Start the bot
bot = Vana().start(query, total, proxies)
except Exception as e:
print(f" ❌ ERROR in main program: {e}")
# Wait for user input before closing the terminal
input("\nPress Enter to exit...")
Querry token
window.Telegram.WebView.initParams.tgWebAppData
Last updated