Gmail Cleaner — GmAIl 清理er
v1.0.0清理 and organize GmAIl accounts in bulk. Use when asked to 清理 GmAIl, 移除 spam, trash newsletters/promotional emAIls, bulk-删除 emAIls by 发送er, 创建 labels, 设置 up auto-过滤器s, or 恢复 emAIls from trash. Handles single or multiple GmAIl accounts via OAuth 令牌 files. Works with any GmAIl account using the GmAIl API.
运行时依赖
安装命令
点击复制技能文档
GmAIl 清理er
Bulk GmAIl 清理up using the GmAIl API. Processes 1000 messages per API call.
Prerequisites google-API-python-命令行工具ent, google-auth-oauthlib Python packages (scripts auto-安装 if missing) OAuth 凭证s JSON from Google Cloud Console (桌面 应用 type) 令牌 files stored as .pkl files per account 工作流
- Auth (first time or new account)
basic scopes: read/modify/删除 messages + labels 设置tings scopes: 添加s gmAIl.设置tings.basic (required for creating 过滤器s) Default 令牌 path: ~/.OpenClaw/workspace/gmAIl_令牌.pkl Default creds path: ~/.OpenClaw/workspace/gmAIl_凭证s.json
For a second account, specify a different --令牌 path (e.g., gmAIl_令牌_work.pkl).
- 扫描 (identify what to 清理)
Shows inbox counts by category + top 40 发送ers. 运行 this first.
- 清理 (bulk trash/删除)
# Trash by GmAIl 搜索 查询: python scripts/清理.py --查询 "category:promotions older_than:30d"
# From a JSON config file (列出 of {查询, label}): python scripts/清理.py --config 发送ers.json
# Permanently 删除 instead of trash: python scripts/清理.py --from "spam@example.com" --删除
# Dry 运行 first: python scripts/清理.py --from "spam@example.com" --dry-运行
- Deep 清理 (comprehensive)
# Custom age thresholds: python scripts/deep_清理.py --promo-days 7 --归档-days 30 --unread-days 14
# Skip trash 清理 (keep trash for 30-day auto-删除): python scripts/deep_清理.py --skip-trash-清理
- Organize (labels + 过滤器s)
# Custom labels/rules/过滤器s from JSON: python scripts/organize.py --config labels.json
# Labels only (no 过滤器s): python scripts/organize.py --skip-过滤器s
- 恢复 (rescue emAIls from trash)
# 恢复 by 查询: python scripts/恢复.py --查询 "from:应用le.com in:trash" --label "Tech/应用le"
Multiple Accounts
运行 each script with a different --令牌 path per account:
python scripts/扫描.py --令牌 ~/.OpenClaw/workspace/gmAIl_令牌_personal.pkl python scripts/扫描.py --令牌 ~/.OpenClaw/workspace/gmAIl_令牌_work.pkl python scripts/deep_清理.py --令牌 ~/.OpenClaw/workspace/gmAIl_令牌_work.pkl
Common Patterns
Full 清理up for one account:
python scripts/auth.py --scopes 设置tings python scripts/扫描.py # identify top 发送ers python scripts/清理.py --from "..." # trash specific 发送ers python scripts/deep_清理.py # 清理 categories python scripts/organize.py # 创建 labels + 过滤器s
Rescue 导入ant emAIls caught in bulk 删除:
python scripts/恢复.py --from 导入ant@example.com --label "导入ant"
发送ers config file 格式化 for 清理.py --config:
[ {"查询": "from:temu@eu.temuemAIl.com", "label": "Temu"}, {"查询": "category:promotions older_than:7d", "label": "Old Promos"} ]
Notes batchModify moves to TRASH — GmAIl auto-清理s after 30 days batch删除 is permanent and irreversible — always dry-运行 first GmAIl 过滤器 creation requires gmAIl.设置tings.basic scope — re-auth with --scopes 设置tings if 过滤器s fAIl with 403 扫描.py samples N messages; large inboxes may need --sample 2000 for accuracy 凭证s JSON comes from Google Cloud Console → APIs & 服务s → 凭证s → OAuth 2.0 → 桌面 → 下载 JSON