mirror of
https://github.com/yeongpin/cursor-free-vip.git
synced 2025-08-03 04:57:36 +08:00
Add local blocked domains feature and enhance verification code retrieval with retry mechanism. Update CHANGELOG.md to reflect new feature.
This commit is contained in:
parent
bef2162509
commit
a7433ec032
@ -8,7 +8,8 @@
|
|||||||
5. Add: Auto Detect Max Use Count | 增加自動檢測最大使用次數
|
5. Add: Auto Detect Max Use Count | 增加自動檢測最大使用次數
|
||||||
6. Add: Detect & Auto Delete Account | 增加檢測 & 自動刪除賬號
|
6. Add: Detect & Auto Delete Account | 增加檢測 & 自動刪除賬號
|
||||||
7. Add: Optimize Some Logic | 優化一些邏輯
|
7. Add: Optimize Some Logic | 優化一些邏輯
|
||||||
|
8. Add: Local Blocked Domains | 增加本地被屏蔽域名
|
||||||
|
9. Fix : Get Verification Code for None | 修復獲取驗證碼為 None
|
||||||
|
|
||||||
## v1.7.10
|
## v1.7.10
|
||||||
1. Add: Totally Reset Cursor | 增加完全重置 Cursor
|
1. Add: Totally Reset Cursor | 增加完全重置 Cursor
|
||||||
|
@ -33,7 +33,8 @@ a = Analysis(
|
|||||||
('new_tempemail.py', '.'),
|
('new_tempemail.py', '.'),
|
||||||
('quit_cursor.py', '.'),
|
('quit_cursor.py', '.'),
|
||||||
('cursor_register_manual.py', '.'),
|
('cursor_register_manual.py', '.'),
|
||||||
('.env', '.')
|
('.env', '.'),
|
||||||
|
('block_domain.txt', '.')
|
||||||
],
|
],
|
||||||
hiddenimports=[
|
hiddenimports=[
|
||||||
'cursor_auth',
|
'cursor_auth',
|
||||||
|
137
new_tempemail.py
137
new_tempemail.py
@ -6,6 +6,7 @@ from colorama import Fore, Style, init
|
|||||||
import requests
|
import requests
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
|
from utils import get_random_wait_time
|
||||||
|
|
||||||
# Initialize colorama
|
# Initialize colorama
|
||||||
init()
|
init()
|
||||||
@ -38,12 +39,37 @@ class NewTempEmail:
|
|||||||
else:
|
else:
|
||||||
print(f"{Fore.CYAN}ℹ️ 已加载 {len(domains)} 个被屏蔽的域名{Style.RESET_ALL}")
|
print(f"{Fore.CYAN}ℹ️ 已加载 {len(domains)} 个被屏蔽的域名{Style.RESET_ALL}")
|
||||||
return domains
|
return domains
|
||||||
return []
|
return self._load_local_blocked_domains()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if self.translator:
|
if self.translator:
|
||||||
print(f"{Fore.YELLOW}⚠️ {self.translator.get('email.blocked_domains_error', error=str(e))}{Style.RESET_ALL}")
|
print(f"{Fore.YELLOW}⚠️ {self.translator.get('email.blocked_domains_error', error=str(e))}{Style.RESET_ALL}")
|
||||||
else:
|
else:
|
||||||
print(f"{Fore.YELLOW}⚠️ 获取被屏蔽域名列表失败: {str(e)}{Style.RESET_ALL}")
|
print(f"{Fore.YELLOW}⚠️ 获取被屏蔽域名列表失败: {str(e)}{Style.RESET_ALL}")
|
||||||
|
return self._load_local_blocked_domains()
|
||||||
|
|
||||||
|
def _load_local_blocked_domains(self):
|
||||||
|
"""Load blocked domains from local file as fallback"""
|
||||||
|
try:
|
||||||
|
local_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "block_domain.txt")
|
||||||
|
if os.path.exists(local_path):
|
||||||
|
with open(local_path, 'r', encoding='utf-8') as f:
|
||||||
|
domains = [line.strip() for line in f.readlines() if line.strip()]
|
||||||
|
if self.translator:
|
||||||
|
print(f"{Fore.CYAN}ℹ️ {self.translator.get('email.local_blocked_domains_loaded', count=len(domains))}{Style.RESET_ALL}")
|
||||||
|
else:
|
||||||
|
print(f"{Fore.CYAN}ℹ️ 已从本地加载 {len(domains)} 个被屏蔽的域名{Style.RESET_ALL}")
|
||||||
|
return domains
|
||||||
|
else:
|
||||||
|
if self.translator:
|
||||||
|
print(f"{Fore.YELLOW}⚠️ {self.translator.get('email.local_blocked_domains_not_found')}{Style.RESET_ALL}")
|
||||||
|
else:
|
||||||
|
print(f"{Fore.YELLOW}⚠️ 本地被屏蔽域名文件不存在{Style.RESET_ALL}")
|
||||||
|
return []
|
||||||
|
except Exception as e:
|
||||||
|
if self.translator:
|
||||||
|
print(f"{Fore.YELLOW}⚠️ {self.translator.get('email.local_blocked_domains_error', error=str(e))}{Style.RESET_ALL}")
|
||||||
|
else:
|
||||||
|
print(f"{Fore.YELLOW}⚠️ 读取本地被屏蔽域名文件失败: {str(e)}{Style.RESET_ALL}")
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def exclude_blocked_domains(self, domains):
|
def exclude_blocked_domains(self, domains):
|
||||||
@ -296,48 +322,75 @@ class NewTempEmail:
|
|||||||
print(f"{Fore.RED}❌ 检查验证邮件出错: {str(e)}{Style.RESET_ALL}")
|
print(f"{Fore.RED}❌ 检查验证邮件出错: {str(e)}{Style.RESET_ALL}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get_verification_code(self):
|
def get_verification_code(self, max_retries=3):
|
||||||
"""get verification code"""
|
"""get verification code with retry mechanism"""
|
||||||
try:
|
for attempt in range(1, max_retries + 1):
|
||||||
# Use API to get email list
|
try:
|
||||||
headers = {"Authorization": f"Bearer {self.token}"}
|
# Check if token is valid
|
||||||
response = requests.get(f"{self.api_url}/messages", headers=headers)
|
if not self.token:
|
||||||
|
if self.translator:
|
||||||
if response.status_code == 200:
|
print(f"{Fore.YELLOW}⚠️ {self.translator.get('email.no_token_retry')}{Style.RESET_ALL}")
|
||||||
messages = response.json()["hydra:member"]
|
else:
|
||||||
for message in messages:
|
print(f"{Fore.YELLOW}⚠️ 未获取到有效令牌,尝试重新创建邮箱... (尝试 {attempt}/{max_retries}){Style.RESET_ALL}")
|
||||||
if message["from"]["address"] == "no-reply@cursor.sh" and "Verify your email address" in message["subject"]:
|
|
||||||
# Get email content
|
# Try to recreate email
|
||||||
message_id = message["id"]
|
self.create_email()
|
||||||
message_response = requests.get(f"{self.api_url}/messages/{message_id}", headers=headers)
|
if not self.token:
|
||||||
|
continue # Skip to next attempt if still no token
|
||||||
if message_response.status_code == 200:
|
|
||||||
# Extract verification code from email content
|
# Use API to get email list
|
||||||
email_content = message_response.json()["text"]
|
headers = {"Authorization": f"Bearer {self.token}"}
|
||||||
# Find 6-digit verification code
|
response = requests.get(f"{self.api_url}/messages", headers=headers)
|
||||||
import re
|
|
||||||
code_match = re.search(r'\b\d{6}\b', email_content)
|
if response.status_code == 200:
|
||||||
|
messages = response.json()["hydra:member"]
|
||||||
|
for message in messages:
|
||||||
|
if message["from"]["address"] == "no-reply@cursor.sh" and "Verify your email address" in message["subject"]:
|
||||||
|
# Get email content
|
||||||
|
message_id = message["id"]
|
||||||
|
message_response = requests.get(f"{self.api_url}/messages/{message_id}", headers=headers)
|
||||||
|
|
||||||
if code_match:
|
if message_response.status_code == 200:
|
||||||
code = code_match.group(0)
|
# Extract verification code from email content
|
||||||
if self.translator:
|
email_content = message_response.json()["text"]
|
||||||
print(f"{Fore.GREEN}✅ {self.translator.get('email.verification_code_found')}: {code}{Style.RESET_ALL}")
|
# Find 6-digit verification code
|
||||||
else:
|
import re
|
||||||
print(f"{Fore.GREEN}✅ 获取验证码成功: {code}{Style.RESET_ALL}")
|
code_match = re.search(r'\b\d{6}\b', email_content)
|
||||||
return code
|
|
||||||
|
if code_match:
|
||||||
if self.translator:
|
code = code_match.group(0)
|
||||||
print(f"{Fore.YELLOW}⚠️ {self.translator.get('email.verification_code_not_found')}{Style.RESET_ALL}")
|
if self.translator:
|
||||||
else:
|
print(f"{Fore.GREEN}✅ {self.translator.get('email.verification_code_found')}: {code}{Style.RESET_ALL}")
|
||||||
print(f"{Fore.YELLOW}⚠️ 未找到有效的验证码{Style.RESET_ALL}")
|
else:
|
||||||
return None
|
print(f"{Fore.GREEN}✅ 获取验证码成功: {code}{Style.RESET_ALL}")
|
||||||
|
return code
|
||||||
except Exception as e:
|
|
||||||
if self.translator:
|
if attempt < max_retries:
|
||||||
print(f"{Fore.RED}❌ {self.translator.get('email.verification_code_error')}: {str(e)}{Style.RESET_ALL}")
|
wait_time = 10 * attempt # Increase wait time with each attempt
|
||||||
else:
|
if self.translator:
|
||||||
print(f"{Fore.RED}❌ 获取验证码出错: {str(e)}{Style.RESET_ALL}")
|
print(f"{Fore.YELLOW}⚠️ {self.translator.get('email.verification_code_retry', attempt=attempt, max=max_retries, wait=wait_time)}{Style.RESET_ALL}")
|
||||||
return None
|
else:
|
||||||
|
print(f"{Fore.YELLOW}⚠️ 未找到有效的验证码,将在 {wait_time} 秒后重试... (尝试 {attempt}/{max_retries}){Style.RESET_ALL}")
|
||||||
|
time.sleep(wait_time)
|
||||||
|
else:
|
||||||
|
if self.translator:
|
||||||
|
print(f"{Fore.RED}❌ {self.translator.get('email.verification_code_not_found')}{Style.RESET_ALL}")
|
||||||
|
else:
|
||||||
|
print(f"{Fore.RED}❌ 未找到有效的验证码{Style.RESET_ALL}")
|
||||||
|
except Exception as e:
|
||||||
|
if attempt < max_retries:
|
||||||
|
if self.translator:
|
||||||
|
print(f"{Fore.YELLOW}⚠️ {self.translator.get('email.verification_code_error_retry', error=str(e), attempt=attempt, max=max_retries)}{Style.RESET_ALL}")
|
||||||
|
else:
|
||||||
|
print(f"{Fore.YELLOW}⚠️ 获取验证码出错: {str(e)},将重试... (尝试 {attempt}/{max_retries}){Style.RESET_ALL}")
|
||||||
|
time.sleep(get_random_wait_time(self.config, 'page_load_wait'))
|
||||||
|
else:
|
||||||
|
if self.translator:
|
||||||
|
print(f"{Fore.RED}❌ {self.translator.get('email.verification_code_error')}: {str(e)}{Style.RESET_ALL}")
|
||||||
|
else:
|
||||||
|
print(f"{Fore.RED}❌ 获取验证码出错: {str(e)}{Style.RESET_ALL}")
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
def main(translator=None):
|
def main(translator=None):
|
||||||
temp_email = NewTempEmail(translator)
|
temp_email = NewTempEmail(translator)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user