From 0d8648c5671221eb3ffe5bf79fbdd3acb37a8404 Mon Sep 17 00:00:00 2001 From: break27 Date: Thu, 14 Aug 2025 13:38:13 +0800 Subject: [PATCH] minor fix --- 邮件批量发送.py | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/邮件批量发送.py b/邮件批量发送.py index e660bf8..95a71cb 100644 --- a/邮件批量发送.py +++ b/邮件批量发送.py @@ -183,6 +183,16 @@ def main(): time.sleep(args.interval) while True: + try: + # 打开草稿箱 + click("li[data-id='default0/Brouillons']", condition=EC.presence_of_element_located) + click("button[data-id='default0/Brouillons']", condition=EC.presence_of_element_located) + # 打开邮件 + click("ul[aria-label='List view'] li[data-index='0']", condition=EC.presence_of_element_located) + except Exception as e: + print(f'[警告] 打开草稿邮件时发生了错误:{e}') + pass + try: print('[信息] 请选择数据源') title = 'Open (%s)' % args.address @@ -215,17 +225,6 @@ def main(): print(f'[信息] 已读取联系人信息共 {limit} 条') if limit == 0: continue - try: - # 打开草稿箱 - click("li[data-id='default0/Brouillons']", condition=EC.presence_of_element_located) - click("button[data-id='default0/Brouillons']", condition=EC.presence_of_element_located) - # 打开邮件 - click("ul[aria-label='List view'] li[data-index='0']", condition=EC.presence_of_element_located) - except Exception as e: - print(f'[警告] 打开草稿邮件时发生了错误:{e}') - print(f'[信息] 提示:请手动选择邮件') - pass - rate = 60 / (args.interval + 3) length = list.count(sents, None) timezone = ZoneInfo(args.timezone) if args.timezone else None @@ -237,9 +236,9 @@ def main(): entries = list(filter(lambda it: it.get('locale') == suffix, greetings)) locale = dict(entries[0]) if len(entries) > 0 else None - print(f'[信息] 当前语言:{str(suffix).upper() if locale else '无'}', end='\n\n') + print(f'[信息] 当前语言:{str(suffix).upper() if locale else '无'}') - if input('[????] 确认操作:(y) 确定 / (N) 取消') not in ['Y', 'y']: + if input('[????] 是否继续?确定 (y) / 取消 (N): ') not in ['Y', 'y']: print('[信息] 操作取消') continue @@ -248,7 +247,7 @@ def main(): print(f'[信息] 已读取邮件:{subject}') print(f'[信息] 指定发件人:{sender}') - if sender.lower().find(f'<{str(args.address).lower()}>'): + if sender.lower().find(f'<{str(args.address).lower()}>') == -1: print(f'[警告] 检测到发件人与设定不一致') print(f'[信息] 提示:请检查邮件是否正确') @@ -294,7 +293,7 @@ def main(): if (target := locate("h1.subject").text.strip()) != subject: print(f'[警告] 邮件主题与设定不一致:{target}') - if input('[????] 是否继续:(y) / (N): ') in ['Y', 'y']: + if input('[????] 是否继续?确定 (y) / 取消 (N): ') in ['Y', 'y']: subject = target print(f'[信息] 已更新邮件主题设定') else: @@ -397,8 +396,8 @@ def main(): except Exception as e: print(f'[警告] 写入文件时发生了错误:{e}') - if input('[????] 继续运行 (C) / 退出程序 (w): ') in ['W', 'w']: break - else: continue + if active and input('[????] 继续运行 (c) / 退出程序 (W): ') in ['C', 'c']: continue + else: break return 0