Compare commits

...
8 Commits
Author SHA1 Message Date
shanmite 136379a3aa docs: 更新CHANGELOG 2021-12-02 19:47:00 +08:00
shanmite 313942adb7 ci: pkg.yml tag_name 2021-12-02 19:40:08 +08:00
shanmite 66efd62d56 feat: 新增设置use_public_blacklist 2021-12-02 19:29:26 +08:00
shanmite d7cf7422f4 feat: 增加粉丝数查询第三方接口 2021-12-02 19:18:51 +08:00
shanmite 094e019063 fix: 二级转发带有效抽奖 2021-12-02 19:07:43 +08:00
shanmite 8de74537f7 fix: description获取不到 2021-12-02 18:51:59 +08:00
shanmite 70c10f247b fix: 更改默认设置key_words blockword 2021-12-02 18:50:41 +08:00
shanmite 2f26a393ca feat: 源uid参与筛选判断
- 重构筛选处关于uid的逻辑
- debug日志详细化
2021-12-02 17:53:49 +08:00
10 changed files with 109 additions and 60 deletions
+2 -7
View File
@@ -6,13 +6,8 @@ on:
- main
paths:
- "lib/**"
- "main.js"
pull_request:
branches:
- main
paths:
- "lib/**"
- "main.js"
- "*.js"
- "*.json"
workflow_dispatch:
jobs:
+5 -9
View File
@@ -1,20 +1,15 @@
name: "Package Node.js project into an executable"
on:
push:
branches:
- main
paths:
- "lib/**"
- "main.js"
pull_request:
branches:
- main
paths:
- "lib/**"
- "main.js"
- "*.js"
- "*.json"
workflow_dispatch:
branches:
- main
jobs:
build_all:
runs-on: ubuntu-latest
@@ -42,4 +37,5 @@ jobs:
with:
file: "dist/*.zip"
delete_file: "dist/*.zip"
tag_name: "v*.*.*"
overwrite: true
+1
View File
@@ -3,6 +3,7 @@ node_modules/
tests/
dyids/
dist/
*.log
package-lock.json
env.js
my_config.js
+15
View File
@@ -1,5 +1,20 @@
<!-- markdownlint-disable MD036 MD024-->
# CHANGELOG
## 主要变化(2.3.8)
* 313942a ci: pkg.yml tag_name
* 66efd62 feat: 新增设置`use_public_blacklist`
* d7cf742 feat: 增加粉丝数查询第三方接口
* 094e019 fix: 二级转发带有效抽奖
* 8de7453 fix: description获取不到
* 70c10f2 fix: 更改默认设置`key_words` `blockword`
* 2f26a39 feat: 源uid参与筛选判断
## 较上一版本变化
* 变更可执行文件
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.3.7...v2.3.8
## 主要变化(2.3.7)
* 50e18e2 feat: 下载更新时有多个版本
* b9c73bd chore: change docker auto build
+48 -33
View File
@@ -188,12 +188,10 @@ class Monitor extends Searcher {
log.info('筛选动态', `开始筛选(${protoLotteryInfo.length})`);
log.debug('未进行筛选的动态信息', protoLotteryInfo);
/** 所有抽奖信息 */
let alllotteryinfo = [];
const
{ set_lottery_info_url, key_words, model, chatmodel, max_create_time, is_imitator, only_followed, at_users, blockword, blacklist } = config,
{ set_lottery_info_url, key_words, model, chatmodel, max_create_time, is_imitator, only_followed, at_users, blockword, blacklist, use_public_blacklist } = config,
now_ts = Date.now() / 1000;
/**
@@ -235,63 +233,79 @@ class Monitor extends Searcher {
}
/* 检查动态是否满足要求 */
await try_for_each(protoLotteryInfo, async function ({
lottery_info_type, is_liked,
uids, uname, dyid, create_time,
ctrl, rid, des, type,
hasOfficialLottery
}) {
await try_for_each(protoLotteryInfo, async function (lottery_info) {
const {
lottery_info_type, is_liked,
uids, uname, dyid, create_time,
ctrl, rid, des, type,
hasOfficialLottery
} = lottery_info;
log.debug('正在筛选的动态信息', lottery_info);
/* 遇到转发过就退出 */
if (is_liked) {
log.info("筛选动态", `已转发(${dyid})`)
log.info("筛选动态", `已转发(https://t.bilibili.com/${dyid})`)
return false
}
/* 超过指定时间退出 */
if (now_ts - create_time > max_create_time * 86400) {
log.info("筛选动态", `过时动态(${dyid})`)
log.info("筛选动态", `过时动态(https://t.bilibili.com/${dyid})`)
return false
}
const
/**判断是转发源动态还是现动态 */
uid = lottery_info_type === 'uid' ? uids[1] : uids[0],
isFollowed = (new RegExp(uid)).test(attentionList),
description = typeof des === 'string' ? des : '',
[m_uid, ori_uid] = uids,
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]
: [m_uid, mIsFollowed],
description = des.split(/\/\/@.*?:/)[0],
needAt = /(?:@|艾特)[^@|(艾特)]*?好友/.test(description),
needTopic = [...new Set(description.match(/(?<=[带加上](?:话题|tag).*)#.+?#|(?<=[带加上])#.+?#(?=话题|tag)/ig) || [])].join(' '),
isRelayDynamic = type === 1,
isTwoLevelDynamic = /\/\/@/.test(description),
has_key_words = key_words.every(it => new RegExp(it).test(description)),
isBlock = new RegExp(blockword.join('|')).test(description),
isLottery =
(is_imitator && lottery_info_type === 'uid' && model !== '00')
|| (hasOfficialLottery && model[0] === '1')
|| (!hasOfficialLottery && model[1] === '1' && !isTwoLevelDynamic && has_key_words),
|| (!hasOfficialLottery && model[1] === '1' && has_key_words),
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("筛选动态", `包含屏蔽词(${dyid})`)
log.info("筛选动态", `包含屏蔽词(https://t.bilibili.com/${dyid})`)
return false
}
/**若勾选只转已关注 */
if (only_followed && !isFollowed) {
log.info("筛选动态", `只转已关注(${dyid})`)
if (only_followed && !mIsFollowed && !oriIsFollowed) {
log.info("筛选动态", `只转已关注(https://t.bilibili.com/${dyid})`)
return false
}
/* 获取黑名单并去重合并 */
const { blacklist: remote_blacklist } = global_var.get("remoteconfig")
, new_blacklist = remote_blacklist
? [...new Set([...blacklist.split(','), ...remote_blacklist.split(',')])].join()
const
{ blacklist: remote_blacklist } = use_public_blacklist === false
? { blacklist: "" }
: global_var.get("remoteconfig"),
/* 获取黑名单并去重合并 */
new_blacklist = remote_blacklist
? [
...new Set([...blacklist.split(','),
...remote_blacklist.split(',')])
].join()
: blacklist;
if ((new RegExp(dyid + '|' + uid)).test(new_blacklist)) {
log.info("筛选动态", `黑名单用户(${dyid})`)
if ((new RegExp(dyid + '|' + m_uid + '|' + ori_uid)).test(new_blacklist)) {
log.info("筛选动态", `公共黑名单用户(https://t.bilibili.com/${dyid})`)
return false
}
@@ -304,8 +318,8 @@ class Monitor extends Searcher {
/**初始化待关注列表 */
onelotteryinfo.uid = []
if (!isFollowed) {
onelotteryinfo.uid.push(uid);
if (!realIsFollowed) {
onelotteryinfo.uid.push(real_uid);
}
onelotteryinfo.dyid = dyid;
@@ -335,12 +349,12 @@ class Monitor extends Searcher {
}
/* 是否是转发的动态 */
if (isRelayDynamic) {
if (isRelayDynamic && real_uid) {
/* 转发内容长度+'//'+'@'+用户名+':'+源内容 */
const addlength = RandomStr.length + 2 + uname.length + 1 + 1;
onelotteryinfo.relay_chat = RandomStr + `//@${uname}:` + des;
new_ctrl.push({
data: String(uid),
data: String(real_uid),
location: RandomStr.length + 2,
length: uname.length + 1,
type: 1
@@ -349,8 +363,9 @@ class Monitor extends Searcher {
item.location += addlength;
return item;
}).forEach(it => new_ctrl.push(it))
if (!(new RegExp(uids[1])).test(attentionList))
onelotteryinfo.uid.push(uids[1]);
if (!oriIsFollowed) {
onelotteryinfo.uid.push(ori_uid);
}
} else {
onelotteryinfo.relay_chat = RandomStr;
}
@@ -372,7 +387,7 @@ class Monitor extends Searcher {
alllotteryinfo.push(onelotteryinfo);
} else {
log.info("筛选动态", `非抽奖动态(${dyid})`)
log.info("筛选动态", `非抽奖动态(https://t.bilibili.com/${dyid})`)
}
})
+8 -2
View File
@@ -75,7 +75,10 @@ function parseDynamicCard(dynamic_detail_card) {
/* 是否有官方抽奖 */
obj.hasOfficialLottery = extension && extension.lott && true;
/* 转发者的描述 后两个分别是视频动态的描述和视频本身的描述*/
obj.description = (item && (item.content || item.description || cardToJson.dynamic || cardToJson.desc)) || '';
obj.description =
(item && (item.content + item.description))
|| (cardToJson.dynamic + cardToJson.desc)
|| '';
if (obj.type === 1) {
const { origin_extension, origin } = cardToJson
, originToJson = strToJson(origin)
@@ -93,7 +96,10 @@ function parseDynamicCard(dynamic_detail_card) {
/* 被转发者的name */
obj.origin_uname = (user && (user.name || user.uname)) || '';
/* 被转发者的描述 */
obj.origin_description = (item && (item.content || item.description || originToJson.dynamic || originToJson.desc)) || '';
obj.origin_description =
(item && (item.content + item.description))
|| (originToJson.dynamic + originToJson.desc)
|| '';
}
return obj
+9 -4
View File
@@ -49,8 +49,8 @@ const config = {
* 符合js正则表达式的字符串
*/
key_words: [
"[抽奖]",
"[转关].*[转关]"
"[抽奖]",
"[转关]"
],
/**
@@ -221,15 +221,20 @@ const config = {
at_users: [['转发抽奖娘', 294887687], ['你的工具人老公', 100680137]],
/**
* - 自动同步 https://gitee.com/shanmite/lottery-notice/raw/master/notice.json
* - 英文逗号分隔 如: 1,2,3
*/
blacklist: '',
/**
* - 自动同步 https://gitee.com/shanmite/lottery-notice/raw/master/notice.json
* - 使用公共黑名单
*/
use_public_blacklist: true,
/**
* 屏蔽词
*/
blockword: ["脚本抽奖", "恭喜", "结果", "抽奖号", "钓鱼", "涨粉"],
blockword: ["脚本", "抽奖号", "钓鱼"],
/**
* 转发评语
+11
View File
@@ -526,6 +526,17 @@ const bili_client = {
query: {
vmid: uid
}
}),
/**
* 线路三
* @param {number} uid
* @returns {Promise<string>}
*/
(uid) => get({
url: "https://tenapi.cn/bilibilifo/",
query: {
uid
}
})
], responseText => {
const res = strToJson(responseText);
+9 -4
View File
@@ -63,8 +63,8 @@ module.exports = Object.freeze({
* 符合js正则表达式的字符串
*/
key_words: [
"[抽奖]",
"[转关].*[转关]"
"[抽奖]",
"[转关]"
],
/**
@@ -235,15 +235,20 @@ module.exports = Object.freeze({
at_users: [['转发抽奖娘', 294887687], ['你的工具人老公', 100680137]],
/**
* - 自动同步 https://gitee.com/shanmite/lottery-notice/raw/master/notice.json
* - 英文逗号分隔 如: 1,2,3
*/
blacklist: '',
/**
* - 自动同步 https://gitee.com/shanmite/lottery-notice/raw/master/notice.json
* - 使用公共黑名单
*/
use_public_blacklist: true,
/**
* 屏蔽词
*/
blockword: ["脚本抽奖", "恭喜", "结果", "抽奖号", "钓鱼", "涨粉"],
blockword: ["脚本", "抽奖号", "钓鱼"],
/**
* 转发评语
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "lottery-auto-script",
"version": "2.3.7",
"version": "2.3.8",
"description": "自动参与B站动态抽奖",
"main": "main.js",
"scripts": {