feat: 快速移除关注模式新增粉丝数限制 (#305)

Fixed #305
This commit is contained in:
shanmite 2023-08-05 16:37:17 +08:00
parent 3d90e11b96
commit 248c78d669
3 changed files with 28 additions and 10 deletions

View File

@ -33,7 +33,7 @@ async function getFollowList(partition) {
* 清理动态和关注 * 清理动态和关注
*/ */
async function clear() { 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; let success = true;
const uid_list = (await Promise.all(clear_partition.split(',').map(getFollowList))).flat(); const uid_list = (await Promise.all(clear_partition.split(',').map(getFollowList))).flat();
if (!uid_list.length) { if (!uid_list.length) {
@ -45,13 +45,17 @@ async function clear() {
log.info('清理关注', '进入只清理关注模式') log.info('清理关注', '进入只清理关注模式')
/* 专清关注 */ /* 专清关注 */
for (const [index, uid] of uid_list.entries()) { for (const [index, uid] of uid_list.entries()) {
log.info('清理关注', `(${index}) (${uid})`) const fannumber = await bili.getUserInfo(uid);
/* 取消关注 */ log.info('清理关注', `粉丝数${fannumber}`)
if (await retryfn(3, [false], () => bili.cancelAttention(uid))) { if (fannumber !== -1 && fannumber < clear_quick_remove_attention_fans_number_smallest) {
log.info('清理关注', '成功') log.info('清理关注', `(${index}) (${uid})`)
} else { /* 取消关注 */
log.error('清理关注', '失败') if (await retryfn(3, [false], () => bili.cancelAttention(uid))) {
break log.info('清理关注', '成功')
} else {
log.error('清理关注', '失败')
break
}
} }
/* 延时 */ /* 延时 */
await delay(clear_remove_delay); await delay(clear_remove_delay);

View File

@ -408,6 +408,13 @@ const config = {
*/ */
clear_quick_remove_attention: false, 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_attention: true,
/** /**
* 清除动态延时(毫秒) * 清除延时(毫秒)
*/ */
clear_remove_delay: 8000, clear_remove_delay: 8000,

View File

@ -418,6 +418,13 @@ module.exports = Object.freeze({
*/ */
clear_quick_remove_attention: false, 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_attention: true,
/** /**
* 清除动态延时(毫秒) * 清除延时(毫秒)
*/ */
clear_remove_delay: 8000, clear_remove_delay: 8000,