feat(qdreader): streamline account menu
This commit is contained in:
+61
-26
@@ -4,7 +4,7 @@
|
||||
//[author: Hermes]
|
||||
//[service: BOSS]
|
||||
//[class: 工具类]
|
||||
// [version: 2.12.0]
|
||||
// [version: 2.13.0]
|
||||
// [platform: web,qq,wx,tg,tb,fs,we]
|
||||
// [public: false]
|
||||
// [price: 0]
|
||||
@@ -279,7 +279,7 @@ function contentText() {
|
||||
}
|
||||
function usage() {
|
||||
return [
|
||||
"启点读书签到插件 v2.12.0",
|
||||
"启点读书签到插件 v2.13.0",
|
||||
"【一级菜单】",
|
||||
"账号管理:启点账号",
|
||||
"执行查询:启点查询",
|
||||
@@ -968,18 +968,22 @@ function listenInput(timeoutMs) {
|
||||
try { if (typeof sender !== "undefined" && sender && sender.listen) return trim(sender.listen(timeoutMs || 60000)) } catch (e) {}
|
||||
return ""
|
||||
}
|
||||
function accountMenuText() {
|
||||
return [
|
||||
"启点账号管理",
|
||||
"1. 查看账号",
|
||||
"2. 添加/更新账号",
|
||||
"3. 账号详情/修改备注",
|
||||
"4. 账号任务配置",
|
||||
"5. 删除账号",
|
||||
"6. 清空账号",
|
||||
"q. 退出",
|
||||
"请回复序号"
|
||||
].join("\n")
|
||||
function accountMenuText(store, bind) {
|
||||
var uids = visibleUids(store || getStore(), bind || getBindStore(), false)
|
||||
var remarks = remarksForStore(store || {})
|
||||
var lines = ["启点账号管理"]
|
||||
if (!uids.length) lines.push("当前用户还没有保存启点读书CK")
|
||||
else {
|
||||
lines.push("现有账号:")
|
||||
for (var i = 0; i < uids.length; i++) {
|
||||
var uid = uids[i]
|
||||
lines.push((i + 1) + ". " + maskUid(uid) + (remarks[uid] ? "(" + remarks[uid] + ")" : ""))
|
||||
}
|
||||
}
|
||||
lines.push("回复编号进入账号配置,例如 1")
|
||||
lines.push("回复负编号删除账号,例如 -1")
|
||||
lines.push("回复 a 添加/更新账号;all 清空账号;q 退出")
|
||||
return lines.join("\n")
|
||||
}
|
||||
function queryMenuText() {
|
||||
return [
|
||||
@@ -1054,12 +1058,20 @@ function accountDetailText(uid, store, bind) {
|
||||
"修改备注请回复新备注名,发送 清空 可删除备注,发送 q 退出"
|
||||
].join("\n")
|
||||
}
|
||||
function accountDetailMenu(store, bind) {
|
||||
var uid = chooseUid(store, bind, "请选择要查看/修改备注的账号:")
|
||||
if (!uid) return reply("已退出")
|
||||
function accountConfigText(uid, store, bind) {
|
||||
var detail = accountDetailText(uid, store, bind)
|
||||
reply(detail)
|
||||
if (/^(无权|未找到)/.test(detail)) return
|
||||
if (/^(无权|未找到)/.test(detail)) return detail
|
||||
return detail + "\n\n账号配置:\n1. 修改备注\n2. 任务配置\n3. 立即签到该账号\n-1. 删除该账号\nq. 返回/退出\n请回复选项"
|
||||
}
|
||||
function accountConfigMenu(uid, store, bind) {
|
||||
if (!uid) return reply("未选择账号,已退出")
|
||||
var cfg = accountConfigText(uid, store, bind)
|
||||
reply(cfg)
|
||||
if (/^(无权|未找到)/.test(cfg)) return
|
||||
var op = listenInput(60000)
|
||||
if (!op || /^(q|退出|取消|返回)$/i.test(op)) return reply("已退出")
|
||||
if (/^(1|备注|改名|名称)$/i.test(op)) {
|
||||
reply("请回复新备注名;发送 清空 可删除备注;q 退出")
|
||||
var remark = listenInput(60000)
|
||||
if (!remark || /^(q|退出|取消)$/i.test(remark)) return reply("已退出")
|
||||
var remarks = remarksForStore(store)
|
||||
@@ -1067,12 +1079,22 @@ function accountDetailMenu(store, bind) {
|
||||
setRemarkStore(remarks)
|
||||
return reply("已更新备注:" + maskUid(uid) + (remarks[uid] ? "(" + remarks[uid] + ")" : ""))
|
||||
}
|
||||
if (/^(2|任务|配置|开关)$/i.test(op)) return taskMenuForUid(uid)
|
||||
if (/^(3|签到|执行|立即)$/i.test(op)) return reply(signAll(uid, false, "menu"))
|
||||
if (/^-1$/.test(op) || /^(删除|delete|del|rm)$/i.test(op)) return reply(handleDelete("删除 " + uid, store, bind))
|
||||
return reply("未识别选项,已退出")
|
||||
}
|
||||
function accountDetailMenu(store, bind) {
|
||||
var uid = chooseUid(store, bind, "请选择要查看/修改备注的账号:")
|
||||
if (!uid) return reply("已退出")
|
||||
return accountConfigMenu(uid, store, bind)
|
||||
}
|
||||
function accountMenu(store, bind) {
|
||||
reply(accountMenuText())
|
||||
var uids = visibleUids(store, bind, false)
|
||||
reply(accountMenuText(store, bind))
|
||||
var op = listenInput(60000)
|
||||
if (!op || /^(q|退出|取消)$/i.test(op)) return reply("已退出")
|
||||
if (/^(1|查看|查询|列表|账号)$/i.test(op)) return reply(accountListText(store, bind))
|
||||
if (/^(2|添加|新增|更新)$/i.test(op)) {
|
||||
if (/^(a|add|添加|新增|更新)$/i.test(op)) {
|
||||
reply("请在60秒内发送 QX 抓到的完整 Cookie(q:退出)")
|
||||
var ck = listenInput(60000)
|
||||
if (!ck || /^(q|退出|取消)$/i.test(ck)) return reply("已退出")
|
||||
@@ -1080,18 +1102,31 @@ function accountMenu(store, bind) {
|
||||
var remarkMsg = (save.ok && save.uids.length === 1) ? maybePromptRemark(save.uids[0], store) : ""
|
||||
return reply(save.text + remarkMsg)
|
||||
}
|
||||
if (/^(3|详情|备注|改名|名称)$/i.test(op)) return accountDetailMenu(store, bind)
|
||||
if (/^(4|任务|配置|开关)$/i.test(op)) {
|
||||
if (/^(all|清空|全部)$/i.test(op)) return reply(handleDelete("删除 all", store, bind))
|
||||
var n = parseInt(op, 10)
|
||||
if (!isNaN(n) && String(n) === op.replace(/^\+/, "")) {
|
||||
if (n > 0) {
|
||||
if (n > uids.length) return reply("编号无效,已退出")
|
||||
return accountConfigMenu(uids[n - 1], store, bind)
|
||||
}
|
||||
if (n < 0) {
|
||||
var idx = Math.abs(n)
|
||||
if (idx > uids.length) return reply("编号无效,已退出")
|
||||
return reply(handleDelete("删除 " + uids[idx - 1], store, bind))
|
||||
}
|
||||
}
|
||||
if (/^(查看|查询|列表|账号)$/i.test(op)) return reply(accountListText(store, bind))
|
||||
if (/^(详情|备注|改名|名称)$/i.test(op)) return accountDetailMenu(store, bind)
|
||||
if (/^(任务|配置|开关)$/i.test(op)) {
|
||||
var taskUid = chooseUid(store, bind, "请选择要配置任务的账号:")
|
||||
if (!taskUid) return reply("已退出")
|
||||
return taskMenuForUid(taskUid)
|
||||
}
|
||||
if (/^(5|删除)$/i.test(op)) {
|
||||
if (/^(删除)$/i.test(op)) {
|
||||
var uid = chooseUid(store, bind, "请选择要删除的账号:")
|
||||
if (!uid) return reply("已退出")
|
||||
return reply(handleDelete("删除 " + uid, store, bind))
|
||||
}
|
||||
if (/^(6|清空|全部)$/i.test(op)) return reply(handleDelete("删除 all", store, bind))
|
||||
return reply("未识别选项,已退出")
|
||||
}
|
||||
function queryMenu() {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//[author: Hermes]
|
||||
//[service: BOSS]
|
||||
//[class: 工具类]
|
||||
// [version: 2.12.0]
|
||||
// [version: 2.13.0]
|
||||
// [platform: web,qq,wx,tg,tb,fs,we]
|
||||
// [public: false]
|
||||
// [price: 0]
|
||||
@@ -279,7 +279,7 @@ function contentText() {
|
||||
}
|
||||
function usage() {
|
||||
return [
|
||||
"启点读书签到插件 v2.12.0",
|
||||
"启点读书签到插件 v2.13.0",
|
||||
"【一级菜单】",
|
||||
"账号管理:启点账号",
|
||||
"执行查询:启点查询",
|
||||
@@ -968,18 +968,22 @@ function listenInput(timeoutMs) {
|
||||
try { if (typeof sender !== "undefined" && sender && sender.listen) return trim(sender.listen(timeoutMs || 60000)) } catch (e) {}
|
||||
return ""
|
||||
}
|
||||
function accountMenuText() {
|
||||
return [
|
||||
"启点账号管理",
|
||||
"1. 查看账号",
|
||||
"2. 添加/更新账号",
|
||||
"3. 账号详情/修改备注",
|
||||
"4. 账号任务配置",
|
||||
"5. 删除账号",
|
||||
"6. 清空账号",
|
||||
"q. 退出",
|
||||
"请回复序号"
|
||||
].join("\n")
|
||||
function accountMenuText(store, bind) {
|
||||
var uids = visibleUids(store || getStore(), bind || getBindStore(), false)
|
||||
var remarks = remarksForStore(store || {})
|
||||
var lines = ["启点账号管理"]
|
||||
if (!uids.length) lines.push("当前用户还没有保存启点读书CK")
|
||||
else {
|
||||
lines.push("现有账号:")
|
||||
for (var i = 0; i < uids.length; i++) {
|
||||
var uid = uids[i]
|
||||
lines.push((i + 1) + ". " + maskUid(uid) + (remarks[uid] ? "(" + remarks[uid] + ")" : ""))
|
||||
}
|
||||
}
|
||||
lines.push("回复编号进入账号配置,例如 1")
|
||||
lines.push("回复负编号删除账号,例如 -1")
|
||||
lines.push("回复 a 添加/更新账号;all 清空账号;q 退出")
|
||||
return lines.join("\n")
|
||||
}
|
||||
function queryMenuText() {
|
||||
return [
|
||||
@@ -1054,12 +1058,20 @@ function accountDetailText(uid, store, bind) {
|
||||
"修改备注请回复新备注名,发送 清空 可删除备注,发送 q 退出"
|
||||
].join("\n")
|
||||
}
|
||||
function accountDetailMenu(store, bind) {
|
||||
var uid = chooseUid(store, bind, "请选择要查看/修改备注的账号:")
|
||||
if (!uid) return reply("已退出")
|
||||
function accountConfigText(uid, store, bind) {
|
||||
var detail = accountDetailText(uid, store, bind)
|
||||
reply(detail)
|
||||
if (/^(无权|未找到)/.test(detail)) return
|
||||
if (/^(无权|未找到)/.test(detail)) return detail
|
||||
return detail + "\n\n账号配置:\n1. 修改备注\n2. 任务配置\n3. 立即签到该账号\n-1. 删除该账号\nq. 返回/退出\n请回复选项"
|
||||
}
|
||||
function accountConfigMenu(uid, store, bind) {
|
||||
if (!uid) return reply("未选择账号,已退出")
|
||||
var cfg = accountConfigText(uid, store, bind)
|
||||
reply(cfg)
|
||||
if (/^(无权|未找到)/.test(cfg)) return
|
||||
var op = listenInput(60000)
|
||||
if (!op || /^(q|退出|取消|返回)$/i.test(op)) return reply("已退出")
|
||||
if (/^(1|备注|改名|名称)$/i.test(op)) {
|
||||
reply("请回复新备注名;发送 清空 可删除备注;q 退出")
|
||||
var remark = listenInput(60000)
|
||||
if (!remark || /^(q|退出|取消)$/i.test(remark)) return reply("已退出")
|
||||
var remarks = remarksForStore(store)
|
||||
@@ -1067,12 +1079,22 @@ function accountDetailMenu(store, bind) {
|
||||
setRemarkStore(remarks)
|
||||
return reply("已更新备注:" + maskUid(uid) + (remarks[uid] ? "(" + remarks[uid] + ")" : ""))
|
||||
}
|
||||
if (/^(2|任务|配置|开关)$/i.test(op)) return taskMenuForUid(uid)
|
||||
if (/^(3|签到|执行|立即)$/i.test(op)) return reply(signAll(uid, false, "menu"))
|
||||
if (/^-1$/.test(op) || /^(删除|delete|del|rm)$/i.test(op)) return reply(handleDelete("删除 " + uid, store, bind))
|
||||
return reply("未识别选项,已退出")
|
||||
}
|
||||
function accountDetailMenu(store, bind) {
|
||||
var uid = chooseUid(store, bind, "请选择要查看/修改备注的账号:")
|
||||
if (!uid) return reply("已退出")
|
||||
return accountConfigMenu(uid, store, bind)
|
||||
}
|
||||
function accountMenu(store, bind) {
|
||||
reply(accountMenuText())
|
||||
var uids = visibleUids(store, bind, false)
|
||||
reply(accountMenuText(store, bind))
|
||||
var op = listenInput(60000)
|
||||
if (!op || /^(q|退出|取消)$/i.test(op)) return reply("已退出")
|
||||
if (/^(1|查看|查询|列表|账号)$/i.test(op)) return reply(accountListText(store, bind))
|
||||
if (/^(2|添加|新增|更新)$/i.test(op)) {
|
||||
if (/^(a|add|添加|新增|更新)$/i.test(op)) {
|
||||
reply("请在60秒内发送 QX 抓到的完整 Cookie(q:退出)")
|
||||
var ck = listenInput(60000)
|
||||
if (!ck || /^(q|退出|取消)$/i.test(ck)) return reply("已退出")
|
||||
@@ -1080,18 +1102,31 @@ function accountMenu(store, bind) {
|
||||
var remarkMsg = (save.ok && save.uids.length === 1) ? maybePromptRemark(save.uids[0], store) : ""
|
||||
return reply(save.text + remarkMsg)
|
||||
}
|
||||
if (/^(3|详情|备注|改名|名称)$/i.test(op)) return accountDetailMenu(store, bind)
|
||||
if (/^(4|任务|配置|开关)$/i.test(op)) {
|
||||
if (/^(all|清空|全部)$/i.test(op)) return reply(handleDelete("删除 all", store, bind))
|
||||
var n = parseInt(op, 10)
|
||||
if (!isNaN(n) && String(n) === op.replace(/^\+/, "")) {
|
||||
if (n > 0) {
|
||||
if (n > uids.length) return reply("编号无效,已退出")
|
||||
return accountConfigMenu(uids[n - 1], store, bind)
|
||||
}
|
||||
if (n < 0) {
|
||||
var idx = Math.abs(n)
|
||||
if (idx > uids.length) return reply("编号无效,已退出")
|
||||
return reply(handleDelete("删除 " + uids[idx - 1], store, bind))
|
||||
}
|
||||
}
|
||||
if (/^(查看|查询|列表|账号)$/i.test(op)) return reply(accountListText(store, bind))
|
||||
if (/^(详情|备注|改名|名称)$/i.test(op)) return accountDetailMenu(store, bind)
|
||||
if (/^(任务|配置|开关)$/i.test(op)) {
|
||||
var taskUid = chooseUid(store, bind, "请选择要配置任务的账号:")
|
||||
if (!taskUid) return reply("已退出")
|
||||
return taskMenuForUid(taskUid)
|
||||
}
|
||||
if (/^(5|删除)$/i.test(op)) {
|
||||
if (/^(删除)$/i.test(op)) {
|
||||
var uid = chooseUid(store, bind, "请选择要删除的账号:")
|
||||
if (!uid) return reply("已退出")
|
||||
return reply(handleDelete("删除 " + uid, store, bind))
|
||||
}
|
||||
if (/^(6|清空|全部)$/i.test(op)) return reply(handleDelete("删除 all", store, bind))
|
||||
return reply("未识别选项,已退出")
|
||||
}
|
||||
function queryMenu() {
|
||||
|
||||
@@ -165,7 +165,7 @@ test('quick submit can decode QDHeader uid without Buffer or atob', () => {
|
||||
test('account menu add remark uses saved QDHeader uid instead of ywguid', () => {
|
||||
const streamQdheader = 'KG51bGwpfChudWxsKXwxMTc5fDI1NTZ8KG51bGwpfDE2LjEwfDB8aU9TL2lQaG9uZS8obnVsbCl8MHwobnVsbCl8KG51bGwpfDQ3NTcwMDk3NXwxNzc5MDA5MTM2MDAwfDB8KG51bGwpfHx8KG51bGwpfChudWxsKXww';
|
||||
const streamCookie = `QDHeader=${streamQdheader}; ywguid=120098575768; qdh=qdh; sessionyw=s; appId=12`;
|
||||
const r = runPlugin({ content: '启点账号', userId: 'user-a', listens: ['2', streamCookie, '01'] });
|
||||
const r = runPlugin({ content: '启点账号', userId: 'user-a', listens: ['a', streamCookie, '01'] });
|
||||
assert.match(r.replies.join('\n'), /uid: 475700975/);
|
||||
assert.equal(JSON.parse(r.store.qdreader_remark_json)['475700975'], '01');
|
||||
assert.equal(JSON.parse(r.store.qdreader_remark_json)['120098575768'], undefined);
|
||||
@@ -553,7 +553,7 @@ test('hermes_qidian bucket values are read and written without legacy bucket fal
|
||||
'hermes_qidian.qdreader_cookie_json': JSON.stringify({ '12345': cookie }),
|
||||
'hermes_qidian.qdreader_user_bind_json': JSON.stringify({ '12345': 'user-a' }),
|
||||
};
|
||||
const r = runPlugin({ content: '启点账号', bucketStore, userId: 'user-a', listens: ['3', '1', '主号'] });
|
||||
const r = runPlugin({ content: '启点账号', bucketStore, userId: 'user-a', listens: ['1', '1', '主号'] });
|
||||
assert.match(r.replies.join('\n'), /已更新备注/);
|
||||
assert.equal(JSON.parse(r.bucketStore['hermes_qidian.qdreader_remark_json'])['12345'], '主号');
|
||||
});
|
||||
@@ -581,13 +581,12 @@ test('account command shows only current user bound accounts without cookies', (
|
||||
qdreader_user_bind_json: JSON.stringify({ '12345': 'user-a', '67890': 'user-b' }),
|
||||
qdreader_remark_json: JSON.stringify({ '12345': '主号', '67890': '副号' }),
|
||||
};
|
||||
const r = runPlugin({ content: '启点账号', store, userId: 'user-a', listens: ['1'] });
|
||||
const r = runPlugin({ content: '启点账号', store, userId: 'user-a', listens: ['q'] });
|
||||
assert.match(r.replies[0], /启点账号管理/);
|
||||
assert.match(r.replies[1], /当前用户共 1 个账号/);
|
||||
assert.match(r.replies[1], /12\*\*\*45/);
|
||||
assert.match(r.replies[1], /主号/);
|
||||
assert.doesNotMatch(r.replies[1], /67\*\*\*90/);
|
||||
assert.doesNotMatch(r.replies[1], /QDHeader=/);
|
||||
assert.match(r.replies[0], /现有账号/);
|
||||
assert.match(r.replies[0], /1\. 12\*\*\*45(主号)/);
|
||||
assert.doesNotMatch(r.replies[0], /67\*\*\*90/);
|
||||
assert.doesNotMatch(r.replies[0], /QDHeader=/);
|
||||
});
|
||||
|
||||
test('query command shows last sign log not account management', () => {
|
||||
@@ -641,12 +640,13 @@ test('account menu prompts remark after add and can edit from detail', () => {
|
||||
qdreader_cookie_json: JSON.stringify({ '12345': cookie }),
|
||||
qdreader_user_bind_json: JSON.stringify({ '12345': 'user-a' }),
|
||||
};
|
||||
const add = runPlugin({ content: '启点账号', store: {}, userId: 'user-a', listens: ['2', cookie, '主号'] });
|
||||
const add = runPlugin({ content: '启点账号', store: {}, userId: 'user-a', listens: ['a', cookie, '主号'] });
|
||||
assert.match(add.replies.join('\n'), /是否为该账号添加备注/);
|
||||
assert.equal(JSON.parse(add.store.qdreader_remark_json)['12345'], '主号');
|
||||
const clear = runPlugin({ content: '启点账号', store: add.store, userId: 'user-a', listens: ['3', '1', '清空'] });
|
||||
assert.match(clear.replies.join('\n'), /请选择要查看\/修改备注的账号/);
|
||||
assert.match(clear.replies.join('\n'), /启点账号详情/);
|
||||
const clear = runPlugin({ content: '启点账号', store: add.store, userId: 'user-a', listens: ['1', '1', '清空'] });
|
||||
assert.match(clear.replies.join('\n'), /现有账号/);
|
||||
assert.match(clear.replies.join('\n'), /账号配置/);
|
||||
assert.match(clear.replies.join('\n'), /请回复新备注名/);
|
||||
assert.equal(JSON.parse(clear.store.qdreader_remark_json)['12345'], undefined);
|
||||
});
|
||||
|
||||
@@ -672,13 +672,49 @@ test('legacy ck query points to separated commands', () => {
|
||||
});
|
||||
|
||||
|
||||
test('delete account uses numbered selection instead of uid input', () => {
|
||||
test('account menu first screen lists accounts and positive number opens config', () => {
|
||||
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', listens: ['5', '2'] });
|
||||
const r = runPlugin({ content: '启点账号', store, userId: 'user-a', listens: ['2', 'q'] });
|
||||
assert.match(r.replies[0], /启点账号管理/);
|
||||
assert.match(r.replies[0], /现有账号/);
|
||||
assert.match(r.replies[0], /1\. 12\*\*\*45(主号)/);
|
||||
assert.match(r.replies[0], /2\. 67\*\*\*90(副号)/);
|
||||
assert.match(r.replies[0], /回复编号进入账号配置/);
|
||||
assert.match(r.replies[0], /回复负编号删除账号/);
|
||||
assert.match(r.replies[1], /启点账号详情/);
|
||||
assert.match(r.replies[1], /67\*\*\*90/);
|
||||
assert.match(r.replies[1], /账号配置/);
|
||||
assert.match(r.replies[2], /已退出/);
|
||||
});
|
||||
|
||||
test('account menu negative number deletes matching listed account', () => {
|
||||
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': '副号' }),
|
||||
qdreader_task_pref_json: JSON.stringify({ '12345': { adv: true }, '67890': { lottery: true } }),
|
||||
};
|
||||
const r = runPlugin({ content: '启点账号', store, userId: 'user-a', listens: ['-2'] });
|
||||
assert.match(r.replies[0], /1\. 12\*\*\*45(主号)/);
|
||||
assert.match(r.replies[0], /2\. 67\*\*\*90(副号)/);
|
||||
assert.match(r.replies[1], /已删除 uid: 67890/);
|
||||
assert.deepEqual(JSON.parse(r.store.qdreader_cookie_json), { '12345': cookie });
|
||||
assert.deepEqual(JSON.parse(r.store.qdreader_user_bind_json), { '12345': 'user-a' });
|
||||
assert.deepEqual(JSON.parse(r.store.qdreader_remark_json), { '12345': '主号' });
|
||||
assert.deepEqual(JSON.parse(r.store.qdreader_task_pref_json), { '12345': { adv: true } });
|
||||
});
|
||||
|
||||
test('delete account legacy option still uses numbered selection', () => {
|
||||
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', listens: ['删除', '2'] });
|
||||
assert.match(r.replies[1], /请选择要删除的账号/);
|
||||
assert.match(r.replies[1], /1\. 12\*\*\*45/);
|
||||
assert.match(r.replies[1], /2\. 67\*\*\*90/);
|
||||
@@ -692,7 +728,7 @@ test('delete all command clears only current user saved cookies', () => {
|
||||
qdreader_user_bind_json: JSON.stringify({ '12345': 'user-a', '67890': 'user-b' }),
|
||||
qdreader_remark_json: JSON.stringify({ '12345': '主号', '67890': '副号' }),
|
||||
};
|
||||
const r = runPlugin({ content: '启点账号', store, userId: 'user-a', listens: ['6'] });
|
||||
const r = runPlugin({ content: '启点账号', store, userId: 'user-a', listens: ['all'] });
|
||||
assert.match(r.replies[0], /启点账号管理/);
|
||||
assert.match(r.replies[1], /已删除全部/);
|
||||
assert.deepEqual(JSON.parse(r.store.qdreader_cookie_json), { '67890': cookie.replace(/12345/g, '67890') });
|
||||
@@ -784,9 +820,9 @@ test('account task menu stores full task switches per account and sign uses sele
|
||||
qdreader_cookie_json: JSON.stringify({ '12345': cookie }),
|
||||
qdreader_user_bind_json: JSON.stringify({ '12345': 'user-a' }),
|
||||
};
|
||||
const menu = runPlugin({ content: '启点账号', store: { ...store }, userId: 'user-a', listens: ['4', '1', '2 on'] });
|
||||
assert.match(menu.replies[0], /账号任务配置/);
|
||||
assert.match(menu.replies[1], /请选择要配置任务的账号/);
|
||||
const menu = runPlugin({ content: '启点账号', store: { ...store }, userId: 'user-a', listens: ['1', '2', '2 on'] });
|
||||
assert.match(menu.replies[0], /启点账号管理/);
|
||||
assert.match(menu.replies[1], /账号配置/);
|
||||
assert.match(menu.replies[2], /激励任务:关闭/);
|
||||
assert.match(menu.replies[3], /激励任务已开启/);
|
||||
assert.equal(JSON.parse(menu.store.qdreader_task_pref_json)['12345'].adv, true);
|
||||
@@ -818,8 +854,8 @@ test('delete account also clears per-account task prefs', () => {
|
||||
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', listens: ['5', '1'] });
|
||||
assert.match(r.replies[2], /已删除 uid: 12345/);
|
||||
const r = runPlugin({ content: '启点账号', store, userId: 'user-a', listens: ['-1'] });
|
||||
assert.match(r.replies[1], /已删除 uid: 12345/);
|
||||
assert.deepEqual(JSON.parse(r.store.qdreader_task_pref_json), {});
|
||||
});
|
||||
|
||||
@@ -829,7 +865,7 @@ test('account task menu supports one-click enable and disable all optional tasks
|
||||
qdreader_cookie_json: JSON.stringify({ '12345': cookie }),
|
||||
qdreader_user_bind_json: JSON.stringify({ '12345': 'user-a' }),
|
||||
};
|
||||
const enable = runPlugin({ content: '启点账号', store: { ...store }, userId: 'user-a', listens: ['4', '1', 'all on'] });
|
||||
const enable = runPlugin({ content: '启点账号', store: { ...store }, userId: 'user-a', listens: ['1', '2', 'all on'] });
|
||||
assert.match(enable.replies[3], /已一键开启账号 12\*\*\*45 的全部可选任务/);
|
||||
const prefs = JSON.parse(enable.store.qdreader_task_pref_json)['12345'];
|
||||
assert.equal(prefs.adv, true);
|
||||
@@ -839,7 +875,7 @@ test('account task menu supports one-click enable and disable all optional tasks
|
||||
assert.equal(prefs.chapterCard, true);
|
||||
assert.equal(prefs.messageBox, true);
|
||||
|
||||
const disable = runPlugin({ content: '启点账号', store: enable.store, userId: 'user-a', listens: ['4', '1', 'all off'] });
|
||||
const disable = runPlugin({ content: '启点账号', store: enable.store, userId: 'user-a', listens: ['1', '2', 'all off'] });
|
||||
assert.match(disable.replies[3], /已一键关闭账号 12\*\*\*45 的全部可选任务/);
|
||||
const disabled = JSON.parse(disable.store.qdreader_task_pref_json)['12345'];
|
||||
assert.equal(disabled.adv, false);
|
||||
|
||||
Reference in New Issue
Block a user