Răsfoiți Sursa

Rename curator_state to curator_status

Krystic Cong 1 lună în urmă
părinte
comite
11dc4a1f1a
5 a modificat fișierele cu 11 adăugiri și 11 ștergeri
  1. 1 1
      .gitignore
  2. 5 5
      README.md
  3. 1 1
      configs/settings.template.json
  4. 2 2
      fetch_requests.py
  5. 2 2
      fill_sent_log.py

+ 1 - 1
.gitignore

@@ -43,5 +43,5 @@ Session.vim
 records/curator_requests.xlsx
 records/curator_requests.xlsx
 records/send_log.xlsx
 records/send_log.xlsx
 records/steam_key.txt
 records/steam_key.txt
-configs/curator_state.json
+configs/curator_status.json
 configs/settings.json
 configs/settings.json

+ 5 - 5
README.md

@@ -19,7 +19,7 @@
    若首次安装 pip 版本过旧,可先 `python -m pip install --upgrade pip`。
    若首次安装 pip 版本过旧,可先 `python -m pip install --upgrade pip`。
 4. 目录布局(已建好):
 4. 目录布局(已建好):
    - `configs/settings.json`:统一配置 IMAP/SMTP、默认文件路径(records/……)、主题、起始日期、最小 UID 等(仓库里只放模板 `configs/settings.template.json`,自己复制为 `settings.json` 使用);
    - `configs/settings.json`:统一配置 IMAP/SMTP、默认文件路径(records/……)、主题、起始日期、最小 UID 等(仓库里只放模板 `configs/settings.template.json`,自己复制为 `settings.json` 使用);
-   - `configs/curator_state.json`:脚本自动维护的书签与已发送邮箱;
+   - `configs/curator_status.json`:脚本自动维护的书签与已发送邮箱;
    - `templates/`:HTML 邮件模板(默认使用 `templates/email_template.html`);
    - `templates/`:HTML 邮件模板(默认使用 `templates/email_template.html`);
    - `records/`:输入/输出数据文件(默认 `curator_requests.xlsx`、`send_log.xlsx`、`steam_key.txt` 都在这里)。
    - `records/`:输入/输出数据文件(默认 `curator_requests.xlsx`、`send_log.xlsx`、`steam_key.txt` 都在这里)。
 
 
@@ -34,7 +34,7 @@
     "keys": "records/steam_key.txt",
     "keys": "records/steam_key.txt",
     "log": "records/send_log.xlsx",
     "log": "records/send_log.xlsx",
     "template": "templates/email_template.html",
     "template": "templates/email_template.html",
-    "state": "configs/curator_state.json"
+    "state": "configs/curator_status.json"
   },
   },
   "smtp": {
   "smtp": {
     "host": "smtp.feishu.cn",
     "host": "smtp.feishu.cn",
@@ -57,7 +57,7 @@
 
 
 ## `fetch_requests.py`
 ## `fetch_requests.py`
 ### 作用
 ### 作用
-登录 IMAP 邮箱、抓取自上次书签之后的邮件,排除回复/转发,提取 Curator 名称、邮箱、社交链接、所需 key 数等信息写入 `records/curator_requests.xlsx`。脚本会把已处理的邮箱/UID 存在 `configs/curator_state.json`,下次只扫描新的邮件。
+登录 IMAP 邮箱、抓取自上次书签之后的邮件,排除回复/转发,提取 Curator 名称、邮箱、社交链接、所需 key 数等信息写入 `records/curator_requests.xlsx`。脚本会把已处理的邮箱/UID 存在 `configs/curator_status.json`,下次只扫描新的邮件。
 
 
 IMAP/起始日期/输出路径等全部在 `configs/settings.json` 中维护(运行时可改用 `--config path/to/settings.json`)。
 IMAP/起始日期/输出路径等全部在 `configs/settings.json` 中维护(运行时可改用 `--config path/to/settings.json`)。
 
 
@@ -78,11 +78,11 @@ python fetch_requests.py --config configs/settings.json --reset-state
 python fetch_requests.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)。
+运行完成后会在 `records/curator_requests.xlsx` 中追加 `curtor_YYYYMMDD##` 的表格,`configs/curator_status.json` 记录最新 `last_uid`。脚本结束时,还会贴心打印三条推荐命令(Dry-run / Test / Real)。
 
 
 ## `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`,方便邮件客户端按对话展示。
+读取 `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_status.json` 里维护 `sent_emails` 列表,防止向已发过 key 的邮箱重复派发。支持 Dry-run、Test 模式、跳过已处理 UID、发送成功后把原邮件标记 `\Answered`。如果 Excel 中包含 `Original Message-ID`,回复邮件会自动带上 `In-Reply-To/References`,方便邮件客户端按对话展示。
 
 
 ### 关键参数
 ### 关键参数
 默认配置全部来自 `configs/settings.json`,命令行参数只在需要覆盖默认值时使用。常见参数:
 默认配置全部来自 `configs/settings.json`,命令行参数只在需要覆盖默认值时使用。常见参数:

+ 1 - 1
configs/settings.template.json

@@ -7,7 +7,7 @@
     "keys": "records/steam_key.txt",
     "keys": "records/steam_key.txt",
     "log": "records/send_log.xlsx",
     "log": "records/send_log.xlsx",
     "template": "templates/email_template.html",
     "template": "templates/email_template.html",
-    "state": "configs/curator_state.json"
+    "state": "configs/curator_status.json"
   },
   },
   "smtp": {
   "smtp": {
     "host": "smtp.example.com",
     "host": "smtp.example.com",

+ 2 - 2
fetch_requests.py

@@ -40,7 +40,7 @@ USAGE
    # Start date used ONLY for the first run (no state yet). IMAP format DD-Mon-YYYY.
    # Start date used ONLY for the first run (no state yet). IMAP format DD-Mon-YYYY.
    export START_DATE="18-Oct-2025"
    export START_DATE="18-Oct-2025"
    # Optional: where to store/read bookmark state per mailbox
    # Optional: where to store/read bookmark state per mailbox
-   export STATE_FILE="curator_state.json"
+   export STATE_FILE="curator_status.json"
 
 
 3) Run a connectivity test (no state read/write):
 3) Run a connectivity test (no state read/write):
   python fetch_requests.py --test
   python fetch_requests.py --test
