fix(通知): 账号状态分类合并为一条消息

This commit is contained in:
2026-10-21 16:47:13 +08:00
parent abaf65737e
commit 7bc19e9eaa
7 changed files with 45 additions and 40 deletions
+18 -16
View File
@@ -1169,9 +1169,11 @@ def set_account_status(name, status=""):
def notify_account_status_summary(job_name="", source="计划运行"):
"""汇总账号库的「账号状态」并发通知(webhook 事件 `account.status.summary`)。
用户口径:**不做统计,按状态类型分别发送** —— 每个状态一条消息,
标题是「账号状态:作品异常」,正文列出这个类型的账号(昵称 + 设备)。
空状态(未设置)不单独发;没有可发的类型时不发。
用户口径:**不做统计;所有类型合到一个消息里,按类型分行列出账号**。
例如:
作品异常:A(A01)、B(A02)
账号安全待提升:C(A03)
空状态(未设置)不列;没有可发状态时不发。
"""
try:
with _ctx():
@@ -1192,20 +1194,20 @@ def notify_account_status_summary(job_name="", source="计划运行"):
return 2
return 1
from core import notifier
lines = []
for st in sorted(groups, key=_prio):
rs = groups[st]
accounts = "、".join(
"%s(%s)" % (r.get("nickname") or "?",
r.get("device_name") or "未登记")
for r in rs)
level = ("warning" if ("异常" in st or "待提升" in st)
else ("success" if "正常" in st else "info"))
notifier.notify(
"account.status.summary",
title="账号状态:%s" % st,
job_name=job_name or "全部账号", source=source,
status_type=st, accounts=accounts, level=level)
names = "、".join(
"%s(%s)" % (r.get("nickname") or "?",
r.get("device_name") or "未登记")
for r in groups[st])
lines.append("%s:%s" % (st, names))
from core import notifier
notifier.notify(
"account.status.summary",
job_name=job_name or "全部账号", source=source,
groups="\n> ".join(lines),
level=("warning" if any(("异常" in st or "待提升" in st)
for st in groups) else "success"))
return True
except Exception as e:
_log.warning(f"账号状态分类通知失败(不影响主流程): {e}")