1 Commits

Author SHA1 Message Date
Your Name
ae07d88b28 feat: 更新版本号到8.0.1 2025-02-09 23:25:21 +08:00
5 changed files with 165 additions and 82 deletions

View File

@@ -13,6 +13,16 @@ urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
class Config: class Config:
def __init__(self): def __init__(self):
# 默认配置
self.default_config = {
"TEMP_MAIL": "demo",
"TEMP_MAIL_EXT": "@mailto.plus",
"TEMP_MAIL_EPIN": "",
"DOMAIN": "mailto.plus",
"BROWSER_USER_AGENT": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
"MAIL_SERVER": "https://tempmail.plus"
}
# 获取应用程序的根目录路径 # 获取应用程序的根目录路径
if getattr(sys, "frozen", False): if getattr(sys, "frozen", False):
# 如果是打包后的可执行文件 # 如果是打包后的可执行文件
@@ -23,8 +33,8 @@ class Config:
# 配置重试策略 # 配置重试策略
retry_strategy = Retry( retry_strategy = Retry(
total=3, total=2, # 减少重试次数
backoff_factor=1, backoff_factor=0.5, # 减少等待时间
status_forcelist=[429, 500, 502, 503, 504], status_forcelist=[429, 500, 502, 503, 504],
) )
@@ -41,27 +51,34 @@ class Config:
# 从API获取配置 # 从API获取配置
try: try:
# 使用session发送请求 # 使用session发送请求,减少超时时间
response = self.session.get( response = self.session.get(
"https://cursorapi.nosqli.com/admin/api.mail/getRandom", "https://cursorapi.nosqli.com/admin/api.mail/getRandom",
timeout=30, timeout=10,
allow_redirects=True allow_redirects=True
) )
data = response.json() data = response.json()
if data['code'] != 0: if data['code'] == 0:
raise Exception(data['msg'])
config = data['data']['env'] config = data['data']['env']
else:
logging.warning(f"API返回错误: {data.get('msg', '未知错误')}")
logging.info("使用默认配置继续运行...")
config = self.default_config
except Exception as e:
logging.warning(f"从API获取配置失败: {str(e)}")
logging.info("使用默认配置继续运行...")
config = self.default_config
# 设置配置项 # 设置配置项
self.imap = False self.imap = False
self.temp_mail = config.get("TEMP_MAIL", "").strip() self.temp_mail = config.get("TEMP_MAIL", self.default_config["TEMP_MAIL"]).strip()
self.temp_mail_ext = config.get("TEMP_MAIL_EXT", "").strip() self.temp_mail_ext = config.get("TEMP_MAIL_EXT", self.default_config["TEMP_MAIL_EXT"]).strip()
self.temp_mail_epin = config.get("TEMP_MAIL_EPIN", "").strip() self.temp_mail_epin = config.get("TEMP_MAIL_EPIN", self.default_config["TEMP_MAIL_EPIN"]).strip()
self.domain = config.get("DOMAIN", "").strip() self.domain = config.get("DOMAIN", self.default_config["DOMAIN"]).strip()
self.browser_user_agent = config.get("BROWSER_USER_AGENT", "").strip() self.browser_user_agent = config.get("BROWSER_USER_AGENT", self.default_config["BROWSER_USER_AGENT"]).strip()
self.mail_server = config.get("MAIL_SERVER", "").strip() self.mail_server = config.get("MAIL_SERVER", self.default_config["MAIL_SERVER"]).strip()
# 如果临时邮箱为null则加载IMAP # 如果临时邮箱为null则加载IMAP
if self.temp_mail == "null": if self.temp_mail == "null":
@@ -71,9 +88,6 @@ class Config:
self.imap_user = config.get("IMAP_USER", "").strip() self.imap_user = config.get("IMAP_USER", "").strip()
self.imap_pass = config.get("IMAP_PASS", "").strip() self.imap_pass = config.get("IMAP_PASS", "").strip()
self.imap_dir = config.get("IMAP_DIR", "inbox").strip() self.imap_dir = config.get("IMAP_DIR", "inbox").strip()
except Exception as e:
logging.error(f"从API获取配置失败: {e}")
raise e
self.check_config() self.check_config()

