fix qdreader message window and nested result

This commit is contained in:
2026-05-20 22:26:49 +08:00
parent c850f2bbbe
commit e035a760de
5 changed files with 96 additions and 7 deletions
+1
View File
@@ -650,5 +650,6 @@ QDReader 签到结果判定补充:
- 激励任务 `finishWatch` 可能返回 `result=9``Result=9`,上游将其视为可继续/已受理,再回查 `mainPage` 判断任务是否完成;插件不能把大小写不同的 `result=9` 直接计为失败。
- 每日任务不是简单取任务列表第一个。上游会先处理 `packagelist` 里的惊喜/前置任务,再从任务列表按标题定位“每日任务”,执行多次 `finishWatch` 后回查完成状态。
- 大咖荐书不是一次 `pullmessage` 即结束。消息 token 需要由 `UserId` 经过 `(uid * 4 & 0x7ffffffffffffffc) ^ 0x113a4f` 后转 base62;流程是:拉会话列表 → 对红点会话带 `senderId` 拉消息 → 从最近消息提取 `orderId``getrewarddetail` → 根据奖励类型走 `rewardcallback``addbookshelf`。如果直接用十进制 token 或缺少 `senderId`,容易返回“参数错误”。
- 大咖荐书应限制在北京时间 `20:00-22:00` 窗口执行;窗口外要标记为跳过并避免调用消息接口,否则晚间窗口后容易返回“参数错误”并污染整账号结果。
- “无可领取礼包/今日已签到”属于幂等成功类提示;这类提示不应让整个账号汇总失败。
- 每次修复这类链路必须补 VM 回归测试:请求路径、签名 payload 里的参数、特殊返回码分类、最终账号成功/失败汇总。
+17 -3
View File
@@ -4,7 +4,7 @@
//[author: Hermes]
//[service: BOSS]
//[class: 工具类]
//[version: 2.10.1]
//[version: 2.10.2]
//[platform: web,qq,wx,tg,tb,fs,we]
//[public: false]
//[price: 0]
@@ -276,7 +276,7 @@ function contentText() {
}
function usage() {
return [
"启点读书签到插件 v2.10.1",
"启点读书签到插件 v2.10.2",
"【一级菜单】",
"账号管理:启点账号",
"执行查询:启点查询",
@@ -404,7 +404,14 @@ function qidianRequest(path, method, data, cookie) {
if (typeof out === "string") out = safeJsonParse(out, out)
return out
}
function resultCode(obj) { return obj && (obj.Result !== undefined ? obj.Result : obj.result !== undefined ? obj.result : obj.Code !== undefined ? obj.Code : obj.code !== undefined ? obj.code : obj.retcode) }
function resultCode(obj) {
if (!obj) return undefined
var keys = ["Result", "result", "Code", "code", "retcode", "RetCode"]
for (var i = 0; i < keys.length; i++) if (obj[keys[i]] !== undefined) return obj[keys[i]]
var data = obj.Data || obj.data || obj.ResultData || obj.resultData
if (data && typeof data === "object") for (var j = 0; j < keys.length; j++) if (data[keys[j]] !== undefined) return data[keys[j]]
return undefined
}
function resultOk(obj) {
var code = resultCode(obj)
var status = obj && (obj.status || obj.Status)
@@ -695,11 +702,18 @@ function recentCreateTime(v) {
var now = (new Date()).getTime()
return now - t >= 0 && now - t <= 24 * 60 * 60 * 1000
}
function beijingHour(dateLike) { return beijingDate(dateLike).getUTCHours() }
function messageBoxWindowLabel() { return "20:00-22:00" }
function messageBoxAllowedNow() {
var h = beijingHour()
return h >= 20 && h < 22
}
function orderIdFromText(s) {
var m = String(s || "").match(/orderId=([a-f0-9]+)/i)
return m ? m[1] : ""
}
function doMessageBox(cookie) {
if (!messageBoxAllowedNow()) return { name: "大咖荐书", ok: true, skipped: true, msg: "不在执行时间 " + messageBoxWindowLabel() + ",已跳过", path: "https://magev6.if.qidian.com/argus/api/v2/message/pullmessage" }
var token = messageTokenFromCookie(cookie)
if (!token) return { name: "大咖荐书", ok: true, msg: "缺少消息 token,已跳过", path: "https://magev6.if.qidian.com/argus/api/v2/message/pullmessage" }
var baseParams = { token: token, type: "0", pg: "1", pz: "10" }
+6
View File
@@ -198,3 +198,9 @@ node tests/qdreader_plugin.test.mjs
- `finishWatch` 的上游/签名网关响应可能使用小写 `result=9`,现在和 `Result=9` 一样按“已受理,需回查”处理,避免激励任务误报 `任务 ... 失败`
- 大咖荐书继续使用上游 base62 token,不再回退十进制 token;若线上仍返回“参数错误”,优先确认 Autman 已重新导入本版本,而不是旧版只请求一次 `pullmessage`
## v2.10.2 现场失败修正
- `finishWatch` 兼容响应码嵌在 `data/Data.result` 的网关包装形态,避免空 message 时继续误报具体任务失败。
- 大咖荐书恢复执行时间窗口限制:仅北京时间 20:00-22:00 执行,其他时间标记为跳过,不再调用消息接口导致“参数错误”。
+17 -3
View File
@@ -4,7 +4,7 @@
//[author: Hermes]
//[service: BOSS]
//[class: 工具类]
//[version: 2.10.1]
//[version: 2.10.2]
//[platform: web,qq,wx,tg,tb,fs,we]
//[public: false]
//[price: 0]
@@ -276,7 +276,7 @@ function contentText() {
}
function usage() {
return [
"启点读书签到插件 v2.10.1",
"启点读书签到插件 v2.10.2",
"【一级菜单】",
"账号管理:启点账号",
"执行查询:启点查询",
@@ -404,7 +404,14 @@ function qidianRequest(path, method, data, cookie) {
if (typeof out === "string") out = safeJsonParse(out, out)
return out
}
function resultCode(obj) { return obj && (obj.Result !== undefined ? obj.Result : obj.result !== undefined ? obj.result : obj.Code !== undefined ? obj.Code : obj.code !== undefined ? obj.code : obj.retcode) }
function resultCode(obj) {
if (!obj) return undefined
var keys = ["Result", "result", "Code", "code", "retcode", "RetCode"]
for (var i = 0; i < keys.length; i++) if (obj[keys[i]] !== undefined) return obj[keys[i]]
var data = obj.Data || obj.data || obj.ResultData || obj.resultData
if (data && typeof data === "object") for (var j = 0; j < keys.length; j++) if (data[keys[j]] !== undefined) return data[keys[j]]
return undefined
}
function resultOk(obj) {
var code = resultCode(obj)
var status = obj && (obj.status || obj.Status)
@@ -695,11 +702,18 @@ function recentCreateTime(v) {
var now = (new Date()).getTime()
return now - t >= 0 && now - t <= 24 * 60 * 60 * 1000
}
function beijingHour(dateLike) { return beijingDate(dateLike).getUTCHours() }
function messageBoxWindowLabel() { return "20:00-22:00" }
function messageBoxAllowedNow() {
var h = beijingHour()
return h >= 20 && h < 22
}
function orderIdFromText(s) {
var m = String(s || "").match(/orderId=([a-f0-9]+)/i)
return m ? m[1] : ""
}
function doMessageBox(cookie) {
if (!messageBoxAllowedNow()) return { name: "大咖荐书", ok: true, skipped: true, msg: "不在执行时间 " + messageBoxWindowLabel() + ",已跳过", path: "https://magev6.if.qidian.com/argus/api/v2/message/pullmessage" }
var token = messageTokenFromCookie(cookie)
if (!token) return { name: "大咖荐书", ok: true, msg: "缺少消息 token,已跳过", path: "https://magev6.if.qidian.com/argus/api/v2/message/pullmessage" }
var baseParams = { token: token, type: "0", pg: "1", pz: "10" }
+55 -1
View File
@@ -369,7 +369,7 @@ test('optional QDReader full tasks use upstream executable endpoints and sign ab
qdreader_task_pref_json: JSON.stringify({ '12345': { adv: true, extraAdv: true, lottery: true, weeklyExchange: true, chapterCard: true, messageBox: true } }),
};
const originalDate = Date;
const sunday = fixedDateClass('2026-05-24T07:01:00.000+08:00');
const sunday = fixedDateClass('2026-05-24T20:01:00.000+08:00');
const r = runPlugin({
content: '启点签到',
store,
@@ -790,6 +790,58 @@ test('adv task treats upstream result 9 as accepted and verifies finished state'
assert.match(r.calls.find(c => /video\/adv\/finishWatch$/.test(c.url)).body, /1165585369246138372/);
});
test('adv task accepts nested data result 9 with empty message from sign gateway wrapper', () => {
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: '1165585369246138372', Title: '看视频领福利', IsFinished: 0 }] } } } },
{ body: { code: 0, data: { headers: { 'QD-Sign': 'sig' } } } },
{ statusCode: 200, body: { code: 200, data: { result: 9, message: '' } } },
{ body: { code: 0, data: { headers: { 'QD-Sign': 'sig' } } } },
{ statusCode: 200, body: { code: 0, Data: { VideoRewardTab: { TaskList: [{ TaskId: '1165585369246138372', Title: '看视频领福利', IsFinished: 1 }] } } } },
],
});
assert.match(r.replies[0], /激励任务✅\(已完成\)/);
assert.doesNotMatch(r.replies[0], /任务 1165585369246138372 失败/);
});
test('message box skips outside Beijing 20-22 window without calling message API', () => {
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': { messageBox: true } }),
};
const now = fixedDateClass('2026-05-20T22:20:00.000+08:00');
const r = runPlugin({
content: '启点签到',
store,
userId: 'user-a',
globals: { Date: now },
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: '无可领取礼包' } },
],
});
assert.match(r.replies[0], /大咖荐书⏭\(不在执行时间 20:00-22:00,已跳过\)/);
assert.match(r.replies[0], /汇总:成功 1 \/ 失败 0 \/ 总计 1/);
assert.equal(r.calls.some(c => /message\/pullmessage/.test(c.url)), false);
});
test('message box uses base62 token and senderId/detail/callback chain instead of parameter-error one-shot', () => {
const store = {
qdreader_cookie_json: JSON.stringify({ '12345': cookie }),
@@ -836,10 +888,12 @@ test('stream uid message token matches upstream operator precedence and avoids p
qdreader_user_bind_json: JSON.stringify({ '475700975': 'user-a' }),
qdreader_task_pref_json: JSON.stringify({ '475700975': { messageBox: true } }),
};
const now = fixedDateClass('2026-05-20T20:31:00.000+08:00');
const r = runPlugin({
content: '启点签到',
store,
userId: 'user-a',
globals: { Date: now },
requests: [
{ body: { code: 0, data: { headers: { 'QD-Sign': 'sig' } } } },
{ statusCode: 200, body: { code: 1, msg: '今日已签到' } },