feat(设备端): 每 5 秒账号巡检 + 打码名按账号库还原

- 后台线程每 5s 并行探测所有在线设备,账号变化才广播下发
- resolve_masked_name:锋哥苏***探访 → 账号库唯一匹配的完整昵称
- /api/device/agent/account 同一套还原(平台/手机手动切号都覆盖)
- 多匹配用上次完整名 tiebreak,分不清不猜
- ACCOUNT_WATCH=0 可关闭;测试/文档同步
This commit is contained in:
2026-10-19 13:13:31 +08:00
parent d399dbd979
commit 0a3920d97d
7 changed files with 156 additions and 15 deletions
+21
View File
@@ -193,6 +193,27 @@ db.session.expire_all()
check("换了号(打码名对不上)→ 更新成新探测值",
Device.query.get("A11:5555").cur_account_name, "周周苏***探访")
print("▶ ⑦ 手机手动切号:打码名按账号库还原完整昵称")
db.session.add(DeviceAccount(id="r11a", device_name="A11",
nickname="锋哥苏州百业探访", douyin_id="x1"))
db.session.commit()
ap.remember_name("A11:5555", "锋哥苏州百业探访")
check("唯一匹配 → 还原完整名",
ap.resolve_masked_name("A11:5555", "锋哥苏***探访"), "锋哥苏州百业探访")
check("对不上任何账号 → 返回空(不猜)",
ap.resolve_masked_name("A11:5555", "某某***某某"), "")
# 再加两个也能匹配同一打码名 → 用上次的完整名做 tiebreak
db.session.add_all([
DeviceAccount(id="r11b", device_name="A11", nickname="锋哥苏州甲探访", douyin_id="x2"),
DeviceAccount(id="r11c", device_name="A11", nickname="锋哥苏州乙探访", douyin_id="x3"),
])
db.session.commit()
check("多个匹配时用上次完整名 tiebreak",
ap.resolve_masked_name("A11:5555", "锋哥苏***探访"), "锋哥苏州百业探访")
row = Device.query.get("A11:5555"); row.cur_account_name = ""; db.session.commit()
check("分不清且没有历史 → 返回空",
ap.resolve_masked_name("A11:5555", "锋哥苏***探访"), "")
print()
if fails:
print("❌ 失败 %d 项:%s" % (len(fails), "、".join(fails)))