From 93cdaf5d3e19e2c687160a143d4a0aa813a5da23 Mon Sep 17 00:00:00 2001 From: Hex Date: Wed, 14 Oct 2026 23:21:59 +0800 Subject: [PATCH] =?UTF-8?q?feat(library):=20=E2=9C=A8=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=85=B3=E6=B3=A8=E5=85=B4=E8=B6=A3=E4=BB=BB=E5=8A=A1=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=B9=B6=E6=9B=B4=E6=96=B0=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 在 `library_task.js` 中实现了 `doFollowInterestTask` 方法,用于处理 `interactive.follow.interest_online` 类型的任务。 * 新增 `getInterestList` 方法,通过调用兴趣广场 API 获取兴趣列表。 * 在任务分发逻辑中集成了关注兴趣任务的处理流程。 * 更新 `README.md`,在任务列表说明中添加了“关注兴趣”项。 --- README.md | 1 + library_task.js | 95 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) diff --git a/README.md b/README.md index 011a32c..7ff99a8 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ * 关注用户 * 关注栏目 * 关注品牌 + * 关注兴趣 * 站外浏览 * 打开第三方 App * 开启推送 diff --git a/library_task.js b/library_task.js index d641f83..2177289 100644 --- a/library_task.js +++ b/library_task.js @@ -86,6 +86,14 @@ class SmzdmTaskBot extends SmzdmBot { await waitHuman(5, 15); } + // 关注兴趣任务 + else if (task.task_event_type == 'interactive.follow.interest_online') { + const { isSuccess } = await this.doFollowInterestTask(task); + + notifyMsg += this.getTaskNotifyMessage(isSuccess, task); + + await waitHuman(5, 15); + } // 收藏任务 else if (task.task_event_type == 'interactive.favorite') { const { isSuccess } = await this.doFavoriteTask(task); @@ -586,6 +594,93 @@ class SmzdmTaskBot extends SmzdmBot { return await this.receiveReward(task.task_id); } + // 执行关注兴趣任务(兴趣广场的兴趣项,关注参数与栏目一致) + async doFollowInterestTask(task) { + this.$env.log(`开始任务: ${task.task_name}`); + + const interests = this.getShuffled(await this.getInterestList()); + const need = Number(task.task_even_num - task.task_finished_num); + + if (interests.length < 1) { + return { + isSuccess: false + }; + } + + await wait(3, 10); + + for (let i = 0; i < Math.min(need, interests.length); i++) { + const interest = interests[i]; + + if (interest.is_follow == '1') { + await this.follow({ + method: 'destroy', + type: interest.type, + keywordId: interest.keyword_id, + keyword: interest.keyword + }); + + await wait(3, 10); + } + + await this.follow({ + method: 'create', + type: interest.type, + keywordId: interest.keyword_id, + keyword: interest.keyword + }); + + await wait(3, 10); + + if (interest.is_follow == '0') { + await this.follow({ + method: 'destroy', + type: interest.type, + keywordId: interest.keyword_id, + keyword: interest.keyword + }); + + await wait(3, 10); + } + } + + this.$env.log('领取奖励'); + await waitHuman(5, 15); + + return await this.receiveReward(task.task_id); + } + + // 兴趣广场里的兴趣列表 + async getInterestList() { + const { isSuccess, data, response } = await requestApi('https://interest-api.smzdm.com/interest_square/index_v6', { + method: 'post', + headers: this.getHeaders(), + data: { + 'f': 'android' + } + }); + + if (!isSuccess) { + this.$env.log(`获取兴趣列表失败!${response}`); + + return []; + } + + const interests = []; + + (data.data.rows || []).forEach(row => { + (row.sub_rows || []).forEach(item => { + const interest = item.follow_data; + + if (interest && interest.keyword_id && interest.keyword) { + interests.push(interest); + } + }); + }); + + return interests; + } + // 执行关注品牌任务(先取关,再关注,最后取关) async doFollowBrandTask(task) { this.$env.log(`开始任务: ${task.task_name}`);