Skip to content

Commit cc08209

Browse files
committed
upload
0 parents  commit cc08209

6 files changed

+341
-0
lines changed

main.py

+171
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
import aiohttp
2+
import asyncio
3+
import aiofiles
4+
import logging
5+
import time
6+
7+
logging.basicConfig(level=logging.INFO)
8+
logger = logging.getLogger(__name__)
9+
10+
# 设置默认请求头
11+
headers = {
12+
'Content-Type': 'application/json',
13+
}
14+
15+
# coday 函数
16+
async def coday(url, method, headers, payload_data=None, proxy=None):
17+
try:
18+
async with aiohttp.ClientSession() as session:
19+
async with session.request(method, url, headers=headers, json=payload_data, proxy=proxy) as response:
20+
try:
21+
json_data = await response.json()
22+
except aiohttp.ContentTypeError:
23+
json_data = {}
24+
if not response.ok:
25+
return {'error': True, 'status': response.status, 'data': json_data}
26+
return json_data
27+
except Exception as e:
28+
logger.error(f"Error in coday: {e}")
29+
return {'error': True, 'message': str(e)}
30+
31+
# 读取令牌、唯一 ID 和代理
32+
async def read_tokens_ids_and_proxies():
33+
try:
34+
# 读取 token 文件
35+
async with aiofiles.open('token.txt', 'r') as f:
36+
token_data = await f.read()
37+
tokens = [line.strip() for line in token_data.split('\n') if line.strip()]
38+
39+
# 读取唯一 ID 文件
40+
async with aiofiles.open('unique_id.txt', 'r') as f:
41+
ids_data = await f.read()
42+
unique_ids = [line.strip() for line in ids_data.split('\n') if line.strip()]
43+
44+
# 询问用户是否使用代理
45+
use_proxy = input("是否使用代理?(y/n): ").strip().lower() == 'y'
46+
47+
proxies = []
48+
if use_proxy:
49+
# 读取代理文件
50+
async with aiofiles.open('proxy.txt', 'r') as f:
51+
proxy_data = await f.read()
52+
proxies = [line.strip() for line in proxy_data.split('\n') if line.strip()]
53+
54+
# 检查 token、唯一 ID 和代理的行数是否匹配
55+
if len(tokens) != len(unique_ids) or len(tokens) != len(proxies):
56+
logger.error("Token、唯一 ID 和代理的行数不匹配。")
57+
return []
58+
59+
# 组合账户信息
60+
accounts = []
61+
for i in range(len(tokens)):
62+
access_token, refresh_token = map(str.strip, tokens[i].split('|'))
63+
ids = list(map(str.strip, unique_ids[i].split('|')))
64+
proxy = proxies[i] if use_proxy else None
65+
proxy_type = 'socks5' if proxy and proxy.startswith('socks5://') else 'http'
66+
accounts.append({'access_token': access_token, 'refresh_token': refresh_token, 'unique_ids': ids, 'proxy': f"{proxy_type}://{proxy}" if proxy else None})
67+
68+
return accounts
69+
except Exception as e:
70+
logger.error(f"读取 token、唯一 ID 或代理文件失败: {e}")
71+
return []
72+
# 刷新令牌功能
73+
async def refresh_token(refresh_token, account_index, proxy):
74+
logger.info(f"正在刷新账户 {account_index + 1} 的访问令牌...")
75+
payload_data = {'refresh_token': refresh_token}
76+
response = await coday("https://api.meshchain.ai/meshmain/auth/refresh-token", 'POST', headers, payload_data, proxy=proxy)
77+
78+
if response and response.get('access_token'):
79+
# 更新 token 文件
80+
async with aiofiles.open('token.txt', 'r') as f:
81+
token_lines = (await f.read()).split('\n')
82+
token_lines[account_index] = f"{response['access_token']}|{response['refresh_token']}"
83+
async with aiofiles.open('token.txt', 'w') as f:
84+
await f.write('\n'.join(token_lines))
85+
logger.info(f"账户 {account_index + 1} 的令牌刷新成功")
86+
return response['access_token']
87+
logger.error(f"账户 {account_index + 1} 的令牌刷新失败")
88+
return None
89+
90+
# info 函数
91+
async def info(unique_id, headers, proxy):
92+
url = 'https://api.meshchain.ai/meshmain/nodes/status'
93+
return await coday(url, 'POST', headers, {'unique_id': unique_id}, proxy=proxy)
94+
95+
# estimate 函数
96+
async def estimate(unique_id, headers, proxy):
97+
url = 'https://api.meshchain.ai/meshmain/rewards/estimate'
98+
return await coday(url, 'POST', headers, {'unique_id': unique_id}, proxy=proxy)
99+
100+
# claim 函数
101+
async def claim(unique_id, headers, proxy):
102+
url = 'https://api.meshchain.ai/meshmain/rewards/claim'
103+
result = await coday(url, 'POST', headers, {'unique_id': unique_id}, proxy=proxy)
104+
return result.get('total_reward', None)
105+
106+
# start 函数
107+
async def start(unique_id, headers, proxy):
108+
url = 'https://api.meshchain.ai/meshmain/rewards/start'
109+
return await coday(url, 'POST', headers, {'unique_id': unique_id}, proxy=proxy)
110+
111+
# 单个账户的主要处理流程
112+
async def process_account(account, account_index):
113+
global headers
114+
headers['Authorization'] = f"Bearer {account['access_token']}"
115+
116+
for unique_id in account['unique_ids']:
117+
proxy = account['proxy']
118+
119+
# 获取用户信息
120+
profile = await info(unique_id, headers, proxy)
121+
122+
if profile.get('error'):
123+
logger.error(f"账户 {account_index + 1} | {unique_id}: 获取用户信息失败,尝试刷新令牌...")
124+
new_access_token = await refresh_token(account['refresh_token'], account_index, proxy)
125+
if not new_access_token:
126+
return
127+
headers['Authorization'] = f"Bearer {new_access_token}"
128+
else:
129+
name = profile.get('name')
130+
total_reward = profile.get('total_reward')
131+
logger.info(f"账户 {account_index + 1} | {unique_id}: {name} | 余额: {total_reward}")
132+
133+
# 获取奖励估算
134+
filled = await estimate(unique_id, headers, proxy)
135+
if not filled:
136+
logger.error(f"账户 {account_index + 1} | {unique_id}: 获取估算值失败。")
137+
continue
138+
139+
if filled.get('value', 0) > 10:
140+
logger.info(f"账户 {account_index + 1} | {unique_id}: 尝试领取奖励...")
141+
reward = await claim(unique_id, headers, proxy)
142+
if reward:
143+
logger.info(f"账户 {account_index + 1} | {unique_id}: 奖励领取成功!新余额: {reward}")
144+
await start(unique_id, headers, proxy)
145+
logger.info(f"账户 {account_index + 1} | {unique_id}: 重新开始挖矿。")
146+
else:
147+
logger.error(f"账户 {account_index + 1} | {unique_id}: 领取奖励失败。")
148+
else:
149+
logger.info(f"账户 {account_index + 1} | {unique_id}: 已经在挖矿中,当前值: {filled.get('value', 0)}")
150+
151+
# 主流程处理所有账户
152+
async def main():
153+
banner = "Your Banner Here"
154+
logger.debug(banner)
155+
156+
while True:
157+
accounts = await read_tokens_ids_and_proxies()
158+
159+
if not accounts:
160+
logger.error("没有账户可处理。")
161+
return
162+
163+
for i, account in enumerate(accounts):
164+
logger.info(f"正在处理账户 {i + 1}...")
165+
await process_account(account, i)
166+
167+
await asyncio.sleep(60) # 每 60 秒运行一次
168+
169+
# 运行主流程
170+
if __name__ == "__main__":
171+
asyncio.run(main())

