feat: check_if_duplicated可同时使用多种方式

This commit is contained in:
shanmite 2021-12-10 15:16:17 +08:00
parent dd994263b9
commit 0ba6acec31
4 changed files with 20 additions and 15 deletions

View File

@ -256,13 +256,16 @@ class Monitor extends Searcher {
log.info('筛选动态', `去重后(${protoLotteryInfo.length})`); log.info('筛选动态', `去重后(${protoLotteryInfo.length})`);
/**并发查询dyid */ /**并发查询dyid */
await Promise.all( if (check_if_duplicated === 1 || check_if_duplicated === 2) {
[...dyids_map.keys()] await Promise.all(
.map(it => d_storage [...dyids_map.keys()]
.searchDyid(it) .map(it => d_storage
.then(hasIt => dyids_map.set(it, hasIt)) .searchDyid(it)
) .then(hasIt => dyids_map.set(it, hasIt))
) )
)
log.info('筛选动态', `并发查询本地dyid完毕`);
}
if (lottery_param[0] !== "APIs" && set_lottery_info_url && protoLotteryInfo.length) { if (lottery_param[0] !== "APIs" && set_lottery_info_url && protoLotteryInfo.length) {
log.info("上传抽奖信息", "开始") log.info("上传抽奖信息", "开始")
@ -299,9 +302,9 @@ class Monitor extends Searcher {
/* 遇到转发过就退出 */ /* 遇到转发过就退出 */
if ( if (
(!check_if_duplicated ((!check_if_duplicated || check_if_duplicated === 2)
&& is_liked) && is_liked)
|| (check_if_duplicated === 1 || ((check_if_duplicated === 1 || check_if_duplicated === 2)
&& dyids_map.get(dyid)) && dyids_map.get(dyid))
) { ) {
log.info("筛选动态", `已转发(https://t.bilibili.com/${dyid})`) log.info("筛选动态", `已转发(https://t.bilibili.com/${dyid})`)
@ -527,7 +530,7 @@ class Monitor extends Searcher {
} }
/* 点赞 */ /* 点赞 */
if (!check_if_duplicated) { if (!check_if_duplicated || check_if_duplicated === 2) {
status = await retryfn( status = await retryfn(
5, 5,
[1, 2, 3], [1, 2, 3],

View File

@ -380,9 +380,9 @@ class Searcher {
, { is_liked } = parsed_card; , { is_liked } = parsed_card;
if ( if (
(!check_if_duplicated ((!check_if_duplicated || check_if_duplicated === 2)
&& is_liked) && is_liked)
|| (check_if_duplicated === 1 || ((check_if_duplicated === 1 || check_if_duplicated === 2)
&& await d_storage.searchDyid(dyid)) && await d_storage.searchDyid(dyid))
) { ) {
log.info('获取动态', `动态(${dyid})已转发过`) log.info('获取动态', `动态(${dyid})已转发过`)
@ -454,7 +454,7 @@ class Searcher {
let results = await pre let results = await pre
, { dyid } = cur; , { dyid } = cur;
if (!check_if_duplicated) { if (!check_if_duplicated || check_if_duplicated === 2) {
log.info('获取动态', `查看动态(${dyid})是否点赞 (${length--})`) log.info('获取动态', `查看动态(${dyid})是否点赞 (${length--})`)
const card = await bili.getOneDynamicByDyid(dyid) const card = await bili.getOneDynamicByDyid(dyid)

View File

@ -74,8 +74,9 @@ const config = {
* - 不检查 -1 * - 不检查 -1
* - 通过是否点赞判断 0 * - 通过是否点赞判断 0
* - 检索本地dyids文件 1 * - 检索本地dyids文件 1
* - 通过是否点赞判断+检索本地dyids文件 2
*/ */
check_if_duplicated: 0, check_if_duplicated: 1,
/** /**
* - 动态创建时间 * - 动态创建时间

View File

@ -88,8 +88,9 @@ module.exports = Object.freeze({
* - 不检查 -1 * - 不检查 -1
* - 通过是否点赞判断 0 * - 通过是否点赞判断 0
* - 检索本地dyids文件 1 * - 检索本地dyids文件 1
* - 通过是否点赞判断+检索本地dyids文件 2
*/ */
check_if_duplicated: 0, check_if_duplicated: 1,
/** /**
* - 动态创建时间 * - 动态创建时间