4 Commits

Author SHA1 Message Date
huangzhenpc
7e2dd19a20 refactor: 移除调试打印信息 2025-02-10 17:09:36 +08:00
huangzhenpc
6403cd20f6 feat: 8.0.2.1版本更新主程序代码 2025-02-10 17:08:18 +08:00
huangzhenpc
241b1f2413 feat: 8.0.2.1版本支持QQ邮箱获取验证码 2025-02-10 16:59:21 +08:00
huangzhenpc
d1232d7d3b docs: 添加 8.0.2 版本开发任务说明文档 2025-02-10 11:07:31 +08:00
9 changed files with 102 additions and 105 deletions

BIN
README.md

Binary file not shown.

38
VERSION_8.0.2.md Normal file
View File

@@ -0,0 +1,38 @@
# Cursor V8.0.2 版本开发任务
## 分支信息
- 分支名称:`8.0.2`
- 基于分支:`master` (8.0.1)
- 开发状态:进行中
## 主要任务
### 1. 邮箱服务迁移
- 将临时邮箱服务从国外 temp 邮箱迁移至国内邮箱服务
- 优化邮箱验证流程
- 提高邮件送达率和稳定性
### 2. 计费系统优化
- 改进计费触发时机
- 实现脚本执行完成后再进行计费
- 优化计费准确性和可靠性
## 预期改进
- 提高邮箱服务的稳定性和速度
- 更准确的计费统计
- 更好的用户体验
## 测试重点
1. 新邮箱服务的可用性测试
2. 计费系统的准确性验证
3. 脚本执行完成后的计费时机控制
## 注意事项
- 确保邮箱服务迁移过程中的平滑过渡
- 保证计费系统改造不影响现有用户
- 做好版本升级方案
## 相关文件
- `config.py`: 邮箱配置更新
- `cursor_pro_keep_alive.py`: 计费逻辑优化
- `test_mail_api.py`: 新邮箱服务测试

View File

@@ -15,12 +15,19 @@ class Config:
def __init__(self): def __init__(self):
# 默认配置 # 默认配置
self.default_config = { self.default_config = {
"TEMP_MAIL": "demo", "TEMP_MAIL": "", # 设置为空字符串,表示可选
"TEMP_MAIL_EXT": "@mailto.plus", "TEMP_MAIL_EXT": "@mailto.plus",
"TEMP_MAIL_EPIN": "", "TEMP_MAIL_EPIN": "",
"DOMAIN": "mailto.plus", "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", "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" "MAIL_SERVER": "https://tempmail.plus",
# IMAP 相关配置
"USE_IMAP": False, # 是否使用 IMAP
"IMAP_HOST": "",
"IMAP_PORT": 993,
"IMAP_USERNAME": "",
"IMAP_PASSWORD": "",
"IMAP_USE_SSL": True
} }
# 获取应用程序的根目录路径 # 获取应用程序的根目录路径
@@ -53,7 +60,7 @@ class Config:
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/gettestapi",
timeout=10, timeout=10,
allow_redirects=True allow_redirects=True
) )
@@ -73,21 +80,29 @@ class Config:
# 设置配置项 # 设置配置项
self.imap = False self.imap = False
self.temp_mail = config.get("TEMP_MAIL", self.default_config["TEMP_MAIL"]).strip()
self.temp_mail_ext = config.get("TEMP_MAIL_EXT", self.default_config["TEMP_MAIL_EXT"]).strip() # 处理 TEMP_MAIL如果为 null 则启用 IMAP
self.temp_mail_epin = config.get("TEMP_MAIL_EPIN", self.default_config["TEMP_MAIL_EPIN"]).strip() temp_mail = config.get("TEMP_MAIL")
self.domain = config.get("DOMAIN", self.default_config["DOMAIN"]).strip() if temp_mail is None or temp_mail == "null":
self.browser_user_agent = config.get("BROWSER_USER_AGENT", self.default_config["BROWSER_USER_AGENT"]).strip()
self.mail_server = config.get("MAIL_SERVER", self.default_config["MAIL_SERVER"]).strip()
# 如果临时邮箱为null则加载IMAP
if self.temp_mail == "null":
self.imap = True self.imap = True
self.imap_server = config.get("IMAP_SERVER", "").strip() self.temp_mail = "null"
self.imap_port = config.get("IMAP_PORT", "").strip() else:
self.imap_user = config.get("IMAP_USER", "").strip() self.temp_mail = str(temp_mail).strip()
self.imap_pass = config.get("IMAP_PASS", "").strip()
self.imap_dir = config.get("IMAP_DIR", "inbox").strip() # 设置其他基础配置
self.temp_mail_ext = str(config.get("TEMP_MAIL_EXT", self.default_config["TEMP_MAIL_EXT"])).strip()
self.temp_mail_epin = str(config.get("TEMP_MAIL_EPIN", self.default_config["TEMP_MAIL_EPIN"])).strip()
self.domain = str(config.get("DOMAIN", self.default_config["DOMAIN"])).strip()
self.browser_user_agent = str(config.get("BROWSER_USER_AGENT", self.default_config["BROWSER_USER_AGENT"])).strip()
self.mail_server = str(config.get("MAIL_SERVER", self.default_config["MAIL_SERVER"])).strip()
# 如果启用了 IMAP设置 IMAP 配置
if self.imap:
self.imap_server = str(config.get("IMAP_SERVER", "")).strip()
self.imap_port = str(config.get("IMAP_PORT", "")).strip()
self.imap_user = str(config.get("IMAP_USER", "")).strip()
self.imap_pass = str(config.get("IMAP_PASS", "")).strip()
self.imap_dir = str(config.get("IMAP_DIR", "inbox")).strip()
self.check_config() self.check_config()

