From 248c78d66952c4fb17053806bea545c9193df15e Mon Sep 17 00:00:00 2001 From: shanmite Date: Sat, 5 Aug 2023 16:37:17 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BF=AB=E9=80=9F=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E5=85=B3=E6=B3=A8=E6=A8=A1=E5=BC=8F=E6=96=B0=E5=A2=9E=E7=B2=89?= =?UTF-8?q?=E4=B8=9D=E6=95=B0=E9=99=90=E5=88=B6=20(#305)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed #305 --- lib/clear.js | 20 ++++++++++++-------- lib/data/config.js | 9 ++++++++- my_config.example.js | 9 ++++++++- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/lib/clear.js b/lib/clear.js index b78efac..a26abcf 100644 --- a/lib/clear.js +++ b/lib/clear.js @@ -33,7 +33,7 @@ async function getFollowList(partition) { * 清理动态和关注 */ async function clear() { - const { search_wait, clear_white_list, clear_max_day, clear_quick_remove_attention, clear_remove_dynamic, clear_remove_attention, clear_remove_delay, clear_dynamic_type, clear_partition } = config; + const { search_wait, clear_white_list, clear_max_day, clear_quick_remove_attention, clear_quick_remove_attention_fans_number_smallest, clear_remove_dynamic, clear_remove_attention, clear_remove_delay, clear_dynamic_type, clear_partition } = config; let success = true; const uid_list = (await Promise.all(clear_partition.split(',').map(getFollowList))).flat(); if (!uid_list.length) { @@ -45,13 +45,17 @@ async function clear() { log.info('清理关注', '进入只清理关注模式') /* 专清关注 */ for (const [index, uid] of uid_list.entries()) { - log.info('清理关注', `(${index}) (${uid})`) - /* 取消关注 */ - if (await retryfn(3, [false], () => bili.cancelAttention(uid))) { - log.info('清理关注', '成功') - } else { - log.error('清理关注', '失败') - break + const fannumber = await bili.getUserInfo(uid); + log.info('清理关注', `粉丝数${fannumber}`) + if (fannumber !== -1 && fannumber < clear_quick_remove_attention_fans_number_smallest) { + log.info('清理关注', `(${index}) (${uid})`) + /* 取消关注 */ + if (await retryfn(3, [false], () => bili.cancelAttention(uid))) { + log.info('清理关注', '成功') + } else { + log.error('清理关注', '失败') + break + } } /* 延时 */ await delay(clear_remove_delay); diff --git a/lib/data/config.js b/lib/data/config.js index 3847872..3a96967 100644 --- a/lib/data/config.js +++ b/lib/data/config.js @@ -408,6 +408,13 @@ const config = { */ clear_quick_remove_attention: false, + /** + * - 快速移除关注 + * - 不加判断只去除关注 + * - 移除粉丝数小于指定数量的 + */ + clear_quick_remove_attention_fans_number_smallest: Infinity, + /** * 是否移除动态 */ @@ -419,7 +426,7 @@ const config = { clear_remove_attention: true, /** - * 清除动态延时(毫秒) + * 清除延时(毫秒) */ clear_remove_delay: 8000, diff --git a/my_config.example.js b/my_config.example.js index 3585ad3..690dd8b 100644 --- a/my_config.example.js +++ b/my_config.example.js @@ -418,6 +418,13 @@ module.exports = Object.freeze({ */ clear_quick_remove_attention: false, + /** + * - 快速移除关注 + * - 不加判断只去除关注 + * - 移除粉丝数小于指定数量的 + */ + clear_quick_remove_attention_fans_number_smallest: Infinity, + /** * 是否移除动态 */ @@ -429,7 +436,7 @@ module.exports = Object.freeze({ clear_remove_attention: true, /** - * 清除动态延时(毫秒) + * 清除延时(毫秒) */ clear_remove_delay: 8000,