mirror of
https://github.com/yeongpin/cursor-free-vip.git
synced 2025-08-03 04:57:36 +08:00
更新邮件检查功能,支持检查最近3分钟内的邮件,并更新错误处理信息。同时,添加了主程序入口以便于直接运行和测试TempMailPlusTab类。
This commit is contained in:
parent
d365e86952
commit
db490718c5
@ -1,5 +1,6 @@
|
|||||||
import requests
|
import requests
|
||||||
import re
|
import re
|
||||||
|
import datetime
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from .email_tab_interface import EmailTabInterface
|
from .email_tab_interface import EmailTabInterface
|
||||||
|
|
||||||
@ -39,10 +40,10 @@ class TempMailPlusTab(EmailTabInterface):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def check_for_cursor_email(self) -> bool:
|
def check_for_cursor_email(self) -> bool:
|
||||||
"""Check if there is a verification email from Cursor
|
"""Check if there is a new email within the last 3 minutes
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
bool: True if verification email exists, False otherwise
|
bool: True if new email within 3 minutes exists, False otherwise
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
params = {
|
params = {
|
||||||
@ -59,13 +60,21 @@ class TempMailPlusTab(EmailTabInterface):
|
|||||||
|
|
||||||
data = response.json()
|
data = response.json()
|
||||||
if data.get('result') and data.get('mail_list'):
|
if data.get('result') and data.get('mail_list'):
|
||||||
|
current_time = datetime.datetime.now()
|
||||||
for mail in data['mail_list']:
|
for mail in data['mail_list']:
|
||||||
if 'cursor.sh' in mail.get('from_mail', '') and mail.get('is_new') == True:
|
if mail.get('is_new') == True:
|
||||||
|
# 检查邮件时间是否在3分钟内
|
||||||
|
try:
|
||||||
|
mail_time = datetime.datetime.strptime(mail.get('time', ''), '%Y-%m-%d %H:%M:%S')
|
||||||
|
time_diff = (current_time - mail_time).total_seconds() / 60 # 转换为分钟
|
||||||
|
if time_diff <= 3: # 3分钟内的邮件
|
||||||
self._cached_mail_id = mail.get('mail_id') # 缓存mail_id
|
self._cached_mail_id = mail.get('mail_id') # 缓存mail_id
|
||||||
return True
|
return True
|
||||||
|
except ValueError:
|
||||||
|
continue
|
||||||
return False
|
return False
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"检查Cursor邮件失败: {str(e)}")
|
print(f"检查新邮件失败: {str(e)}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get_verification_code(self) -> str:
|
def get_verification_code(self) -> str:
|
||||||
@ -107,3 +116,40 @@ class TempMailPlusTab(EmailTabInterface):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"获取验证码失败: {str(e)}")
|
print(f"获取验证码失败: {str(e)}")
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from config import get_config
|
||||||
|
|
||||||
|
config = get_config()
|
||||||
|
|
||||||
|
try:
|
||||||
|
email = config.get('TempMailPlus', 'email')
|
||||||
|
epin = config.get('TempMailPlus', 'epin')
|
||||||
|
|
||||||
|
print(f"配置的邮箱: {email}")
|
||||||
|
|
||||||
|
# 初始化TempMailPlusTab
|
||||||
|
mail_tab = TempMailPlusTab(email, epin)
|
||||||
|
|
||||||
|
# 检查是否有Cursor的邮件
|
||||||
|
print("正在检查Cursor验证邮件...")
|
||||||
|
if mail_tab.check_for_cursor_email():
|
||||||
|
print("找到Cursor验证邮件")
|
||||||
|
|
||||||
|
# 获取验证码
|
||||||
|
verification_code = mail_tab.get_verification_code()
|
||||||
|
if verification_code:
|
||||||
|
print(f"获取到的验证码: {verification_code}")
|
||||||
|
else:
|
||||||
|
print("未能获取到验证码")
|
||||||
|
else:
|
||||||
|
print("未找到Cursor验证邮件")
|
||||||
|
|
||||||
|
except configparser.Error as e:
|
||||||
|
print(f"读取配置文件错误: {str(e)}")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"发生错误: {str(e)}")
|
Loading…
x
Reference in New Issue
Block a user