feat: 过滤掉充电包月抽奖 (#224)

Fixed #224
This commit is contained in:
shanmite 2023-01-03 11:59:39 +08:00
parent 7b5a1778ea
commit cb08e7afe0
6 changed files with 49 additions and 8 deletions

View File

@ -324,7 +324,10 @@ class Monitor extends Searcher {
await try_for_each(protoLotteryInfo, async function (lottery_info) { await try_for_each(protoLotteryInfo, async function (lottery_info) {
const { const {
lottery_info_type, is_liked, lottery_info_type, is_liked,
uids, uname, dyid, reserve_id, reserve_lottery_text, create_time, uids, uname, dyid, reserve_id,
reserve_lottery_text,
is_charge_lottery,
create_time,
ctrl, rid, des, type, ctrl, rid, des, type,
hasOfficialLottery hasOfficialLottery
} = lottery_info; } = lottery_info;
@ -350,6 +353,11 @@ class Monitor extends Searcher {
return false return false
} }
if (is_charge_lottery) {
log.info("筛选动态", `充电抽奖(https://t.bilibili.com/${dyid})`)
return false
}
const const
[m_uid, ori_uid] = uids, [m_uid, ori_uid] = uids,
mIsFollowed = !m_uid || (new RegExp(m_uid)).test(attentionList), mIsFollowed = !m_uid || (new RegExp(m_uid)).test(attentionList),

View File

@ -20,6 +20,7 @@ const { log } = utils
* @property {string} description * @property {string} description
* @property {string} reserve_id * @property {string} reserve_id
* @property {string} reserve_lottery_text * @property {string} reserve_lottery_text
* @property {boolean} is_charge_lottery
* @property {boolean} hasOfficialLottery * @property {boolean} hasOfficialLottery
* @property {Array<Object.<string,string|number>>} ctrl * @property {Array<Object.<string,string|number>>} ctrl
* @property {number} origin_create_time 10 * @property {number} origin_create_time 10
@ -31,6 +32,7 @@ const { log } = utils
* @property {string} origin_description * @property {string} origin_description
* @property {string} origin_reserve_id * @property {string} origin_reserve_id
* @property {string} origin_reserve_lottery_text * @property {string} origin_reserve_lottery_text
* @property {boolean} origin_is_charge_lottery
* @property {boolean} origin_hasOfficialLottery * @property {boolean} origin_hasOfficialLottery
* *
* 整理后的抽奖信息 * 整理后的抽奖信息
@ -44,6 +46,7 @@ const { log } = utils
* @property {string} dyid * @property {string} dyid
* @property {string} reserve_id * @property {string} reserve_id
* @property {string} reserve_lottery_text * @property {string} reserve_lottery_text
* @property {boolean} is_charge_lottery
* @property {string} rid * @property {string} rid
* @property {string} des * @property {string} des
* @property {number} type * @property {number} type
@ -96,6 +99,9 @@ function parseDynamicCard(dynamic_detail_card) {
obj.reserve_lottery_text = text; obj.reserve_lottery_text = text;
} }
} }
if (JSON.stringify(add_on_card_info).match(/充电专属抽奖/)) {
obj.is_charge_lottery = true
}
/* 是否有官方抽奖 */ /* 是否有官方抽奖 */
obj.hasOfficialLottery = extension && extension.lott && true; obj.hasOfficialLottery = extension && extension.lott && true;
/* 转发者的描述 纯文字内容 图片动态描述 后两个分别是视频动态的描述和视频本身的描述*/ /* 转发者的描述 纯文字内容 图片动态描述 后两个分别是视频动态的描述和视频本身的描述*/
@ -131,6 +137,9 @@ function parseDynamicCard(dynamic_detail_card) {
obj.origin_reserve_lottery_text = text; obj.origin_reserve_lottery_text = text;
} }
} }
if (JSON.stringify(add_on_card_info).match(/充电专属抽奖/)) {
obj.origin_is_charge_lottery = true
}
/* 是否有官方抽奖 */ /* 是否有官方抽奖 */
obj.origin_hasOfficialLottery = origin_extension && origin_extension.lott; obj.origin_hasOfficialLottery = origin_extension && origin_extension.lott;
/* 被转发者的name */ /* 被转发者的name */
@ -256,6 +265,7 @@ class Searcher {
return ({ allModifyDynamicResArray, offset }); return ({ allModifyDynamicResArray, offset });
} }
/** /**
* 获取最新动态信息(转发子动态) * 获取最新动态信息(转发子动态)
* 并初步整理 * 并初步整理
@ -307,6 +317,7 @@ class Searcher {
dyid: cur.origin_dynamic_id, dyid: cur.origin_dynamic_id,
reserve_id: cur.origin_reserve_id, reserve_id: cur.origin_reserve_id,
reserve_lottery_text: cur.origin_reserve_lottery_text, reserve_lottery_text: cur.origin_reserve_lottery_text,
is_charge_lottery: cur.origin_is_charge_lottery,
rid: cur.origin_rid_str, rid: cur.origin_rid_str,
des: cur.origin_description, des: cur.origin_description,
type: cur.orig_type, type: cur.orig_type,
@ -320,6 +331,7 @@ class Searcher {
return fomatdata; return fomatdata;
} }
/** /**
* 获取tag下的抽奖信息(转发母动态) * 获取tag下的抽奖信息(转发母动态)
* 并初步整理 * 并初步整理
@ -367,6 +379,7 @@ class Searcher {
dyid: o.dynamic_id, dyid: o.dynamic_id,
reserve_id: o.reserve_id, reserve_id: o.reserve_id,
reserve_lottery_text: o.reserve_lottery_text, reserve_lottery_text: o.reserve_lottery_text,
is_charge_lottery: o.is_charge_lottery,
rid: o.rid_str, rid: o.rid_str,
des: o.description, des: o.description,
type: o.type, type: o.type,
@ -377,6 +390,7 @@ class Searcher {
return fomatdata return fomatdata
} }
/** /**
* 从专栏中获取抽奖信息 * 从专栏中获取抽奖信息
* @param {string} key_words * @param {string} key_words
@ -457,6 +471,7 @@ class Searcher {
dyid: o.dynamic_id, dyid: o.dynamic_id,
reserve_id: o.reserve_id, reserve_id: o.reserve_id,
reserve_lottery_text: o.reserve_lottery_text, reserve_lottery_text: o.reserve_lottery_text,
is_charge_lottery: o.is_charge_lottery,
rid: o.rid_str, rid: o.rid_str,
des: o.description, des: o.description,
type: o.type, type: o.type,
@ -548,5 +563,4 @@ class Searcher {
} }
} }
module.exports = { Searcher, parseDynamicCard };
module.exports = { Searcher };

View File

@ -1,4 +1,3 @@
//@ts-check
/** /**
* @typedef {import("http").IncomingHttpHeaders} HttpHeaders 头部信息 * @typedef {import("http").IncomingHttpHeaders} HttpHeaders 头部信息
* *

View File

@ -5,7 +5,7 @@ const util = require('./util');
(async () => { (async () => {
assert(await bili_client.getMyinfo()); assert(await bili_client.getMyinfo());
await util.par_run([ await util.par_run([0, 1, 2, 3, 4], [
async () => { async () => {
assert.equal((await bili_client.getTopRcmd()).length, 10) assert.equal((await bili_client.getTopRcmd()).length, 10)
}, },
@ -32,7 +32,7 @@ const util = require('./util');
assert.notEqual(await bili_client.sendChat("703886913053917267", "t", 17), 1) assert.notEqual(await bili_client.sendChat("703886913053917267", "t", 17), 1)
}, },
async () => { async () => {
// assert(!await bili_client.createDynamic("123")) assert(!await bili_client.createDynamic("1"))
} }
]) ])

17
test/dynamic_card.test.js Normal file
View File

@ -0,0 +1,17 @@
const assert = require('assert');
const bili_client = require("../lib/net/bili");
const searcher = require("../lib/core/searcher");
(async () => {
assert(await bili_client.getMyinfo());
let info = await bili_client.getOneDynamicByDyid("728424890210713624");
assert(searcher.parseDynamicCard(info).is_charge_lottery);
info = await bili_client.getOneDynamicByDyid("728455586333589522");
assert(searcher.parseDynamicCard(info).origin_is_charge_lottery);
console.log("dynamic_card.test ... ok!");
})()

View File

@ -1,8 +1,11 @@
/** /**
* @param {Array<number>} nums
* @param {Array<()=>any>} fns * @param {Array<()=>any>} fns
*/ */
function par_run(fns) { function par_run(nums, fns) {
return Promise.all((fns.map(fn => fn()))) return Promise.all(
nums.map(num => fns[num]())
)
} }
module.exports = { module.exports = {