fix(qqmusic): 通知发送失败不再静默 + 新增通知诊断工具

现象:青龙日志里「自定义发送通知消息失败!!」,pushplus 只收到一行标题。

根因排查(三处,都已实测复现):
1) 脚本里 require('../sendNotify') 是 catch{} 静默吞掉 —— 容器缺 got 时
   一条通知都发不出去且日志无痕,只能靠猜。改成打印一行原因。
2) sendNotify 的 parseString 用 /(\w+):\s*((?:(?!\n\w+:).)*)/g 解析
   WEBHOOK_BODY,靠「换行 + \w+:」断值。单行 JSON 没有换行,整个 body
   被吞掉 —— 实测 '{"title":"$title",...}' 解析结果为 {}(0 个 key)。
   畸形 body → 对方返回非 200 → 正是「自定义发送通知消息失败」的来源。
3) webhookNotify 有三个前置条件,缺一个就静默 resolve(不发也不报错):
   URL/BODY 至少一个含 $title、WEBHOOK_METHOD 必须显式设、body 能被解析。

新增 _diag_notify.js(仓库根,与 sendNotify.js 同级):
- 查 sendNotify 能否加载、通知 env 是否读到(token 脱敏)
- 复刻 parseString,直接告出 WEBHOOK_BODY 会解析成什么
- 直连 pushplus 发 txt 与 html 两条,对比哪个模板正文完整
- 最后走一遍完整 sendNotify,与直连结果对照
用来区分「通道没发」和「微信侧展示折叠」两件事。

验证:node --check / 签名对拍 6 组 PASS / 加载失败时日志文案实测输出
/ _probe_meta 三元数据 PASS
This commit is contained in:
2026-11-05 08:54:26 +08:00
parent 2d29abb440
commit 483bc29424
3 changed files with 176 additions and 1 deletions

View File

@@ -861,7 +861,10 @@ async function main() {
+ `\n节目任务(20)依赖 App 内正常收听计入(播放上报未启用)`
+ `\n时间: ${new Date().toLocaleString('zh-CN', { timeZone: 'Asia/Shanghai' })}`
let sendNotifyFn = null
try { sendNotifyFn = require('../sendNotify').sendNotify } catch { /* 无 sendNotify 时仅控制台 */ }
try { sendNotifyFn = require('../sendNotify').sendNotify } catch (e) {
// 静默吞掉会让「通知没发出去」完全不可见 —— 必须留一行,否则只能靠猜
log(`[通知] sendNotify 不可用(${e.message.split('\n')[0]}),本轮不发推送`)
}
if (sendNotifyFn) {
try { await sendNotifyFn('QQ音乐签到', desp) } catch (e) { log(`[通知] 推送失败: ${e.message}`) }
}