feat: 取关分区支持设置多分区 (#281)

Fixed #281
This commit is contained in:
shanmite 2023-05-03 08:37:47 +08:00
parent c7bdf74d5c
commit b6c56c5061
3 changed files with 10 additions and 8 deletions

View File

@ -6,12 +6,13 @@ const config = require("./data/config");
/**
* 获取关注分区里的uid
* @param {string} partition
* @returns { Promise<number[]> }
*/
async function getFollowList() {
async function getFollowList(partition) {
const
{ clear_partition, clear_white_list, get_partition_wait } = config,
tagid = await bili.checkMyPartition(clear_partition);
{ clear_white_list, get_partition_wait } = config,
tagid = await bili.checkMyPartition(partition);
let rmup = [];
if (typeof tagid === 'undefined') {
log.info('获取关注列表', '未能成功获取关注分区id');
@ -32,9 +33,9 @@ async function getFollowList() {
* 清理动态和关注
*/
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 } = config;
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;
let success = true;
const uid_list = await getFollowList();
const uid_list = (await Promise.all(clear_partition.split(',').map(getFollowList))).flat();
if (!uid_list.length) {
log.info('清理关注', `关注为空`)
} else {

View File

@ -1152,7 +1152,7 @@ const bili_client = {
if (res.code === 0) {
const data = res.data.filter((it) => it.name === name);
if (data.length) {
log.info('获取分区id', '成功');
log.info('获取分区id', `成功 ${name}`);
tagid = data[0].tagid;
} else {
log.warn('获取分区id', `失败 无指定分区名${name}`);
@ -1219,10 +1219,10 @@ const bili_client = {
res.data.forEach(d => {
uids.push(d.mid);
});
log.info(`获取分组${tagid}`, `成功获取取关分区列表${n}`);
log.info(`获取分组id${tagid}`, `成功获取取关分区列表${n}`);
return uids;
} else {
log.error(`获取分组${tagid}`, `获取取关分区列表失败\n${responseText}`);
log.error(`获取分组id${tagid}`, `获取取关分区列表失败\n${responseText}`);
return uids;
}
}

View File

@ -403,6 +403,7 @@ module.exports = Object.freeze({
/**
* - 取关分区
* - 默认为: 此处存放因抽奖临时关注的up
* - 可用逗号分割以取关多分区
*/
clear_partition: '',