diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 943f566..cfdf409 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -6,13 +6,8 @@ on: - main paths: - "lib/**" - - "main.js" - pull_request: - branches: - - main - paths: - - "lib/**" - - "main.js" + - "*.js" + - "*.json" workflow_dispatch: jobs: diff --git a/.github/workflows/pkg.yml b/.github/workflows/pkg.yml index 0658138..4cfd16b 100644 --- a/.github/workflows/pkg.yml +++ b/.github/workflows/pkg.yml @@ -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 diff --git a/.gitignore b/.gitignore index f11e3a5..5a371d2 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ node_modules/ tests/ dyids/ dist/ +*.log package-lock.json env.js my_config.js \ No newline at end of file diff --git a/lib/core/monitor.js b/lib/core/monitor.js index 312f3b5..fe9cf91 100644 --- a/lib/core/monitor.js +++ b/lib/core/monitor.js @@ -188,8 +188,6 @@ class Monitor extends Searcher { log.info('筛选动态', `开始筛选(${protoLotteryInfo.length})`); - log.debug('未进行筛选的动态信息', protoLotteryInfo); - /** 所有抽奖信息 */ let alllotteryinfo = []; const @@ -235,28 +233,36 @@ 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), + [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 = typeof des === 'string' ? des : '', needAt = /(?:@|艾特)[^@|(艾特)]*?好友/.test(description), needTopic = [...new Set(description.match(/(?<=[带加上](?:话题|tag).*)#.+?#|(?<=[带加上])#.+?#(?=话题|tag)/ig) || [])].join(' '), @@ -273,25 +279,32 @@ class Monitor extends Searcher { || (hasOfficialLottery && chatmodel[0] === '1') || (!hasOfficialLottery && chatmodel[1] === '1'); + log.debug("筛选动态", { real_uid, mIsFollowed, oriIsFollowed, realIsFollowed, needAt, needTopic, isRelayDynamic, isTwoLevelDynamic, key_words, has_key_words, 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 } = 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 +317,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 +348,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 +362,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 +386,7 @@ class Monitor extends Searcher { alllotteryinfo.push(onelotteryinfo); } else { - log.info("筛选动态", `非抽奖动态(${dyid})`) + log.info("筛选动态", `非抽奖动态(https://t.bilibili.com/${dyid})`) } })