proxy.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
socks5://user:password@ip:port
2+
http://user:password@ip:port

register.py

+162
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
import aiohttp
2+
import asyncio
3+
import aiofiles
4+
import aioconsole
5+
import json
6+
import os
7+
import random
8+
import string
9+
import logging
10+
11+
logging.basicConfig(level=logging.INFO)
12+
logger = logging.getLogger(__name__)
13+
14+
# 设置默认请求头
15+
headers = {
16+
'Content-Type': 'application/json',
17+
}
18+
19+
# coday 函数
20+
async def coday(url, method, headers, payload_data=None):
21+
try:
22+
async with aiohttp.ClientSession() as session:
23+
async with session.request(method, url, headers=headers, json=payload_data) as response:
24+
try:
25+
json_data = await response.json()
26+
except aiohttp.ContentTypeError:
27+
json_data = {}
28+
if not response.ok:
29+
return {'error': True, 'status': response.status, 'data': json_data}
30+
return json_data
31+
except Exception as e:
32+
logger.error(f"Error in coday: {e}")
33+
return {'error': True, 'message': str(e)}
34+
35+
# 注册函数
36+
async def register(session, name, email, password, referral_code):
37+
payload_reg = {
38+
"full_name": name,
39+
"email": email,
40+
"password": password,
41+
"referral_code": referral_code,
42+
}
43+
return await coday('https://api.meshchain.ai/meshmain/auth/email-signup', 'POST', headers, payload_reg)
44+
45+
# 登录函数
46+
async def login(session, email, password):
47+
payload_login = {
48+
"email": email,
49+
"password": password,
50+
}
51+
return await coday('https://api.meshchain.ai/meshmain/auth/email-signin', 'POST', headers, payload_login)
52+
53+
# 验证邮箱函数
54+
async def verify(session, email, otp):
55+
payload_verify = {
56+
"email": email,
57+
"code": otp,
58+
}
59+
return await coday('https://api.meshchain.ai/meshmain/auth/verify-email', 'POST', headers, payload_verify)
60+
61+
# 领取奖励函数
62+
async def claim_bnb(session):
63+
payload_claim = {"mission_id": "ACCOUNT_VERIFICATION"}
64+
return await coday('https://api.meshchain.ai/meshmain/mission/claim', 'POST', headers, payload_claim)
65+
66+
# 生成 16 字节的十六进制字符串
67+
def generate_hex():
68+
return ''.join(random.choices(string.hexdigits, k=16))
69+
70+
# 初始化节点并保存唯一 ID
71+
async def init(session, random_hex):
72+
url = "https://api.meshchain.ai/meshmain/nodes/link"
73+
payload = {
74+
"unique_id": random_hex,
75+
"node_type": "browser",
76+
"name": "Extension"
77+
}
78+
return await coday(url, 'POST', headers, payload)
79+
80+
# estimate 函数
81+
async def estimate(session, id, headers):
82+
url = 'https://api.meshchain.ai/meshmain/rewards/estimate'
83+
return await coday(url, 'POST', headers, {'unique_id': id})
84+
85+
# claim 函数
86+
async def claim(session, id, headers):
87+
url = 'https://api.meshchain.ai/meshmain/rewards/claim'
88+
result = await coday(url, 'POST', headers, {'unique_id': id})
89+
return result.get('total_reward', None)
90+
91+
# start 函数
92+
async def start(session, id, headers):
93+
url = 'https://api.meshchain.ai/meshmain/rewards/start'
94+
return await coday(url, 'POST', headers, {'unique_id': id})
95+
96+
# info 函数
97+
async def info(session, id, headers):
98+
url = 'https://api.meshchain.ai/meshmain/nodes/status'
99+
return await coday(url, 'POST', headers, {'unique_id': id})
100+
101+
# 主函数
102+
async def main():
103+
async with aiohttp.ClientSession() as session:
104+
try:
105+
# 提示用户输入需要注册的账号数量
106+
num_accounts = int(await aioconsole.ainput("请输入需要注册的账号数量: "))
107+
108+
for _ in range(num_accounts):
109+
# 提示用户依次输入信息
110+
name = await aioconsole.ainput("请输入您的姓名: ")
111+
email = await aioconsole.ainput("请输入您的邮箱: ")
112+
password = await aioconsole.ainput("请输入您的密码: ")
113+
referral_code = await aioconsole.ainput("请输入邀请码 (默认: PUSNGANNMK2B): ") or "PUSNGANNMK2B"
114+
115+
# 注册账户
116+
register_message = await register(session, name, email, password, referral_code)
117+
logger.info(f"注册结果: {register_message}")
118+
119+
# 登录账户
120+
login_data = await login(session, email, password)
121+
if not login_data:
122+
continue
123+
124+
# 将 access token 添加到请求头
125+
global headers
126+
headers['Authorization'] = f"Bearer {login_data['access_token']}"
127+
128+
# 验证邮箱
129+
otp = await aioconsole.ainput("请输入您收到的邮箱验证码 (OTP): ")
130+
verify_message = await verify(session, email, otp)
131+
logger.info(f"邮箱验证结果: {verify_message}")
132+
133+
# 领取奖励
134+
claim_message = await claim_bnb(session)
135+
logger.info(f"奖励领取成功: {claim_message}")
136+
137+
# 生成并链接唯一 ID
138+
random_hex = generate_hex()
139+
link_response = await init(session, random_hex)
140+
141+
# 保存令牌和唯一 ID
142+
try:
143+
async with aiofiles.open('token.txt', 'a') as token_file:
144+
await token_file.write(f"{login_data['access_token']}|{login_data['refresh_token']}\n")
145+
logger.info('令牌已保存到 token.txt')
146+
147+
async with aiofiles.open('unique_id.txt', 'a') as id_file:
148+
await id_file.write(f"{link_response['unique_id']}\n")
149+
logger.info('扩展 ID 已保存到 unique_id.txt')
150+
151+
# 启动节点
152+
starting = await start(session, link_response['unique_id'], headers)
153+
if starting:
154+
logger.info(f"扩展 ID: {link_response['unique_id']} 已激活")
155+
except Exception as e:
156+
logger.error('保存数据到文件失败:', e)
157+
except Exception as e:
158+
logger.error("程序运行时发生错误:", e)
159+
160+
# 启动程序
161+
if __name__ == "__main__":
162+
asyncio.run(main())

requirements.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
aiohttp
2+
aiofiles
3+
aioconsole
4+
aiofiles
5+
mailtm
6+
requests

token.txt

Whitespace-only changes.

unique_id.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)