fix: push qdreader cron results to account owners

This commit is contained in:
2026-05-23 13:54:33 +08:00
parent 7388cf8eb5
commit e03ad733f4
3 changed files with 90 additions and 17 deletions
+35 -5
View File
@@ -4,7 +4,7 @@
//[author: Hermes]
//[service: BOSS]
//[class: 工具类]
// [version: 2.15.2]
// [version: 2.15.3]
// [platform: web,qq,wx,tg,tb,fs,we]
// [public: false]
// [price: 0]
@@ -91,6 +91,22 @@ function reply(msg) {
try { if (typeof push === "function") { push({ content: out }); return } } catch (e) {}
try { console.log(out) } catch (e) {}
}
function pushToUser(userId, content) {
userId = trim(userId || "")
content = typeof content === "string" ? content : JSON.stringify(content)
if (!userId || !content) return false
if (typeof push !== "function") return false
var payloads = [
{ imType: "wx", userID: userId, content: content },
{ imType: "we", userID: userId, content: content },
{ imType: "web", userID: userId, content: content },
{ userID: userId, content: content }
]
for (var i = 0; i < payloads.length; i++) {
try { push(payloads[i]); return true } catch (e) {}
}
return false
}
function debug(msg) { try { if (typeof Debug === "function") Debug(String(msg)); else console.log(String(msg)) } catch (e) {} }
function cleanStringMap(obj) {
@@ -286,7 +302,7 @@ function contentText() {
}
function usage() {
return [
"启点读书签到插件 v2.15.2",
"启点读书签到插件 v2.15.3",
"【一级菜单】",
"账号管理:启点账号",
"执行查询:启点查询",
@@ -874,6 +890,7 @@ function signAll(targetUid, allUsers, source, archiveAfterRun) {
var failCount = 0
var items = []
var accountReplies = []
var accountNotices = []
for (var i = 0; i < uids.length; i++) {
var uid = uids[i]
var prefix = "启点读书签到结果:\n"
@@ -883,14 +900,18 @@ function signAll(targetUid, allUsers, source, archiveAfterRun) {
var r = doCheckin(uid, store[uid], source, runId)
if (r.ok) okCount++; else failCount++
items.push({ uid: String(uid), ok: !!r.ok, msg: String(r.msg || ""), time: r.log.time, remark: remarks[uid] || "" })
accountReplies.push(prefix + (r.ok ? "✅ " : "❌ ") + maskUid(uid) + suffix + "" + r.msg)
var msg = prefix + (r.ok ? "✅ " : "❌ ") + maskUid(uid) + suffix + "" + r.msg
accountReplies.push(msg)
accountNotices.push({ uid: String(uid), owner: bind[String(uid)] || "", msg: msg })
} catch (e) {
failCount++
var emsg = e && e.message ? e.message : String(e)
var er = { uid: String(uid), ok: false, msg: emsg, time: nowIso(), startedAt: startedAt, source: source, runId: runId, error: true, remark: remarks[uid] || "" }
setLastResult(uid, er)
items.push(er)
accountReplies.push(prefix + "❌ " + maskUid(uid) + suffix + "" + emsg)
var errMsg = prefix + "❌ " + maskUid(uid) + suffix + "" + emsg
accountReplies.push(errMsg)
accountNotices.push({ uid: String(uid), owner: bind[String(uid)] || "", msg: errMsg })
}
}
var finishedAt = nowIso()
@@ -898,9 +919,18 @@ function signAll(targetUid, allUsers, source, archiveAfterRun) {
var tail = []
tail.push("汇总:成功 " + okCount + " / 失败 " + failCount + " / 总计 " + uids.length)
tail.push("记录时间:" + finishedAt + "" + sourceName(source) + "")
var archiveLine = ""
if (archiveAfterRun) {
var ar = archiveRunLog(source + "-after-sign")
if (ar && ar.archived) tail.push("日志已归档:" + ar.key)
if (ar && ar.archived) { archiveLine = "日志已归档:" + ar.key; tail.push(archiveLine) }
}
if (allUsers && source === "cron") {
for (var pi = 0; pi < accountNotices.length; pi++) {
var notice = accountNotices[pi]
var body = notice.msg + "\n" + tail.join("\n")
if (!pushToUser(notice.owner, body)) debug("QDReader cron push skipped for uid " + notice.uid + ": empty owner or push unavailable")
}
return tail.join("\n")
}
if (accountReplies.length > 1) {
for (var ai = 0; ai < accountReplies.length; ai++) reply(accountReplies[ai])