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

View File

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

View File

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