Compare commits

...
11 Commits
Author SHA1 Message Date
shanmite 4bbbfc89a7 docs: 更新CHANGELOG 2021-12-12 16:39:45 +08:00
shanmite aba17ed0ad feat: 提示关键词修改建议 2021-12-12 16:32:49 +08:00
shanmite 5a23043466 feat: 只通过是否点赞判断时点赞 2021-12-12 16:02:01 +08:00
shanmite 76f715248d fix: 黑名单匹配(#90)
子串不参与匹配
2021-12-12 15:57:48 +08:00
shanmite 0d4185d02a fix(Searcher): getLotteryInfoByUID(#89)
是否获取点赞信息
2021-12-12 15:04:37 +08:00
shanmite 2ff4ec812b docs: 更新CHANGELOG 2021-12-11 18:24:38 +08:00
shanmite 20c423fc09 fix: "公共黑名单"显示错误(#87) 2021-12-11 18:21:37 +08:00
shanmite 6851f29f75 fix: 描述中出现undefined(#88) 2021-12-11 18:18:43 +08:00
shanmite 77d198bec5 docs: 更新CHANGELOG 2021-12-10 15:21:26 +08:00
shanmite 0ba6acec31 feat: check_if_duplicated可同时使用多种方式 2021-12-10 15:16:17 +08:00
shanmite dd994263b9 fix: 只转已关注功能失效 2021-12-10 14:50:41 +08:00
7 changed files with 110 additions and 75 deletions
+20
View File
@@ -1,5 +1,25 @@
<!-- markdownlint-disable MD036 MD024-->
# CHANGELOG
## 主要变化(2.4.3)
* aba17ed feat: 提示关键词修改建议
* 5a23043 feat: 只通过是否点赞判断时点赞
* 76f7152 fix: 黑名单匹配(#90)
* 0d4185d fix(Searcher): getLotteryInfoByUID(#89)
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
## 主要变化(2.4.2)
* 20c423f fix: "公共黑名单"显示错误(#87)
* 6851f29 fix: 描述中出现undefined(#88)
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
## 主要变化(2.4.1)
* 0ba6ace feat: check_if_duplicated可同时使用多种方式
* dd99426 fix: 只转已关注功能失效
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
## 主要变化(2.4.0)
* 01562b6 ci: verison升级时小版本号归0
* 90ac347 docs: 更新README
+48 -33
View File
@@ -256,13 +256,16 @@ class Monitor extends Searcher {
log.info('筛选动态', `去重后(${protoLotteryInfo.length})`);
/**并发查询dyid */
await Promise.all(
[...dyids_map.keys()]
.map(it => d_storage
.searchDyid(it)
.then(hasIt => dyids_map.set(it, hasIt))
)
)
if (check_if_duplicated === 1 || check_if_duplicated === 2) {
await Promise.all(
[...dyids_map.keys()]
.map(it => d_storage
.searchDyid(it)
.then(hasIt => dyids_map.set(it, hasIt))
)
)
log.info('筛选动态', `并发查询本地dyid完毕`);
}
if (lottery_param[0] !== "APIs" && set_lottery_info_url && protoLotteryInfo.length) {
log.info("上传抽奖信息", "开始")
@@ -299,9 +302,9 @@ class Monitor extends Searcher {
/* 遇到转发过就退出 */
if (
(!check_if_duplicated
((!check_if_duplicated || check_if_duplicated === 2)
&& is_liked)
|| (check_if_duplicated === 1
|| ((check_if_duplicated === 1 || check_if_duplicated === 2)
&& dyids_map.get(dyid))
) {
log.info("筛选动态", `已转发(https://t.bilibili.com/${dyid})`)
@@ -316,8 +319,8 @@ class Monitor extends Searcher {
const
[m_uid, ori_uid] = uids,
mIsFollowed = m_uid && (new RegExp(m_uid)).test(attentionList),
oriIsFollowed = ori_uid && (new RegExp(ori_uid)).test(attentionList),
mIsFollowed = !m_uid || (new RegExp(m_uid)).test(attentionList),
oriIsFollowed = !ori_uid || (new RegExp(ori_uid)).test(attentionList),
/**判断是转发源动态还是现动态 实际发奖人*/
[real_uid, realIsFollowed] = lottery_info_type === 'uid'
? [ori_uid, oriIsFollowed]
@@ -335,23 +338,7 @@ class Monitor extends Searcher {
isSendChat =
(is_imitator && lottery_info_type === 'uid' && chatmodel !== '00')
|| (hasOfficialLottery && chatmodel[0] === '1')
|| (!hasOfficialLottery && chatmodel[1] === '1');
log.debug("筛选动态", { real_uid, mIsFollowed, oriIsFollowed, realIsFollowed, needAt, needTopic, isRelayDynamic, key_words, has_key_words, blockword, isBlock, isLottery, isSendChat })
/**屏蔽词 */
if (isBlock) {
log.info("筛选动态", `包含屏蔽词(https://t.bilibili.com/${dyid})`)
return false
}
/**若勾选只转已关注 */
if (only_followed && !mIsFollowed && !oriIsFollowed) {
log.info("筛选动态", `只转已关注(https://t.bilibili.com/${dyid})`)
return false
}
const
|| (!hasOfficialLottery && chatmodel[1] === '1'),
{ blacklist: remote_blacklist } = use_public_blacklist === false
? { blacklist: "" }
: global_var.get("remoteconfig"),
@@ -360,14 +347,42 @@ class Monitor extends Searcher {
? [
...new Set([...blacklist.split(','),
...remote_blacklist.split(',')])
].join()
: blacklist;
]
: blacklist.split(','),
keys = [dyid, m_uid, ori_uid];
if ((new RegExp(dyid + '|' + m_uid + '|' + ori_uid)).test(new_blacklist)) {
log.info("筛选动态", `公共黑名单用户(https://t.bilibili.com/${dyid})`)
log.debug("筛选动态", { real_uid, mIsFollowed, oriIsFollowed, realIsFollowed, needAt, needTopic, isRelayDynamic, key_words, has_key_words, blockword, isBlock, isLottery, isSendChat })
if (!has_key_words && description) {
log.warn("筛选动态", `无关键词动态的描述: ${description}\n\n考虑是否修改设置key_words:\n${key_words.join('\n')}`)
}
/**屏蔽词 */
if (isBlock) {
log.info("筛选动态", `包含屏蔽词(https://t.bilibili.com/${dyid})`)
return false
}
/**若勾选只转已关注 */
if (only_followed
&& (!mIsFollowed || !oriIsFollowed)
) {
log.info("筛选动态", `只转已关注(https://t.bilibili.com/${dyid})`)
return false
}
if (
new_blacklist.some(id => keys.some(key => {
if (key === id + '') {
log.info("筛选动态", `黑名单匹配(${id})(https://t.bilibili.com/${dyid})`)
return true
} else {
return false
}
}))
) {
return false
}
if (isLottery) {
let onelotteryinfo = {};
@@ -408,7 +423,7 @@ class Monitor extends Searcher {
}
/* 是否是转发的动态 */
if (isRelayDynamic && real_uid) {
if (isRelayDynamic) {
/* 转发内容长度+'//'+'@'+用户名+':'+源内容 */
const addlength = RandomStr.length + 2 + uname.length + 1 + 1;
onelotteryinfo.relay_chat = RandomStr + `//@${uname}:` + des;
+31 -34
View File
@@ -75,10 +75,10 @@ function parseDynamicCard(dynamic_detail_card) {
obj.ctrl = (extend_json && strToJson(extend_json).ctrl) || [];
/* 是否有官方抽奖 */
obj.hasOfficialLottery = extension && extension.lott && true;
/* 转发者的描述 后两个分别是视频动态的描述和视频本身的描述*/
/* 转发者的描述 纯文字内容 图片动态描述 后两个分别是视频动态的描述和视频本身的描述*/
obj.description =
(item && (item.content + item.description))
|| (cardToJson.dynamic + cardToJson.desc)
(item && (item.content || '' + item.description || ''))
|| (cardToJson.dynamic || '' + cardToJson.desc || '')
|| '';
if (obj.type === 1) {
const { origin_extension, origin } = cardToJson
@@ -98,8 +98,8 @@ function parseDynamicCard(dynamic_detail_card) {
obj.origin_uname = (user && (user.name || user.uname)) || '';
/* 被转发者的描述 */
obj.origin_description =
(item && (item.content + item.description))
|| (originToJson.dynamic + originToJson.desc)
(item && (item.content || '' + item.description || ''))
|| (originToJson.dynamic || '' + originToJson.desc || '')
|| '';
}
@@ -241,38 +241,35 @@ class Searcher {
}
})
.reduce(async (pre, cur) => {
const results = await pre
, { origin_dynamic_id } = cur;
const card = await bili.getOneDynamicByDyid(origin_dynamic_id)
if (card) {
await utils.delay(get_dynamic_detail_wait)
const { is_liked } = parseDynamicCard(card)
let
results = await pre,
{ origin_dynamic_id } = cur,
is_liked = false;
if (!check_if_duplicated || check_if_duplicated === 2) {
const card = await bili.getOneDynamicByDyid(origin_dynamic_id)
log.info('获取动态', `查看源动态(${origin_dynamic_id})是否点赞 (${length--})`)
if (is_liked) {
log.info('获取动态', `动态(${origin_dynamic_id})已转发过`)
} else {
return [...results, {
lottery_info_type: 'uid',
create_time: cur.origin_create_time,
is_liked,
uids: [cur.uid, cur.origin_uid],
uname: cur.origin_uname,
ctrl: [],
dyid: cur.origin_dynamic_id,
rid: cur.origin_rid_str,
des: cur.origin_description,
type: cur.orig_type,
hasOfficialLottery: cur.origin_hasOfficialLottery
}]
if (card) {
({ is_liked } = parseDynamicCard(card))
}
await utils.delay(get_dynamic_detail_wait)
}
return results
results.push({
lottery_info_type: 'uid',
create_time: cur.origin_create_time,
is_liked,
uids: [cur.uid, cur.origin_uid],
uname: cur.origin_uname,
ctrl: [],
dyid: cur.origin_dynamic_id,
rid: cur.origin_rid_str,
des: cur.origin_description,
type: cur.orig_type,
hasOfficialLottery: cur.origin_hasOfficialLottery
})
return results
}, Promise.resolve([]))
log.info('获取动态', `成功获取用户${UID}的动态信息`);
@@ -380,9 +377,9 @@ class Searcher {
, { is_liked } = parsed_card;
if (
(!check_if_duplicated
((!check_if_duplicated || check_if_duplicated === 2)
&& is_liked)
|| (check_if_duplicated === 1
|| ((check_if_duplicated === 1 || check_if_duplicated === 2)
&& await d_storage.searchDyid(dyid))
) {
log.info('获取动态', `动态(${dyid})已转发过`)
@@ -454,7 +451,7 @@ class Searcher {
let results = await pre
, { dyid } = cur;
if (!check_if_duplicated) {
if (!check_if_duplicated || check_if_duplicated === 2) {
log.info('获取动态', `查看动态(${dyid})是否点赞 (${length--})`)
const card = await bili.getOneDynamicByDyid(dyid)
+4 -3
View File
@@ -49,8 +49,8 @@ const config = {
* 符合js正则表达式的字符串
*/
key_words: [
"[抽奖送]",
"[转关评]"
"[抽奖送揪]|福利",
"[转关评粉]|参与"
],
/**
@@ -74,8 +74,9 @@ const config = {
* - 不检查 -1
* - 通过是否点赞判断 0
* - 检索本地dyids文件 1
* - 通过是否点赞判断+检索本地dyids文件 2
*/
check_if_duplicated: 0,
check_if_duplicated: 1,
/**
* - 动态创建时间
+5 -3
View File
@@ -63,8 +63,8 @@ module.exports = Object.freeze({
* 符合js正则表达式的字符串
*/
key_words: [
"[抽奖送]",
"[转关评]"
"[抽奖送揪]|福利",
"[转关评粉]|参与"
],
/**
@@ -88,8 +88,9 @@ module.exports = Object.freeze({
* - 不检查 -1
* - 通过是否点赞判断 0
* - 检索本地dyids文件 1
* - 通过是否点赞判断+检索本地dyids文件 2
*/
check_if_duplicated: 0,
check_if_duplicated: 1,
/**
* - 动态创建时间
@@ -243,6 +244,7 @@ module.exports = Object.freeze({
at_users: [['转发抽奖娘', 294887687], ['你的工具人老公', 100680137]],
/**
* - 动态dyid或UID
* - 英文逗号分隔 如: 1,2,3
*/
blacklist: '',
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "lottery-auto-script",
"version": "2.4.0",
"version": "2.4.3",
"description": "自动参与B站动态抽奖",
"main": "main.js",
"scripts": {
+1 -1
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# version: <major.minor.patch>
level=minor
level=patch
npm version $level \
--no-commit-hooks \