ソースを参照

Rename scripts to fetch_requests/send_keys

Krystic Cong 1 ヶ月 前
コミット
59ff0836a4
4 ファイル変更22 行追加22 行削除
  1. 11 11
      README.md
  2. 6 6
      fetch_requests.py
  3. 0 0
      fill_sent_log.py
  4. 5 5
      send_keys.py

+ 11 - 11
README.md

@@ -2,8 +2,8 @@
 
 ## 项目概览
 这是一组自动化脚本,用来:
-1. 通过 `imap_curator_export.py` 登录 IMAP 邮箱,筛选 Steam Curator 索要激活码的邮件,导出 `curator_requests.xlsx`;
-2. 再用 `bulk_send_keys.py` 读取导出的 Excel 和 `steam_key.txt` 里的激活码池,批量发送 HTML 邮件,并记录每个 key 的派发日志。
+1. 通过 `fetch_requests.py` 登录 IMAP 邮箱,筛选 Steam Curator 索要激活码的邮件,导出 `curator_requests.xlsx`;
+2. 再用 `send_keys.py` 读取导出的 Excel 和 `steam_key.txt` 里的激活码池,批量发送 HTML 邮件,并记录每个 key 的派发日志。
 
 ## 环境准备
 1. 安装 Python 3.10 或更新版本(macOS 可用 `brew install python@3.10`,Windows 直接从 python.org 下载)。
@@ -55,7 +55,7 @@
 ```
 命令行如果只写文件名(如 `--excel curator_requests.xlsx`),脚本会自动拼接对应目录(records/templates/config)。
 
-## `imap_curator_export.py`
+## `fetch_requests.py`
 ### 作用
 登录 IMAP 邮箱、抓取自上次书签之后的邮件,排除回复/转发,提取 Curator 名称、邮箱、社交链接、所需 key 数等信息写入 `records/curator_requests.xlsx`。脚本会把已处理的邮箱/UID 存在 `configs/curator_state.json`,下次只扫描新的邮件。
 
@@ -66,21 +66,21 @@ IMAP/起始日期/输出路径等全部在 `configs/settings.json` 中维护(
 ### 常用命令
 ```bash
 # 1. 连通性测试(只确认能否登录,不读写状态)
-python imap_curator_export.py --config configs/settings.json --test
+python fetch_requests.py --config configs/settings.json --test
 
 # 2. 正式导出(使用/更新书签)
-python imap_curator_export.py --config configs/settings.json
+python fetch_requests.py --config configs/settings.json
 
 # 3. 重置书签后再导出(强制从 START_DATE 开始)
-python imap_curator_export.py --config configs/settings.json --reset-state
+python fetch_requests.py --config configs/settings.json --reset-state
 
 # 4. 导出后顺便把匹配的邮件标记为已读
-python imap_curator_export.py --config configs/settings.json --mark-read
+python fetch_requests.py --config configs/settings.json --mark-read
 ```
 
 运行完成后会在 `records/curator_requests.xlsx` 中追加 `curtor_YYYYMMDD##` 的表格,`configs/curator_state.json` 记录最新 `last_uid`。脚本结束时,还会贴心打印三条推荐命令(Dry-run / Test / Real)。
 
-## `bulk_send_keys.py`
+## `send_keys.py`
 ### 作用
 读取 `records/curator_requests.xlsx` 与 `records/steam_key.txt` 中待分发的激活码,按请求数量配给 key,使用 `templates/email_template.html`(若不存在则用脚本内置模板)渲染 HTML 邮件,通过 SMTP 发送,并在 `records/send_log.xlsx` 里记录“每个 key 一行”的详细日志(每次运行会新增 `sendlog_YYYYMMDD##` 的 sheet 并置顶;真实发送开始前会自动清理旧的 DRYRUN/TEST sheet)。脚本还会在 `configs/curator_state.json` 里维护 `sent_emails` 列表,防止向已发过 key 的邮箱重复派发。支持 Dry-run、Test 模式、跳过已处理 UID、发送成功后把原邮件标记 `\Answered`。如果 Excel 中包含 `Original Message-ID`,回复邮件会自动带上 `In-Reply-To/References`,方便邮件客户端按对话展示。
 