View File

@@ -254,10 +254,12 @@ def handle_verification_code(tab, email_handler):
return True return True
retry_count += 1 retry_count += 1
print(f"[调试] 未找到验证码输入框,重试次数: {retry_count}")
time.sleep(1) time.sleep(1)
except Exception as e: except Exception as e:
print_status(f"验证码处理过程出错: {str(e)}", "error") print_status(f"验证码处理过程出错: {str(e)}", "error")
print(f"[调试] 错误详情: {str(e)}")
retry_count += 1 retry_count += 1
if retry_count < max_retries: if retry_count < max_retries:
time.sleep(1) time.sleep(1)
@@ -760,8 +762,8 @@ if __name__ == "__main__":
print_status("浏览器初始化完成", "success") print_status("浏览器初始化完成", "success")
print_status("正在初始化邮箱验证模块...")
email_handler = EmailVerificationHandler()
print_step_header("配置信息") print_step_header("配置信息")
login_url = "https://authenticator.cursor.sh" login_url = "https://authenticator.cursor.sh"
@@ -779,6 +781,11 @@ if __name__ == "__main__":
print_status(f"生成的邮箱账号: {account}") print_status(f"生成的邮箱账号: {account}")
auto_update_cursor_auth = True auto_update_cursor_auth = True
print_status("正在初始化邮箱验证模块...")
# 使用生成的account初始化email_handler
email_handler = EmailVerificationHandler(account=account)
print_status("初始化邮箱验证模块成功", "success")
tab = browser.latest_tab tab = browser.latest_tab
tab.run_js("try { turnstile.reset() } catch(e) { }") tab.run_js("try { turnstile.reset() } catch(e) { }")

View File