View File

@@ -534,15 +534,20 @@ def print_progress(message, delay=0.03):
def get_user_input(prompt, valid_options=None): def get_user_input(prompt, valid_options=None):
"""获取用户输入的美化版本""" """获取用户输入的美化版本"""
while True: try:
print(f"\n{Fore.YELLOW}>>>{Fore.WHITE} {prompt}{Style.RESET_ALL}", end=" ") print(f"\n{Fore.YELLOW}>>>{Fore.WHITE} {prompt}{Style.RESET_ALL}", end=" ")
user_input = input().strip() user_input = input().strip()
if valid_options and user_input not in valid_options: if valid_options and user_input and user_input not in valid_options:
print(f"{Fore.RED}✗ 无效的输入,请重试{Style.RESET_ALL}") print(f"{Fore.YELLOW}[提示] 输入无效,请重试{Style.RESET_ALL}")
continue return get_user_input(prompt, valid_options)
return user_input return user_input
except (KeyboardInterrupt, EOFError):
print(f"\n{Fore.YELLOW}[提示] 程序已取消{Style.RESET_ALL}")
sys.exit(0)
except Exception:
return ""
def load_last_account(): def load_last_account():
@@ -573,8 +578,11 @@ def save_last_account(email):
def verify_member(): def verify_member():
"""验证会员身份""" """验证会员身份"""
checker = MemberChecker() checker = MemberChecker()
max_retries = 3
retry_count = 0
while True: while retry_count < max_retries:
try:
print(f"\n{Fore.CYAN}{'='*30} 会员验证 {'='*30}{Style.RESET_ALL}") print(f"\n{Fore.CYAN}{'='*30} 会员验证 {'='*30}{Style.RESET_ALL}")
# 加载上次使用的账号 # 加载上次使用的账号
@@ -591,10 +599,15 @@ def verify_member():
keyword = last_email keyword = last_email
print(f"{Fore.CYAN}[信息] 使用上次账号: {keyword}{Style.RESET_ALL}") print(f"{Fore.CYAN}[信息] 使用上次账号: {keyword}{Style.RESET_ALL}")
elif not keyword: elif not keyword:
print(f"{Fore.RED}✗ 输入不能为空,请重试{Style.RESET_ALL}") if retry_count < max_retries - 1:
print(f"{Fore.YELLOW}[提示] 输入为空,请重试{Style.RESET_ALL}")
retry_count += 1
continue continue
else:
print(f"{Fore.YELLOW}[提示] 多次输入为空,程序退出{Style.RESET_ALL}")
sys.exit(0)
animate_loading("正在验证会员信息", 2) # 使用动画加载替代进度条 animate_loading("正在验证会员信息", 2)
result = checker.check_member(keyword) result = checker.check_member(keyword)
if result['is_valid']: if result['is_valid']:
@@ -612,14 +625,29 @@ def verify_member():
if result['expire_time']: if result['expire_time']:
expire_time = datetime.strptime(result['expire_time'], "%Y-%m-%d %H:%M:%S") expire_time = datetime.strptime(result['expire_time'], "%Y-%m-%d %H:%M:%S")
if expire_time < datetime.now(): if expire_time < datetime.now():
print(f"\n{Fore.RED} 会员已过期,请续费后重试{Style.RESET_ALL}") print(f"\n{Fore.YELLOW}[提示] 会员已过期请续费后重试{Style.RESET_ALL}")
sys.exit(1) sys.exit(0)
return result return result
print(f"\n{Fore.RED} 验证失败: {result['msg']}{Style.RESET_ALL}") print(f"\n{Fore.YELLOW}[提示] 验证失败: {result['msg']}{Style.RESET_ALL}")
retry = get_user_input("是否重试? (y/n):", ['y','n']) retry = get_user_input("是否重试? (y/n):", ['y','n'])
if retry != 'y': if retry.lower() != 'y':
sys.exit(1) print(f"\n{Fore.YELLOW}[提示] 程序已退出{Style.RESET_ALL}")
sys.exit(0)
retry_count += 1
except Exception as e:
if retry_count < max_retries - 1:
print(f"\n{Fore.YELLOW}[提示] 验证过程出现问题,正在重试...{Style.RESET_ALL}")
retry_count += 1
time.sleep(1)
continue
else:
print(f"\n{Fore.YELLOW}[提示] 验证失败次数过多,程序退出{Style.RESET_ALL}")
sys.exit(0)
print(f"\n{Fore.YELLOW}[提示] 验证次数已达上限,程序退出{Style.RESET_ALL}")
sys.exit(0)
def print_status(message, status="info"): def print_status(message, status="info"):
@@ -764,19 +792,31 @@ if __name__ == "__main__":
email=account, access_token=token, refresh_token=token email=account, access_token=token, refresh_token=token
) )
print_status("执行完整重置...") # 先关闭浏览器以释放文件锁
# 关闭浏览器以释放文件锁
if browser_manager: if browser_manager:
browser_manager.quit() browser_manager.quit()
# 执行完整重置 print_status("正在关闭 Cursor...", "info")
from full_reset import full_system_reset if ExitCursor():
if full_system_reset(): print_status("Cursor 已关闭", "success")
else:
print_status("Cursor 关闭失败,继续执行...", "warning")
time.sleep(2) # 等待进程完全退出
print_status("执行完整重置...")
# 以管理员权限执行完整重置
try:
subprocess.run([
"powershell",
"-Command",
"Start-Process python -ArgumentList 'full_reset.py' -Verb RunAs -Wait"
])
print_status("完整重置成功", "success") print_status("完整重置成功", "success")
print_status("所有操作已完成", "success") print_status("所有操作已完成", "success")
print(f"\n{Fore.GREEN}✓ 重置完成!下次启动 Cursor 将使用新的配置。{Style.RESET_ALL}") print(f"\n{Fore.GREEN}✓ 重置完成!下次启动 Cursor 将使用新的配置。{Style.RESET_ALL}")
else: except Exception as e:
print_status("完整重置失败", "error") print_status(f"完整重置失败: {str(e)}", "error")
else: else:
print_status("获取会话令牌失败,注册流程未完成", "error") print_status("获取会话令牌失败,注册流程未完成", "error")