@@ -98,18 +98,18 @@ python imap_curator_export.py --config configs/settings.json --mark-read
 ### 示例
 ```bash
 # 1. 预览模式:只渲染邮件,不发送、不消耗 key
-python bulk_send_keys.py --config configs/settings.json \
+python send_keys.py --config configs/settings.json \
   --sheet curtor_2025111907 \
   --dry-run --limit 5
 
 # 2. 测试发送:发给指定测试邮箱,记录日志但不扣除 key
-python bulk_send_keys.py --config configs/settings.json \
+python send_keys.py --config configs/settings.json \
   --sheet curtor_2025111907 \
   --test --test-email your_test@example.com \
   --no-consume --no-sentemail
 
 # 3. 正式批量发送,并把成功邮件标记 \Answered
-python bulk_send_keys.py --config configs/settings.json \
+python send_keys.py --config configs/settings.json \
   --sheet curtor_2025111907 \
   --mark-answered
 ```

+ 6 - 6
imap_curator_export.py → fetch_requests.py

@@ -43,13 +43,13 @@ USAGE
    export STATE_FILE="curator_state.json"
 
 3) Run a connectivity test (no state read/write):
-   python imap_curator_export.py --test
+  python fetch_requests.py --test
 
 4) Run extraction:
-   python imap_curator_export.py
+  python fetch_requests.py
 
 5) Reset bookmark (force full scan from START_DATE next time):
-   python imap_curator_export.py --reset-state
+  python fetch_requests.py --reset-state
 
 Output:
    ./curator_requests.xlsx
@@ -724,7 +724,7 @@ def run_export(settings: Dict[str, Any], reset_state: bool = False, mark_read: b
 
         print(f"\nExported {len(df)} row(s) to {out_path}")
         print("\nDRY-RUN 命令:")
-        print(f"  python bulk_send_keys.py \\")
+        print(f"  python send_keys.py \\")
         print(f"    --excel {os.path.basename(out_path)} \\")
         print(f"    --sheet {sheet_name} \\")
         print(f"    --template \"email_template.html\" \\")
@@ -733,7 +733,7 @@ def run_export(settings: Dict[str, Any], reset_state: bool = False, mark_read: b
         print(f"    --subject \"Steam Keys for Such A Guy - \" \\")
         print(f"    --dry-run")
         print("\nTEST 命令:")
-        print(f"  python bulk_send_keys.py \\")
+        print(f"  python send_keys.py \\")
         print(f"    --excel {os.path.basename(out_path)} \\")
         print(f"    --sheet {sheet_name} \\")
         print(f"    --template \"email_template.html\" \\")
@@ -743,7 +743,7 @@ def run_export(settings: Dict[str, Any], reset_state: bool = False, mark_read: b
         print(f"    --test \\")
         print(f"    --no-consume --no-sentemail")
         print("\n正式执行命令:")
-        print(f"  python bulk_send_keys.py \\")
+        print(f"  python send_keys.py \\")
         print(f"    --excel {os.path.basename(out_path)} \\")
         print(f"    --sheet {sheet_name} \\")
         print(f"    --template \"email_template.html\" \\")

+ 0 - 0
backfill_sent_emails.py → fill_sent_log.py


+ 5 - 5
bulk_send_keys.py → send_keys.py

@@ -1,9 +1,9 @@
 #!/usr/bin/env python3
 # -*- coding: utf-8 -*-
 """
-bulk_send_keys.py
------------------
-Read an Excel exported by imap_curator_export.py, allocate Steam keys from a TXT pool (one per line),
+send_keys.py
+------------
+Read an Excel exported by fetch_requests.py, allocate Steam keys from a TXT pool (one per line),
 and send HTML emails to curators using a fixed template.
 
 This version:
@@ -22,10 +22,10 @@ This version:
 - Optional external HTML template via --template (fallback to built-in).
 
 Usage examples:
-  python bulk_send_keys.py --excel curator_requests.xlsx --keys key_pool.txt --out send_log.xlsx \
+  python send_keys.py --excel curator_requests.xlsx --keys key_pool.txt --out send_log.xlsx \
       --subject "Steam Keys for Such A Guy" --dry-run --limit 2
 
-  python bulk_send_keys.py --excel curator_requests.xlsx --keys key_pool.txt --out send_log.xlsx \
+  python send_keys.py --excel curator_requests.xlsx --keys key_pool.txt --out send_log.xlsx \
       --subject "Steam Keys for Such A Guy" --test --test-email krystic@such-one.com --limit 1
 """