"""按现场探针结论清掉 4 个永远服务不了的待回复任务,给监听一个干净起点。 两个是订阅号/系统号行(打卡、行业资讯),指纹分毫不差但 _is_real_conversation 永远否掉;两个在整份会话列表里已经不存在。代码现在会自己淘汰它们,但要熬过 退避,这里一次性清完。 """ import json import os import shutil import time ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) PENDING = os.path.join(ROOT, "pending_replies.json") UNREPLIABLE = os.path.join(ROOT, "unrepliable_sessions.json") NOT_A_CONVERSATION = [ "071f171f101f1f00", # 行业资讯(订阅号行) "87878f8f8f878682", # 打卡(系统号行) ] GONE_FROM_LIST = [ "f0e0f0f0f0f0f0f8", "787818181f0f0f00", ] def main() -> None: stamp = time.strftime("%Y%m%d_%H%M%S") shutil.copy2(PENDING, f"{PENDING}.{stamp}.bak") with open(PENDING, encoding="utf-8") as handle: data = json.load(handle) pending = data.get("pending", data) doomed = tuple(NOT_A_CONVERSATION + GONE_FROM_LIST) removed = [k for k in pending if k.startswith(doomed)] for key in removed: pending.pop(key) with open(PENDING, "w", encoding="utf-8") as handle: json.dump(data, handle, ensure_ascii=False, indent=2) print(f"已清理 {len(removed)} 个任务,剩余 {len(pending)} 个") blacklist = {} if os.path.exists(UNREPLIABLE): try: with open(UNREPLIABLE, encoding="utf-8") as handle: blacklist = json.load(handle) or {} except Exception: blacklist = {} now = time.time() for key in removed: if key.startswith(tuple(NOT_A_CONVERSATION)): blacklist[key] = now with open(UNREPLIABLE, "w", encoding="utf-8") as handle: json.dump(blacklist, handle, ensure_ascii=False, indent=2) print(f"订阅号/系统号名单 {len(blacklist)} 个,6 小时后自动复查") if __name__ == "__main__": main()