mirror of
https://github.com/yeongpin/cursor-free-vip.git
synced 2025-08-02 12:47:34 +08:00
增强邮件检查功能,新增验证码缓存机制,优化获取验证码的方法,并更新相关文档注释。
This commit is contained in:
parent
e190a81ee4
commit
be950c510c
@ -34,16 +34,17 @@ class TempMailPlusTab(EmailTabInterface):
|
|||||||
}
|
}
|
||||||
self.cookies = {'email': email}
|
self.cookies = {'email': email}
|
||||||
self._cached_mail_id = None # 缓存mail_id
|
self._cached_mail_id = None # 缓存mail_id
|
||||||
|
self._cached_verification_code = None # 缓存验证码
|
||||||
|
|
||||||
def refresh_inbox(self) -> None:
|
def refresh_inbox(self) -> None:
|
||||||
"""Refresh the email inbox"""
|
"""Refresh the email inbox"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def check_for_cursor_email(self) -> bool:
|
def check_for_cursor_email(self) -> bool:
|
||||||
"""Check if there is a new email
|
"""Check if there is a new email and immediately retrieve verification code
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
bool: True if the first email in mail_list is new, False otherwise
|
bool: True if new email found and verification code retrieved, False otherwise
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
params = {
|
params = {
|
||||||
@ -63,25 +64,27 @@ class TempMailPlusTab(EmailTabInterface):
|
|||||||
# 检查邮件列表中的第一个邮件是否为新邮件
|
# 检查邮件列表中的第一个邮件是否为新邮件
|
||||||
if data['mail_list'][0].get('is_new') == True:
|
if data['mail_list'][0].get('is_new') == True:
|
||||||
self._cached_mail_id = data['mail_list'][0].get('mail_id') # 缓存mail_id
|
self._cached_mail_id = data['mail_list'][0].get('mail_id') # 缓存mail_id
|
||||||
return True
|
|
||||||
|
# 立即获取验证码
|
||||||
|
verification_code = self._extract_verification_code()
|
||||||
|
if verification_code:
|
||||||
|
self._cached_verification_code = verification_code
|
||||||
|
return True
|
||||||
return False
|
return False
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"检查新邮件失败: {str(e)}")
|
print(f"检查新邮件失败: {str(e)}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get_verification_code(self) -> str:
|
def _extract_verification_code(self) -> str:
|
||||||
"""Get the verification code from the email
|
"""Extract verification code from email content
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
str: The verification code if found, empty string otherwise
|
str: The verification code if found, empty string otherwise
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
# 如果没有缓存的mail_id,先检查是否有新邮件
|
|
||||||
if not self._cached_mail_id:
|
if not self._cached_mail_id:
|
||||||
if not self.check_for_cursor_email():
|
return ""
|
||||||
return ""
|
|
||||||
|
|
||||||
# 使用缓存的mail_id获取邮件内容
|
|
||||||
params = {
|
params = {
|
||||||
'email': self.email,
|
'email': self.email,
|
||||||
'epin': self.epin
|
'epin': self.epin
|
||||||
@ -106,8 +109,16 @@ class TempMailPlusTab(EmailTabInterface):
|
|||||||
|
|
||||||
return ""
|
return ""
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"获取验证码失败: {str(e)}")
|
print(f"提取验证码失败: {str(e)}")
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
def get_verification_code(self) -> str:
|
||||||
|
"""Get the verification code from cache
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
str: The cached verification code if available, empty string otherwise
|
||||||
|
"""
|
||||||
|
return self._cached_verification_code or ""
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import os
|
import os
|
||||||
|
Loading…
x
Reference in New Issue
Block a user