From f08f5d3e9e98b5f477ae22f2d745f3cafa20782f Mon Sep 17 00:00:00 2001 From: yeyang <746659424@qq.com> Date: Mon, 30 Jan 2023 02:38:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E4=BF=AE=E5=A4=8D=E6=B8=85?= =?UTF-8?q?=E7=A9=BA=E8=AF=B4=E8=AF=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assistant.js | 4 ++-- model/QQInterface.js | 36 +++++++++++++++++++++--------------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/apps/assistant.js b/apps/assistant.js index 9e38e9f..25c4072 100644 --- a/apps/assistant.js +++ b/apps/assistant.js @@ -582,7 +582,7 @@ export class Assistant extends plugin { } // 获取说说列表 - let list = await QQInterface.getQzone(page * 5, 5) + let list = await QQInterface.getQzone(5, page * 5) if (!list) return e.reply(API_ERROR) if (list.total == 0) return e.reply('✅ 说说列表为空') @@ -601,7 +601,7 @@ export class Assistant extends plugin { async Qzonedel (e) { let pos = e.msg.match(/\d+/) // 获取说说列表 - let list = await QQInterface.getQzone(pos - 1, 1) + let list = await QQInterface.getQzone(1, pos - 1) if (!list) return e.reply(API_ERROR) if (!list.msglist) return e.reply('❎ 未获取到该说说') diff --git a/model/QQInterface.js b/model/QQInterface.js index 5e7b232..60fab3a 100644 --- a/model/QQInterface.js +++ b/model/QQInterface.js @@ -26,11 +26,11 @@ export default new class assistant { /** * @description: 取说说列表 * @param {*} e oicq - * @param {Number} pos 偏移量 * @param {Number} num 数量 + * @param {Number} pos 偏移量 * @return {Object} QQ空间数据 */ - async getQzone (pos = 0, num = 20) { + async getQzone (num = 20, pos = 0) { let url = `https://user.qzone.qq.com/proxy/domain/taotao.qq.com/cgi-bin/emotion_cgi_msglist_v6?uin=${Bot.uin}&ftype=0&sort=0&pos=${pos}&num=${num}&replynum=100&g_tk=${Bot.bkn}&code_version=1&format=json&need_private_comment=1` return await fetch(url, { headers: { @@ -58,13 +58,16 @@ export default new class assistant { /** 删除全部说说 */ async delQzoneAll () { - let list = await this.getQzone(0, -1) - if (list.total == 0) return '❎ 说说列表空空' - for (let item of list.msglist) { - let res = await this.delQzone(item.tid, item.t1_source) - if (res.code != 0) return `❎ 遇到错误 ${JSON.stringify(res)}` + let num = 0 + while (true) { + let list = await this.getQzone(40) + if (list.total == 0) return num == 0 ? '❎ 说说列表空空' : '✅ 已清空全部说说' + for (let item of list.msglist) { + let res = await this.delQzone(item.tid, item.t1_source) + if (res.code != 0) return `❎ 遇到错误 ${JSON.stringify(res)}` + } + num++ } - return '✅ 已清空全部说说' } /** 发送说说 */ @@ -120,14 +123,17 @@ export default new class assistant { /** 删除全部留言 */ async delQzoneMsgbAll () { - let list = await this.getQzoneMsgb() - if (list.code != 0) return `❎ 获取列表错误 ${JSON.stringify(list)}` - if (list.data.total == 0) return '❎ 留言列表空空' - for (let item of list.data.commentList) { - let res = await this.delQzoneMsgb(item.id, item.uin) - if (res.code != 0) return `❎ 遇到错误 ${JSON.stringify(res)}` + let num = 0 + while (true) { + let list = await this.getQzoneMsgb(40) + if (list.code != 0) return `❎ 获取列表错误 ${JSON.stringify(list)}` + if (list.data.total == 0) return num == 0 ? '❎ 留言列表空空' : '✅ 已清空全部留言' + for (let item of list.data.commentList) { + let res = await this.delQzoneMsgb(item.id, item.uin) + if (res.code != 0) return `❎ 遇到错误 ${JSON.stringify(res)}` + } + num++ } - return '✅ 已清空全部留言' } // ----------------------------------------------------公告---------------------------------------------