fix(qdreader): separate account replies and verify adv tasks
This commit is contained in:
+36
-17
@@ -651,27 +651,38 @@ function doAdvTask(cookie) {
|
|||||||
var tasks = firstArray(nested(main, ["Data", "VideoRewardTab", "TaskList"]), nested(main, ["data", "VideoRewardTab", "TaskList"]), nested(main, ["Data", "TaskList"]), nested(main, ["data", "TaskList"]))
|
var tasks = firstArray(nested(main, ["Data", "VideoRewardTab", "TaskList"]), nested(main, ["data", "VideoRewardTab", "TaskList"]), nested(main, ["Data", "TaskList"]), nested(main, ["data", "TaskList"]))
|
||||||
if (!tasks.length) return { name: "激励任务", ok: true, msg: "无待完成任务", path: "/argus/api/v2/video/adv/mainPage" }
|
if (!tasks.length) return { name: "激励任务", ok: true, msg: "无待完成任务", path: "/argus/api/v2/video/adv/mainPage" }
|
||||||
if (taskFinished(tasks[tasks.length - 1])) return { name: "激励任务", ok: true, msg: "已完成", path: "/argus/api/v2/video/adv/mainPage" }
|
if (taskFinished(tasks[tasks.length - 1])) return { name: "激励任务", ok: true, msg: "已完成", path: "/argus/api/v2/video/adv/mainPage" }
|
||||||
var done = 0
|
var submittedIds = {}
|
||||||
var attempted = false
|
var submittedCount = 0
|
||||||
var blocked = 0
|
var skippedCount = 0
|
||||||
for (var i = 0; i < tasks.length; i++) {
|
for (var i = 0; i < tasks.length; i++) {
|
||||||
var t = tasks[i] || {}
|
var t = tasks[i] || {}
|
||||||
if (taskFinished(t)) continue
|
if (taskFinished(t)) continue
|
||||||
var tid = taskIdOf(t)
|
var tid = taskIdOf(t)
|
||||||
if (!tid) continue
|
if (!tid) continue
|
||||||
if (!advTaskActionable(t)) { blocked++; continue }
|
if (!advTaskActionable(t)) { skippedCount++; continue }
|
||||||
attempted = true
|
|
||||||
var fr = finishVideoTask(t, cookie)
|
var fr = finishVideoTask(t, cookie)
|
||||||
done += fr.ok
|
if (fr.taskId) { submittedIds[taskIdKey(fr.taskId)] = true; submittedCount += fr.ok }
|
||||||
if (fr.ok < fr.total) return { name: "激励任务", ok: false, msg: resultMsg(fr.last) || ("任务 " + tid + " 失败"), path: "/argus/api/v1/video/adv/finishWatch" }
|
if (fr.ok < fr.total) return { name: "激励任务", ok: false, msg: resultMsg(fr.last) || ("任务 " + tid + " 失败"), path: "/argus/api/v1/video/adv/finishWatch" }
|
||||||
}
|
}
|
||||||
var verify = qdGet("/argus/api/v2/video/adv/mainPage", {}, cookie)
|
var verify = qdGet("/argus/api/v2/video/adv/mainPage", {}, cookie)
|
||||||
var after = firstArray(nested(verify, ["Data", "VideoRewardTab", "TaskList"]), nested(verify, ["data", "VideoRewardTab", "TaskList"]), nested(verify, ["Data", "TaskList"]), nested(verify, ["data", "TaskList"]))
|
var after = firstArray(nested(verify, ["Data", "VideoRewardTab", "TaskList"]), nested(verify, ["data", "VideoRewardTab", "TaskList"]), nested(verify, ["Data", "TaskList"]), nested(verify, ["data", "TaskList"]))
|
||||||
|
var unfinishedSubmitted = 0
|
||||||
var actionableLeft = 0
|
var actionableLeft = 0
|
||||||
for (var v = 0; v < after.length; v++) if (!taskFinished(after[v]) && taskIdOf(after[v]) && advTaskActionable(after[v])) actionableLeft++
|
for (var v = 0; v < after.length; v++) {
|
||||||
var finished = actionableLeft === 0
|
var at = after[v]
|
||||||
var suffix = blocked ? (",跳过 " + blocked + " 个需其它入口任务") : ""
|
var aid = taskIdKey(taskIdOf(at))
|
||||||
return { name: "激励任务", ok: finished, msg: finished ? (attempted ? ("已完成" + suffix) : ("无待完成任务" + suffix)) : (done ? ("已提交 " + done + " 个视频任务,仍有 " + actionableLeft + " 个未完成" + suffix) : ("仍有 " + actionableLeft + " 个未完成" + suffix)), path: "/argus/api/v2/video/adv/mainPage" }
|
if (!aid) continue
|
||||||
|
if (submittedIds[aid]) {
|
||||||
|
if (!taskFinished(at)) unfinishedSubmitted++
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (!taskFinished(at) && advTaskActionable(at)) actionableLeft++
|
||||||
|
}
|
||||||
|
var submittedKeys = Object.keys(submittedIds)
|
||||||
|
var finished = submittedKeys.length ? unfinishedSubmitted === 0 : actionableLeft === 0
|
||||||
|
var suffix = skippedCount ? (",跳过 " + skippedCount + " 个需其它入口任务") : ""
|
||||||
|
var left = submittedKeys.length ? unfinishedSubmitted : actionableLeft
|
||||||
|
return { name: "激励任务", ok: finished, msg: finished ? (submittedKeys.length ? ("已完成" + suffix) : ("无待完成任务" + suffix)) : (submittedCount ? ("已提交 " + submittedCount + " 个视频任务,仍有 " + left + " 个未完成" + suffix) : ("仍有 " + left + " 个未完成" + suffix)), path: "/argus/api/v2/video/adv/mainPage" }
|
||||||
}
|
}
|
||||||
function doDailyTask(cookie) {
|
function doDailyTask(cookie) {
|
||||||
var list = qdGet("/argus/api/v3/checkin/packagelist", {}, cookie)
|
var list = qdGet("/argus/api/v3/checkin/packagelist", {}, cookie)
|
||||||
@@ -864,32 +875,40 @@ function signAll(targetUid, allUsers, source, archiveAfterRun) {
|
|||||||
var okCount = 0
|
var okCount = 0
|
||||||
var failCount = 0
|
var failCount = 0
|
||||||
var items = []
|
var items = []
|
||||||
var lines = ["启点读书签到结果:"]
|
var accountReplies = []
|
||||||
for (var i = 0; i < uids.length; i++) {
|
for (var i = 0; i < uids.length; i++) {
|
||||||
var uid = uids[i]
|
var uid = uids[i]
|
||||||
|
var prefix = "启点读书签到结果:\n"
|
||||||
|
var suffix = ""
|
||||||
|
if (remarks[uid]) suffix = "(" + remarks[uid] + ")"
|
||||||
try {
|
try {
|
||||||
var r = doCheckin(uid, store[uid], source, runId)
|
var r = doCheckin(uid, store[uid], source, runId)
|
||||||
if (r.ok) okCount++; else failCount++
|
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] || "" })
|
items.push({ uid: String(uid), ok: !!r.ok, msg: String(r.msg || ""), time: r.log.time, remark: remarks[uid] || "" })
|
||||||
lines.push((r.ok ? "✅ " : "❌ ") + maskUid(uid) + (remarks[uid] ? "(" + remarks[uid] + ")" : "") + ":" + r.msg)
|
accountReplies.push(prefix + (r.ok ? "✅ " : "❌ ") + maskUid(uid) + suffix + ":" + r.msg)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
failCount++
|
failCount++
|
||||||
var emsg = e && e.message ? e.message : String(e)
|
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] || "" }
|
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)
|
setLastResult(uid, er)
|
||||||
items.push(er)
|
items.push(er)
|
||||||
lines.push("❌ " + maskUid(uid) + (remarks[uid] ? "(" + remarks[uid] + ")" : "") + ":" + emsg)
|
accountReplies.push(prefix + "❌ " + maskUid(uid) + suffix + ":" + emsg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var finishedAt = nowIso()
|
var finishedAt = nowIso()
|
||||||
setLastRunLog({ runId: runId, source: source, startedAt: startedAt, finishedAt: finishedAt, targetUid: targetUid || "", allUsers: !!allUsers, total: uids.length, okCount: okCount, failCount: failCount, items: items })
|
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)
|
var tail = []
|
||||||
lines.push("记录时间:" + finishedAt + "(" + sourceName(source) + ")")
|
tail.push("汇总:成功 " + okCount + " / 失败 " + failCount + " / 总计 " + uids.length)
|
||||||
|
tail.push("记录时间:" + finishedAt + "(" + sourceName(source) + ")")
|
||||||
if (archiveAfterRun) {
|
if (archiveAfterRun) {
|
||||||
var ar = archiveRunLog(source + "-after-sign")
|
var ar = archiveRunLog(source + "-after-sign")
|
||||||
if (ar && ar.archived) lines.push("日志已归档:" + ar.key)
|
if (ar && ar.archived) tail.push("日志已归档:" + ar.key)
|
||||||
}
|
}
|
||||||
return lines.join("\n")
|
if (accountReplies.length > 1) {
|
||||||
|
for (var ai = 0; ai < accountReplies.length; ai++) reply(accountReplies[ai])
|
||||||
|
return tail.join("\n")
|
||||||
|
}
|
||||||
|
return accountReplies[0] + "\n" + tail.join("\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
function shortTime(iso) {
|
function shortTime(iso) {
|
||||||
|
|||||||
@@ -651,27 +651,38 @@ function doAdvTask(cookie) {
|
|||||||
var tasks = firstArray(nested(main, ["Data", "VideoRewardTab", "TaskList"]), nested(main, ["data", "VideoRewardTab", "TaskList"]), nested(main, ["Data", "TaskList"]), nested(main, ["data", "TaskList"]))
|
var tasks = firstArray(nested(main, ["Data", "VideoRewardTab", "TaskList"]), nested(main, ["data", "VideoRewardTab", "TaskList"]), nested(main, ["Data", "TaskList"]), nested(main, ["data", "TaskList"]))
|
||||||
if (!tasks.length) return { name: "激励任务", ok: true, msg: "无待完成任务", path: "/argus/api/v2/video/adv/mainPage" }
|
if (!tasks.length) return { name: "激励任务", ok: true, msg: "无待完成任务", path: "/argus/api/v2/video/adv/mainPage" }
|
||||||
if (taskFinished(tasks[tasks.length - 1])) return { name: "激励任务", ok: true, msg: "已完成", path: "/argus/api/v2/video/adv/mainPage" }
|
if (taskFinished(tasks[tasks.length - 1])) return { name: "激励任务", ok: true, msg: "已完成", path: "/argus/api/v2/video/adv/mainPage" }
|
||||||
var done = 0
|
var submittedIds = {}
|
||||||
var attempted = false
|
var submittedCount = 0
|
||||||
var blocked = 0
|
var skippedCount = 0
|
||||||
for (var i = 0; i < tasks.length; i++) {
|
for (var i = 0; i < tasks.length; i++) {
|
||||||
var t = tasks[i] || {}
|
var t = tasks[i] || {}
|
||||||
if (taskFinished(t)) continue
|
if (taskFinished(t)) continue
|
||||||
var tid = taskIdOf(t)
|
var tid = taskIdOf(t)
|
||||||
if (!tid) continue
|
if (!tid) continue
|
||||||
if (!advTaskActionable(t)) { blocked++; continue }
|
if (!advTaskActionable(t)) { skippedCount++; continue }
|
||||||
attempted = true
|
|
||||||
var fr = finishVideoTask(t, cookie)
|
var fr = finishVideoTask(t, cookie)
|
||||||
done += fr.ok
|
if (fr.taskId) { submittedIds[taskIdKey(fr.taskId)] = true; submittedCount += fr.ok }
|
||||||
if (fr.ok < fr.total) return { name: "激励任务", ok: false, msg: resultMsg(fr.last) || ("任务 " + tid + " 失败"), path: "/argus/api/v1/video/adv/finishWatch" }
|
if (fr.ok < fr.total) return { name: "激励任务", ok: false, msg: resultMsg(fr.last) || ("任务 " + tid + " 失败"), path: "/argus/api/v1/video/adv/finishWatch" }
|
||||||
}
|
}
|
||||||
var verify = qdGet("/argus/api/v2/video/adv/mainPage", {}, cookie)
|
var verify = qdGet("/argus/api/v2/video/adv/mainPage", {}, cookie)
|
||||||
var after = firstArray(nested(verify, ["Data", "VideoRewardTab", "TaskList"]), nested(verify, ["data", "VideoRewardTab", "TaskList"]), nested(verify, ["Data", "TaskList"]), nested(verify, ["data", "TaskList"]))
|
var after = firstArray(nested(verify, ["Data", "VideoRewardTab", "TaskList"]), nested(verify, ["data", "VideoRewardTab", "TaskList"]), nested(verify, ["Data", "TaskList"]), nested(verify, ["data", "TaskList"]))
|
||||||
|
var unfinishedSubmitted = 0
|
||||||
var actionableLeft = 0
|
var actionableLeft = 0
|
||||||
for (var v = 0; v < after.length; v++) if (!taskFinished(after[v]) && taskIdOf(after[v]) && advTaskActionable(after[v])) actionableLeft++
|
for (var v = 0; v < after.length; v++) {
|
||||||
var finished = actionableLeft === 0
|
var at = after[v]
|
||||||
var suffix = blocked ? (",跳过 " + blocked + " 个需其它入口任务") : ""
|
var aid = taskIdKey(taskIdOf(at))
|
||||||
return { name: "激励任务", ok: finished, msg: finished ? (attempted ? ("已完成" + suffix) : ("无待完成任务" + suffix)) : (done ? ("已提交 " + done + " 个视频任务,仍有 " + actionableLeft + " 个未完成" + suffix) : ("仍有 " + actionableLeft + " 个未完成" + suffix)), path: "/argus/api/v2/video/adv/mainPage" }
|
if (!aid) continue
|
||||||
|
if (submittedIds[aid]) {
|
||||||
|
if (!taskFinished(at)) unfinishedSubmitted++
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (!taskFinished(at) && advTaskActionable(at)) actionableLeft++
|
||||||
|
}
|
||||||
|
var submittedKeys = Object.keys(submittedIds)
|
||||||
|
var finished = submittedKeys.length ? unfinishedSubmitted === 0 : actionableLeft === 0
|
||||||
|
var suffix = skippedCount ? (",跳过 " + skippedCount + " 个需其它入口任务") : ""
|
||||||
|
var left = submittedKeys.length ? unfinishedSubmitted : actionableLeft
|
||||||
|
return { name: "激励任务", ok: finished, msg: finished ? (submittedKeys.length ? ("已完成" + suffix) : ("无待完成任务" + suffix)) : (submittedCount ? ("已提交 " + submittedCount + " 个视频任务,仍有 " + left + " 个未完成" + suffix) : ("仍有 " + left + " 个未完成" + suffix)), path: "/argus/api/v2/video/adv/mainPage" }
|
||||||
}
|
}
|
||||||
function doDailyTask(cookie) {
|
function doDailyTask(cookie) {
|
||||||
var list = qdGet("/argus/api/v3/checkin/packagelist", {}, cookie)
|
var list = qdGet("/argus/api/v3/checkin/packagelist", {}, cookie)
|
||||||
@@ -864,32 +875,40 @@ function signAll(targetUid, allUsers, source, archiveAfterRun) {
|
|||||||
var okCount = 0
|
var okCount = 0
|
||||||
var failCount = 0
|
var failCount = 0
|
||||||
var items = []
|
var items = []
|
||||||
var lines = ["启点读书签到结果:"]
|
var accountReplies = []
|
||||||
for (var i = 0; i < uids.length; i++) {
|
for (var i = 0; i < uids.length; i++) {
|
||||||
var uid = uids[i]
|
var uid = uids[i]
|
||||||
|
var prefix = "启点读书签到结果:\n"
|
||||||
|
var suffix = ""
|
||||||
|
if (remarks[uid]) suffix = "(" + remarks[uid] + ")"
|
||||||
try {
|
try {
|
||||||
var r = doCheckin(uid, store[uid], source, runId)
|
var r = doCheckin(uid, store[uid], source, runId)
|
||||||
if (r.ok) okCount++; else failCount++
|
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] || "" })
|
items.push({ uid: String(uid), ok: !!r.ok, msg: String(r.msg || ""), time: r.log.time, remark: remarks[uid] || "" })
|
||||||
lines.push((r.ok ? "✅ " : "❌ ") + maskUid(uid) + (remarks[uid] ? "(" + remarks[uid] + ")" : "") + ":" + r.msg)
|
accountReplies.push(prefix + (r.ok ? "✅ " : "❌ ") + maskUid(uid) + suffix + ":" + r.msg)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
failCount++
|
failCount++
|
||||||
var emsg = e && e.message ? e.message : String(e)
|
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] || "" }
|
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)
|
setLastResult(uid, er)
|
||||||
items.push(er)
|
items.push(er)
|
||||||
lines.push("❌ " + maskUid(uid) + (remarks[uid] ? "(" + remarks[uid] + ")" : "") + ":" + emsg)
|
accountReplies.push(prefix + "❌ " + maskUid(uid) + suffix + ":" + emsg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var finishedAt = nowIso()
|
var finishedAt = nowIso()
|
||||||
setLastRunLog({ runId: runId, source: source, startedAt: startedAt, finishedAt: finishedAt, targetUid: targetUid || "", allUsers: !!allUsers, total: uids.length, okCount: okCount, failCount: failCount, items: items })
|
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)
|
var tail = []
|
||||||
lines.push("记录时间:" + finishedAt + "(" + sourceName(source) + ")")
|
tail.push("汇总:成功 " + okCount + " / 失败 " + failCount + " / 总计 " + uids.length)
|
||||||
|
tail.push("记录时间:" + finishedAt + "(" + sourceName(source) + ")")
|
||||||
if (archiveAfterRun) {
|
if (archiveAfterRun) {
|
||||||
var ar = archiveRunLog(source + "-after-sign")
|
var ar = archiveRunLog(source + "-after-sign")
|
||||||
if (ar && ar.archived) lines.push("日志已归档:" + ar.key)
|
if (ar && ar.archived) tail.push("日志已归档:" + ar.key)
|
||||||
}
|
}
|
||||||
return lines.join("\n")
|
if (accountReplies.length > 1) {
|
||||||
|
for (var ai = 0; ai < accountReplies.length; ai++) reply(accountReplies[ai])
|
||||||
|
return tail.join("\n")
|
||||||
|
}
|
||||||
|
return accountReplies[0] + "\n" + tail.join("\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
function shortTime(iso) {
|
function shortTime(iso) {
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ function runPlugin({ pluginCode = code, filename = pluginPath, content = '', sto
|
|||||||
let listenIndex = 0;
|
let listenIndex = 0;
|
||||||
const baseSender = {
|
const baseSender = {
|
||||||
reply: (msg) => replies.push(String(msg)),
|
reply: (msg) => replies.push(String(msg)),
|
||||||
|
push: (msg) => replies.push(typeof msg === 'string' ? msg : String((msg && (msg.content || msg.message || msg.text)) || JSON.stringify(msg))),
|
||||||
|
sendText: (msg) => replies.push(String(msg)),
|
||||||
getMessage: () => content,
|
getMessage: () => content,
|
||||||
getContent: () => content,
|
getContent: () => content,
|
||||||
isAdmin: () => admin,
|
isAdmin: () => admin,
|
||||||
@@ -35,6 +37,8 @@ function runPlugin({ pluginCode = code, filename = pluginPath, content = '', sto
|
|||||||
console,
|
console,
|
||||||
Buffer,
|
Buffer,
|
||||||
sender: { ...baseSender, ...senderOverrides },
|
sender: { ...baseSender, ...senderOverrides },
|
||||||
|
sendText: (msg) => replies.push(String(msg)),
|
||||||
|
push: (msg) => replies.push(typeof msg === 'string' ? msg : String((msg && (msg.content || msg.message || msg.text)) || JSON.stringify(msg))),
|
||||||
GetUserID: () => userId,
|
GetUserID: () => userId,
|
||||||
GetContent: () => content,
|
GetContent: () => content,
|
||||||
getContent: () => content,
|
getContent: () => content,
|
||||||
@@ -618,6 +622,24 @@ test('delete all command clears only current user saved cookies', () => {
|
|||||||
assert.deepEqual(JSON.parse(r.store.qdreader_remark_json), { '67890': '副号' });
|
assert.deepEqual(JSON.parse(r.store.qdreader_remark_json), { '67890': '副号' });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('manual sign replies per account first and summary separately for multi-account runs', () => {
|
||||||
|
const store = {
|
||||||
|
qdreader_cookie_json: JSON.stringify({ '12345': cookie, '67890': cookie.replace(/12345/g, '67890') }),
|
||||||
|
qdreader_user_bind_json: JSON.stringify({ '12345': 'user-a', '67890': 'user-a' }),
|
||||||
|
qdreader_remark_json: JSON.stringify({ '12345': '主号', '67890': '副号' }),
|
||||||
|
};
|
||||||
|
const r = runPlugin({ content: '启点签到', store, userId: 'user-a' });
|
||||||
|
assert.equal(r.replies.length, 3);
|
||||||
|
assert.match(r.replies[0], /12\*\*\*45(主号)/);
|
||||||
|
assert.match(r.replies[0], /完全体任务完成/);
|
||||||
|
assert.doesNotMatch(r.replies[0], /67\*\*\*90/);
|
||||||
|
assert.match(r.replies[1], /67\*\*\*90(副号)/);
|
||||||
|
assert.match(r.replies[1], /完全体任务完成/);
|
||||||
|
assert.doesNotMatch(r.replies[1], /12\*\*\*45/);
|
||||||
|
assert.match(r.replies[2], /汇总:成功 2 \/ 失败 0 \/ 总计 2/);
|
||||||
|
assert.match(r.replies[2], /日志已归档/);
|
||||||
|
});
|
||||||
|
|
||||||
test('manual sign only runs current user accounts while cron runs all accounts', () => {
|
test('manual sign only runs current user accounts while cron runs all accounts', () => {
|
||||||
const store = {
|
const store = {
|
||||||
qdreader_cookie_json: JSON.stringify({ '12345': cookie, '67890': cookie.replace(/12345/g, '67890') }),
|
qdreader_cookie_json: JSON.stringify({ '12345': cookie, '67890': cookie.replace(/12345/g, '67890') }),
|
||||||
@@ -628,7 +650,8 @@ test('manual sign only runs current user accounts while cron runs all accounts',
|
|||||||
assert.match(manual.replies[0], /总计 1/);
|
assert.match(manual.replies[0], /总计 1/);
|
||||||
const cron = runPlugin({ content: '', store: { ...store }, userId: 'cron', globals: { Date: fixedDateClass('2026-05-19T07:01:00.000+08:00') } });
|
const cron = runPlugin({ content: '', store: { ...store }, userId: 'cron', globals: { Date: fixedDateClass('2026-05-19T07:01:00.000+08:00') } });
|
||||||
assert.equal(cron.calls.length, 8);
|
assert.equal(cron.calls.length, 8);
|
||||||
assert.match(cron.replies[0], /总计 2/);
|
assert.equal(cron.replies.length, 3);
|
||||||
|
assert.match(cron.replies[2], /总计 2/);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('unbound global cookies are not visible or usable by normal users', () => {
|
test('unbound global cookies are not visible or usable by normal users', () => {
|
||||||
@@ -842,6 +865,44 @@ test('adv task does not report success when only unrelated task is finished afte
|
|||||||
assert.match(r.replies[0], /汇总:成功 0 \/ 失败 1 \/ 总计 1/);
|
assert.match(r.replies[0], /汇总:成功 0 \/ 失败 1 \/ 总计 1/);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('adv task reports failure when submitted target ids remain unfinished even if unrelated actionable task exists', () => {
|
||||||
|
const store = {
|
||||||
|
qdreader_cookie_json: JSON.stringify({ '12345': cookie }),
|
||||||
|
qdreader_user_bind_json: JSON.stringify({ '12345': 'user-a' }),
|
||||||
|
qdreader_task_pref_json: JSON.stringify({ '12345': { adv: true } }),
|
||||||
|
};
|
||||||
|
const r = runPlugin({
|
||||||
|
content: '启点签到',
|
||||||
|
store,
|
||||||
|
userId: 'user-a',
|
||||||
|
requests: [
|
||||||
|
{ body: { code: 0, data: { headers: { 'QD-Sign': 'sig' } } } },
|
||||||
|
{ statusCode: 200, body: { code: 1, msg: '今日已签到' } },
|
||||||
|
{ body: { code: 0, data: { headers: { 'QD-Sign': 'sig' } } } },
|
||||||
|
{ statusCode: 200, body: { code: 1, msg: '无可领取礼包' } },
|
||||||
|
{ body: { code: 0, data: { headers: { 'QD-Sign': 'sig' } } } },
|
||||||
|
{ statusCode: 200, body: { code: 0, Data: { VideoRewardTab: { TaskList: [
|
||||||
|
{ TaskId: 'target-a', Title: '看视频领福利A', IsFinished: 0 },
|
||||||
|
{ TaskId: 'target-b', Title: '看视频领福利B', IsFinished: 0 },
|
||||||
|
{ TaskId: '1165585369246138370', Title: '每日签到', IsFinished: 0 },
|
||||||
|
] } } } },
|
||||||
|
{ body: { code: 0, data: { headers: { 'QD-Sign': 'sig' } } } },
|
||||||
|
{ statusCode: 200, body: { result: 9, message: '' } },
|
||||||
|
{ body: { code: 0, data: { headers: { 'QD-Sign': 'sig' } } } },
|
||||||
|
{ statusCode: 200, body: { result: 9, message: '' } },
|
||||||
|
{ body: { code: 0, data: { headers: { 'QD-Sign': 'sig' } } } },
|
||||||
|
{ statusCode: 200, body: { code: 0, Data: { VideoRewardTab: { TaskList: [
|
||||||
|
{ TaskId: 'target-a', Title: '看视频领福利A', IsFinished: 0 },
|
||||||
|
{ TaskId: 'target-b', Title: '看视频领福利B', IsFinished: 0 },
|
||||||
|
{ TaskId: 'unrelated-actionable', Title: '其它视频福利', IsFinished: 1 },
|
||||||
|
{ TaskId: '1165585369246138370', Title: '每日签到', IsFinished: 0 },
|
||||||
|
] } } } },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
assert.match(r.replies[0], /激励任务❌\(已提交 2 个视频任务,仍有 2 个未完成,跳过 1 个需其它入口任务\)/);
|
||||||
|
assert.match(r.replies[0], /汇总:成功 0 \/ 失败 1 \/ 总计 1/);
|
||||||
|
});
|
||||||
|
|
||||||
test('adv task skips non-ad entries that must be handled by their own modules', () => {
|
test('adv task skips non-ad entries that must be handled by their own modules', () => {
|
||||||
const store = {
|
const store = {
|
||||||
qdreader_cookie_json: JSON.stringify({ '12345': cookie }),
|
qdreader_cookie_json: JSON.stringify({ '12345': cookie }),
|
||||||
|
|||||||
Reference in New Issue
Block a user