View File

@@ -1,4 +1,4 @@
{ {
"email": "12132ed@qq.com", "email": "12132ed@qq.com",
"last_used": "2025-02-09 18:55:32" "last_used": "2025-02-09 23:13:26"
} }

View File

@@ -30,7 +30,7 @@ def print_logo():
██║ ╚████║╚██████╔╝███████║╚██████╔╝███████╗██║ ██║ ╚████║╚██████╔╝███████║╚██████╔╝███████╗██║
╚═╝ ╚═══╝ ╚═════╝ ╚══════╝ ╚══▀▀═╝ ╚══════╝╚═╝{Fore.CYAN} ╚═╝ ╚═══╝ ╚═════╝ ╚══════╝ ╚══▀▀═╝ ╚══════╝╚═╝{Fore.CYAN}
{Fore.YELLOW}CURSOR PROFESSIONAL TOOLS - ENTERPRISE EDITION V8.0{Fore.CYAN} {Fore.YELLOW}CURSOR PROFESSIONAL TOOLS - ENTERPRISE EDITION V8.0.1{Fore.CYAN}
════════════════════════════════════════════════════════════════════════════ ════════════════════════════════════════════════════════════════════════════

29
test_mail_api.py Normal file
View File

@@ -0,0 +1,29 @@
import requests
import json
# 禁用 SSL 警告
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
def test_mail_api():
print("开始测试邮箱API...")
try:
# 发送请求
response = requests.get(
'https://cursorapi.nosqli.com/admin/api.mail/getRandom',
verify=False,
proxies={"http": None, "https": None},
timeout=10
)
# 打印响应
print("\n状态码:", response.status_code)
print("\n响应内容:")
print(json.dumps(response.json(), indent=2, ensure_ascii=False))
except Exception as e:
print(f"\n请求失败: {str(e)}")
if __name__ == "__main__":
test_mail_api()