fix(qdreader): archive immediately after sign

This commit is contained in:
2026-05-20 12:21:54 +08:00
parent d09073c33c
commit 74a8e45405
5 changed files with 69 additions and 99 deletions
+12 -10
View File
@@ -4,17 +4,17 @@
//[author: Hermes]
//[service: BOSS]
//[class: 工具类]
//[version: 2.5.5]
//[version: 2.5.7]
//[platform: web,qq,wx,tg,tb,fs,we]
//[public: false]
//[price: 0]
//[disable: false]
//[description: 启点读书(QDReader) Autman 签到插件:保存 QX 抓到的 H5 Cookie,支持手动“启点签到”;定时使用 `1 0,7 * * *`每日 00:01 归档并清空日志、每日 07:01 签到;带独立 bucket、多用户隔离、请求重试、签名响应解析、结果摘要和安全脱敏。]
//[description: 启点读书(QDReader) Autman 签到插件:保存 QX 抓到的 H5 Cookie,支持手动“启点签到”;定时使用 `1 7 * * *` 每日 07:01 签到;每次签到运行结束后立即归档并清空最近运行日志,不再依赖单独归档定时;带独立 bucket、多用户隔离、请求重试、签名响应解析、结果摘要和安全脱敏。]
//[rule: ^启点(账号|查询|ck|CK|cookie|Cookie|签到|读书|归档|日志归档)(.*)$]
//[rule: ^qdreader(.*)$]
//[admin: true]
//[priority: 600]
//[cron: 1 0,7 * * *]
//[cron: 1 7 * * *]
var BUCKET = "hermes_qidian"
@@ -260,7 +260,7 @@ function contentText() {
}
function usage() {
return [
"启点读书签到插件 v2.5.5",
"启点读书签到插件 v2.5.7",
"【一级菜单】",
"账号管理:启点账号",
"执行查询:启点查询",
@@ -452,11 +452,7 @@ function latestArchiveForVisible(uids) {
return null
}
function cronMode() {
var d = new Date()
var h = d.getHours ? d.getHours() : 7
// Single cron: 1 0,7 * * *
// 00:01 system run archives only; 07:01 system run signs only.
if (h === 0) return "archive"
// Cron only runs the signing branch. Archive is performed immediately after each sign run.
return "sign"
}
function formatArchiveReply(ret) {
@@ -484,8 +480,9 @@ function doCheckin(uid, cookie, source, runId) {
setLastResult(uid, result)
return { uid: uid, ok: ok, msg: msg, raw: res, log: result }
}
function signAll(targetUid, allUsers, source) {
function signAll(targetUid, allUsers, source, archiveAfterRun) {
source = source || (allUsers ? "cron" : "manual")
if (archiveAfterRun === undefined) archiveAfterRun = true
var startedAt = nowIso()
var runId = startedAt.replace(/[-:.TZ]/g, "").slice(0, 14) + "_" + source
var store = getStore()
@@ -496,6 +493,7 @@ function signAll(targetUid, allUsers, source) {
if (!uids.length) {
var emptyMsg = targetUid ? ("未找到 uid: " + targetUid) : "还没有保存启点读书CK"
setLastRunLog({ runId: runId, source: source, startedAt: startedAt, finishedAt: nowIso(), targetUid: targetUid || "", total: 0, okCount: 0, failCount: 0, message: emptyMsg, items: [] })
if (archiveAfterRun) archiveRunLog(source + "-after-sign")
return emptyMsg
}
var okCount = 0
@@ -522,6 +520,10 @@ function signAll(targetUid, allUsers, source) {
setLastRunLog({ runId: runId, source: source, startedAt: startedAt, finishedAt: finishedAt, targetUid: targetUid || "", allUsers: !!allUsers, total: uids.length, okCount: okCount, failCount: failCount, items: items })
lines.push("汇总:成功 " + okCount + " / 失败 " + failCount + " / 总计 " + uids.length)
lines.push("记录时间:" + finishedAt + "" + sourceName(source) + "")
if (archiveAfterRun) {
var ar = archiveRunLog(source + "-after-sign")
if (ar && ar.archived) lines.push("日志已归档:" + ar.key)
}
return lines.join("\n")
}