@@ -524,7 +524,7 @@ def connectivity_test(settings: Dict[str, Any]) -> int:
 
 
 def run_export(settings: Dict[str, Any], reset_state: bool = False, mark_read: bool = False) -> int:
 def run_export(settings: Dict[str, Any], reset_state: bool = False, mark_read: bool = False) -> int:
     files_conf = settings.get("files", {})
     files_conf = settings.get("files", {})
-    state_path = os.path.abspath(files_conf.get("state", os.path.join("config", "curator_state.json")))
+    state_path = os.path.abspath(files_conf.get("state", os.path.join("configs", "curator_status.json")))
     out_path = os.path.abspath(files_conf.get("excel", os.path.join("records", "curator_requests.xlsx")))
     out_path = os.path.abspath(files_conf.get("excel", os.path.join("records", "curator_requests.xlsx")))
     start_date = imap_date_string(settings.get("start_date", "18-Oct-2025"))
     start_date = imap_date_string(settings.get("start_date", "18-Oct-2025"))
     imap_conf = settings.get("imap", {})
     imap_conf = settings.get("imap", {})

+ 2 - 2
fill_sent_log.py

@@ -2,7 +2,7 @@
 # -*- coding: utf-8 -*-
 # -*- coding: utf-8 -*-
 """
 """
 临时脚本:读取 configs/settings.json 里的 IMAP 配置,从指定的 Sent 邮箱抓取所有邮件,
 临时脚本:读取 configs/settings.json 里的 IMAP 配置,从指定的 Sent 邮箱抓取所有邮件,
-把其中出现过的收件人邮箱写入 configs/curator_state.json 的 sent_emails 字段。
+把其中出现过的收件人邮箱写入 configs/curator_status.json 的 sent_emails 字段。
 
 
 使用方式(在仓库根目录):
 使用方式(在仓库根目录):
   python backfill_sent_emails.py
   python backfill_sent_emails.py
@@ -110,7 +110,7 @@ def fetch_sent_addresses(imap_conf: dict) -> set[str]:
 def main() -> None:
 def main() -> None:
     settings = load_settings(SETTINGS_PATH)
     settings = load_settings(SETTINGS_PATH)
     files = settings.get("files", {})
     files = settings.get("files", {})
-    state_path = os.path.abspath(files.get("state", os.path.join("configs", "curator_state.json")))
+    state_path = os.path.abspath(files.get("state", os.path.join("configs", "curator_status.json")))
     imap_conf = settings.get("imap", {})
     imap_conf = settings.get("imap", {})
 
 
     new_addresses = fetch_sent_addresses(imap_conf)
     new_addresses = fetch_sent_addresses(imap_conf)