From e190a81ee43f6af47154fa50ebf97ddfbd4aa0dc Mon Sep 17 00:00:00 2001 From: jahv Date: Wed, 30 Apr 2025 07:41:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=82=AE=E4=BB=B6=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E5=8A=9F=E8=83=BD=EF=BC=8C=E7=AE=80=E5=8C=96=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E7=9B=B4=E6=8E=A5=E6=A3=80=E6=9F=A5=E9=82=AE?= =?UTF-8?q?=E4=BB=B6=E5=88=97=E8=A1=A8=E4=B8=AD=E7=9A=84=E7=AC=AC=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E9=82=AE=E4=BB=B6=E6=98=AF=E5=90=A6=E4=B8=BA=E6=96=B0?= =?UTF-8?q?=E9=82=AE=E4=BB=B6=EF=BC=8C=E5=B9=B6=E6=9B=B4=E6=96=B0=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E6=96=87=E6=A1=A3=E6=B3=A8=E9=87=8A=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- email_tabs/tempmail_plus_tab.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/email_tabs/tempmail_plus_tab.py b/email_tabs/tempmail_plus_tab.py index 2f2b8cf..bb23386 100644 --- a/email_tabs/tempmail_plus_tab.py +++ b/email_tabs/tempmail_plus_tab.py @@ -40,10 +40,10 @@ class TempMailPlusTab(EmailTabInterface): pass def check_for_cursor_email(self) -> bool: - """Check if there is a new email within the last 3 minutes + """Check if there is a new email Returns: - bool: True if new email within 3 minutes exists, False otherwise + bool: True if the first email in mail_list is new, False otherwise """ try: params = { @@ -60,18 +60,10 @@ class TempMailPlusTab(EmailTabInterface): data = response.json() if data.get('result') and data.get('mail_list'): - current_time = datetime.datetime.now() - for mail in data['mail_list']: - 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 - return True - except ValueError: - continue + # 检查邮件列表中的第一个邮件是否为新邮件 + if data['mail_list'][0].get('is_new') == True: + self._cached_mail_id = data['mail_list'][0].get('mail_id') # 缓存mail_id + return True return False except Exception as e: print(f"检查新邮件失败: {str(e)}")