@@ -9,11 +9,12 @@ import json
class EmailVerificationHandler: class EmailVerificationHandler:
def __init__(self): def __init__(self, account=None):
config = Config() config = Config()
self.imap = config.get_imap() self.imap = config.get_imap()
self.username = config.get_temp_mail() self.username = config.get_temp_mail()
self.epin = config.get_temp_mail_epin() self.epin = config.get_temp_mail_epin()
self.account = account # 添加account属性用于存储随机生成的邮箱
# 创建新的session并设置基本配置 # 创建新的session并设置基本配置
self.session = requests.Session() self.session = requests.Session()
@@ -56,25 +57,38 @@ class EmailVerificationHandler:
mail.login(self.imap['imap_user'], self.imap['imap_pass']) mail.login(self.imap['imap_user'], self.imap['imap_pass'])
mail.select(self.imap['imap_dir']) mail.select(self.imap['imap_dir'])
status, messages = mail.search(None, 'FROM', '"no-reply@cursor.sh"') # 使用分开的参数方式搜索,更准确
status, messages = mail.search(None, 'TO', f'"{self.account}"', 'FROM', '"no-reply@cursor.sh"')
if status != 'OK': if status != 'OK':
return None return None
mail_ids = messages[0].split() mail_ids = messages[0].split()
if not mail_ids: if not mail_ids:
# 没有获取到,就获取一次 # 没有获取到,就获取一次
return self._get_mail_code_by_imap(retry=retry + 1) return self._get_mail_code_by_imap(retry=retry + 1)
latest_mail_id = mail_ids[-1] latest_id = mail_ids[-1]
# 获取邮件内容 # 获取邮件内容
status, msg_data = mail.fetch(latest_mail_id, '(RFC822)') status, msg_data = mail.fetch(latest_id, '(RFC822)')
if status != 'OK': if status != 'OK':
return None return None
raw_email = msg_data[0][1] raw_email = msg_data[0][1]
email_message = email.message_from_bytes(raw_email) email_message = email.message_from_bytes(raw_email)
# 严格验证收件人
to_addresses = email_message.get_all('to', [])
found_match = False
for addr in to_addresses:
if self.account.lower() in addr.lower():
found_match = True
break
if not found_match:
return self._get_mail_code_by_imap(retry=retry + 1)
# 提取邮件正文 # 提取邮件正文
body = self._extract_imap_body(email_message) body = self._extract_imap_body(email_message)
if body: if body:
@@ -83,16 +97,13 @@ class EmailVerificationHandler:
if code_match: if code_match:
code = code_match.group() code = code_match.group()
# 删除邮件 # 删除邮件
mail.store(latest_mail_id, '+FLAGS', '\\Deleted') mail.store(latest_id, '+FLAGS', '\\Deleted')
mail.expunge() mail.expunge()
mail.logout() mail.logout()
# print(f"找到的验证码: {code}")
return code return code
# print("未找到验证码")
mail.logout() mail.logout()
return None return None
except Exception as e: except Exception as e:
print(f"发生错误: {e}")
return None return None
def _extract_imap_body(self, email_message): def _extract_imap_body(self, email_message):
@@ -177,6 +188,4 @@ class EmailVerificationHandler:
if __name__ == "__main__": if __name__ == "__main__":
email_handler = EmailVerificationHandler() pass
code = email_handler.get_verification_code()
print(code)

View File

@@ -1,4 +1,4 @@
{ {
"email": "12132ed@qq.com", "email": "12132ed@qq.com",
"last_used": "2025-02-09 23:13:26" "last_used": "2025-02-10 17:03:43"
} }

View File

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

View File

@@ -1,43 +0,0 @@
import requests
import json
import urllib3
# 禁用SSL警告
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
def test_specific_email():
print("开始测试指定邮箱API...")
# 创建session并配置
session = requests.Session()
session.verify = False
session.trust_env = False
# 测试URL
test_url = "https://tempmail.plus/api/mails?email=ademyyk@mailto.plus&limit=20&epin="
try:
# 不使用代理直接测试
print("\n1. 直接连接测试...")
response = session.get(test_url)
print(f"状态码: {response.status_code}")
print(f"响应内容: {json.dumps(response.json(), indent=2, ensure_ascii=False)}")
except Exception as e:
print(f"\n直接连接出错: {e}")
# 如果直接连接失败,尝试使用代理
try:
print("\n2. 尝试使用代理...")
proxies = {
'http': 'http://127.0.0.1:7890',
'https': 'http://127.0.0.1:7890'
}
response = session.get(test_url, proxies=proxies)
print(f"状态码: {response.status_code}")
print(f"响应内容: {json.dumps(response.json(), indent=2, ensure_ascii=False)}")
except Exception as e:
print(f"\n代理连接也出错: {e}")
if __name__ == "__main__":
test_specific_email()

View File

@@ -1,29 +0,0 @@
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()