mirror of
https://github.com/shanmiteko/LotteryAutoScript.git
synced 2026-07-22 21:13:47 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
922dd989bc | ||
|
|
c486abf0ed | ||
|
|
4bbbfc89a7 | ||
|
|
aba17ed0ad | ||
|
|
5a23043466 | ||
|
|
76f715248d | ||
|
|
0d4185d02a | ||
|
|
2ff4ec812b | ||
|
|
20c423fc09 | ||
|
|
6851f29f75 | ||
|
|
77d198bec5 | ||
|
|
0ba6acec31 | ||
|
|
dd994263b9 | ||
|
|
12847d7cfc | ||
|
|
01562b6ee0 | ||
|
|
90ac347ff2 | ||
|
|
3cf3939b49 | ||
|
|
d0a8aa9169 | ||
|
|
10db52f9ae | ||
|
|
f9ebbb30eb | ||
|
|
b36c555c13 | ||
|
|
7338e09caf | ||
|
|
80a54e87f8 | ||
|
|
1a6291471a | ||
|
|
449c8d9272 | ||
|
|
136379a3aa | ||
|
|
313942adb7 | ||
|
|
66efd62d56 | ||
|
|
d7cf7422f4 | ||
|
|
094e019063 | ||
|
|
8de74537f7 | ||
|
|
70c10f247b | ||
|
|
2f26a393ca |
@@ -6,13 +6,8 @@ on:
|
||||
- main
|
||||
paths:
|
||||
- "lib/**"
|
||||
- "main.js"
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "lib/**"
|
||||
- "main.js"
|
||||
- "*.js"
|
||||
- "*.json"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
|
||||
@@ -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: "v2"
|
||||
overwrite: true
|
||||
|
||||
@@ -3,6 +3,7 @@ node_modules/
|
||||
tests/
|
||||
dyids/
|
||||
dist/
|
||||
*.log
|
||||
package-lock.json
|
||||
env.js
|
||||
my_config.js
|
||||
@@ -1,5 +1,63 @@
|
||||
<!-- markdownlint-disable MD036 MD024-->
|
||||
# CHANGELOG
|
||||
## 主要变化(2.4.4)
|
||||
* c486abf fix: 黑名单不起作用(#92)
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(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
|
||||
* 3cf3939 feat: 新增设置`check_if_duplicated`
|
||||
* d0a8aa9 feat: metainfo显示nodejs版本号
|
||||
* 10db52f fix: 完善错误延时重试(#82)
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.3.9)
|
||||
* b36c555 ci: auto gen changelog
|
||||
* 7338e09 feat: 更新`notice_key_words`
|
||||
* 80a54e8 ci: `*.exe` `latest_version0`
|
||||
* 1a62914 feat: 新增设置`is_outof_maxfollow`(#80)
|
||||
* 449c8d9 docs: update README
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(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
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
- [Windows](#windows)
|
||||
- [Linux](#linux)
|
||||
- [Docker](#docker)
|
||||
- [防重复转发](#防重复转发)
|
||||
- [防重复转发(可选)](#防重复转发可选)
|
||||
- [检测中奖](#检测中奖)
|
||||
- [检测未读信息, 已读未读信息](#检测未读信息-已读未读信息)
|
||||
- [中奖推送(可选)](#中奖推送可选)
|
||||
@@ -230,6 +230,8 @@ $ tree
|
||||
└── start.sh
|
||||
```
|
||||
|
||||
[](https://asciinema.org/a/453237)
|
||||
|
||||
3.更新
|
||||
|
||||
进入lottery上一级目录
|
||||
@@ -238,13 +240,11 @@ $ tree
|
||||
|
||||
----------------------------------------
|
||||
|
||||
## 防重复转发
|
||||
## 防重复转发(可选)
|
||||
|
||||
~~存储在专栏草稿~~
|
||||
- 脚本将转发过的动态和被过滤的动态都写入`dyids/dyid*.txt`文件中
|
||||
|
||||
~~脚本将转发过的动态和被过滤的动态都写入`dyids/dyid*.txt`文件中~~
|
||||
|
||||
是否点赞
|
||||
- 是否点赞
|
||||
|
||||
----------------------------------------
|
||||
|
||||
|
||||
+227
-112
@@ -1,4 +1,4 @@
|
||||
const { log, hasEnv, shuffle, getRandomOne, delay, try_for_each } = require('../utils');
|
||||
const { log, hasEnv, shuffle, getRandomOne, delay, try_for_each, retryfn } = require('../utils');
|
||||
const { send } = require('../net/http');
|
||||
const bili = require('../net/bili');
|
||||
const { sendNotify } = require('../helper/notify');
|
||||
@@ -7,6 +7,7 @@ const { randomDynamic } = require('../helper/randomDynamic')
|
||||
const { Searcher } = require('./searcher');
|
||||
const global_var = require("../data/global_var");
|
||||
const config = require("../data/config");
|
||||
const d_storage = require('../helper/d_storage');
|
||||
|
||||
/**
|
||||
* 监视器
|
||||
@@ -49,13 +50,16 @@ class Monitor extends Searcher {
|
||||
case 0:
|
||||
event_bus.emit('Turn_on_the_Monitor')
|
||||
break;
|
||||
case 11:
|
||||
case 1001:
|
||||
event_bus.emit('Turn_off_the_Monitor', '评论失败')
|
||||
break
|
||||
case 21:
|
||||
break;
|
||||
case 2001:
|
||||
event_bus.emit('Turn_off_the_Monitor', '关注出错')
|
||||
break
|
||||
case 22:
|
||||
break;
|
||||
case 3001:
|
||||
event_bus.emit('Turn_off_the_Monitor', '分区移动出错')
|
||||
break;
|
||||
case 2004:
|
||||
log.warn('账号异常', `UID(${global_var.get('myUID')})异常号只会对部分UP出现关注异常`)
|
||||
if (!config.is_exception) {
|
||||
await sendNotify('[动态抽奖]账号异常通知', `UID: ${global_var.get('myUID')}\n\n异常号只会对部分UP出现关注异常\n\n可在设置中令is_exception为true关闭此推送`)
|
||||
@@ -63,17 +67,26 @@ class Monitor extends Searcher {
|
||||
config.is_exception = true;
|
||||
event_bus.emit('Turn_on_the_Monitor')
|
||||
break
|
||||
case 31:
|
||||
case 2005:
|
||||
log.warn('关注已达上限', `UID(${global_var.get('myUID')})关注已达上限,已临时进入只转已关注模式`)
|
||||
if (!config.is_outof_maxfollow) {
|
||||
await sendNotify('[动态抽奖]关注已达上限', `UID: ${global_var.get('myUID')}\n\n关注已达上限,已临时进入只转已关注模式\n\n可在设置中令is_outof_maxfollow为true关闭此推送`)
|
||||
}
|
||||
config.is_outof_maxfollow = true;
|
||||
config.only_followed = true;
|
||||
event_bus.emit('Turn_on_the_Monitor')
|
||||
break
|
||||
case 5001:
|
||||
event_bus.emit('Turn_off_the_Monitor', '转发失败')
|
||||
break
|
||||
case 41:
|
||||
case 6001:
|
||||
event_bus.emit('Turn_off_the_Monitor', '获取开奖时间失败')
|
||||
break
|
||||
case 51:
|
||||
case 7001:
|
||||
event_bus.emit('Turn_off_the_Monitor', '获取关注数失败')
|
||||
break
|
||||
default:
|
||||
event_bus.emit('Turn_off_the_Monitor', '未知错误')
|
||||
event_bus.emit('Turn_off_the_Monitor', '??? 未知错误')
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -89,35 +102,49 @@ class Monitor extends Searcher {
|
||||
log.info('筛选动态', `筛选完毕(${len})`);
|
||||
|
||||
if (len) {
|
||||
let is_exception = false;
|
||||
for (const [index, Lottery] of shuffle(allLottery).entries()) {
|
||||
let
|
||||
is_exception = 0,
|
||||
is_outof_maxfollow = 0;
|
||||
for (const [index, lottery] of shuffle(allLottery).entries()) {
|
||||
let status = 0;
|
||||
|
||||
if (Lottery.isOfficialLottery) {
|
||||
let { ts } = await bili.getLotteryNotice(Lottery.dyid);
|
||||
if (
|
||||
is_outof_maxfollow
|
||||
&& lottery.uid.length
|
||||
&& (new RegExp(lottery.uid.join('|'))).test(this.attentionList)
|
||||
) {
|
||||
log.info('过滤', `已关注(${lottery.uid.join(',')})`)
|
||||
continue
|
||||
}
|
||||
|
||||
if (lottery.isOfficialLottery) {
|
||||
let { ts } = await bili.getLotteryNotice(lottery.dyid);
|
||||
const ts_10 = Date.now() / 1000;
|
||||
if (ts < 0) {
|
||||
return 41
|
||||
return 6001
|
||||
}
|
||||
if (ts < ts_10) {
|
||||
log.info('过滤', '已过开奖时间')
|
||||
d_storage.updateDyid(lottery.dyid)
|
||||
await delay(filter_wait)
|
||||
continue
|
||||
}
|
||||
if (ts > ts_10 + config.maxday * 86400) {
|
||||
log.info('过滤', '超过指定开奖时间')
|
||||
d_storage.updateDyid(lottery.dyid)
|
||||
await delay(filter_wait)
|
||||
continue
|
||||
}
|
||||
} else if (Lottery.uid[0]) {
|
||||
} else if (lottery.uid[0]) {
|
||||
const { minfollower } = config
|
||||
if (minfollower > 0) {
|
||||
const followerNum = await bili.getUserInfo(Lottery.uid[0]);
|
||||
const followerNum = await bili.getUserInfo(lottery.uid[0]);
|
||||
if (followerNum < 0) {
|
||||
return 51
|
||||
return 7001
|
||||
}
|
||||
if (followerNum < minfollower) {
|
||||
log.info('过滤', `粉丝数(${followerNum})小于指定数量`)
|
||||
d_storage.updateDyid(lottery.dyid)
|
||||
await delay(filter_wait)
|
||||
continue
|
||||
}
|
||||
@@ -135,27 +162,45 @@ class Monitor extends Searcher {
|
||||
randomDynamic(number)
|
||||
}
|
||||
|
||||
status = await this.go(Lottery)
|
||||
status = await this.go(lottery)
|
||||
switch (status) {
|
||||
case 0:
|
||||
case 9:
|
||||
case 19:
|
||||
case 1002:
|
||||
case 1003:
|
||||
case 1004:
|
||||
case 1005:
|
||||
case 1006:
|
||||
case 1007:
|
||||
case 2002:
|
||||
case 2003:
|
||||
case 4001:
|
||||
case 4002:
|
||||
case 4003:
|
||||
case 5002:
|
||||
case 5003:
|
||||
case 5004:
|
||||
break;
|
||||
case 22:
|
||||
is_exception = true
|
||||
case 2004:
|
||||
is_exception = 2004
|
||||
break;
|
||||
default:
|
||||
case 2005:
|
||||
is_outof_maxfollow = 2005
|
||||
break;
|
||||
case 1001:
|
||||
case 2001:
|
||||
case 3001:
|
||||
case 5001:
|
||||
return status
|
||||
}
|
||||
|
||||
d_storage.updateDyid(lottery.dyid)
|
||||
|
||||
await delay(wait * (Math.random() + 0.5));
|
||||
}
|
||||
log.info('抽奖', '开始转发下一组动态');
|
||||
if (is_exception) {
|
||||
return 22
|
||||
} else {
|
||||
return 0
|
||||
}
|
||||
return is_exception
|
||||
|| is_outof_maxfollow
|
||||
|| 0
|
||||
} else {
|
||||
log.info('抽奖', '无未转发抽奖');
|
||||
return 0
|
||||
@@ -188,12 +233,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,
|
||||
{ check_if_duplicated, 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;
|
||||
|
||||
/**
|
||||
@@ -212,6 +255,18 @@ class Monitor extends Searcher {
|
||||
|
||||
log.info('筛选动态', `去重后(${protoLotteryInfo.length})`);
|
||||
|
||||
/**并发查询dyid */
|
||||
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("上传抽奖信息", "开始")
|
||||
await new Promise((resolve) => {
|
||||
@@ -235,67 +290,103 @@ 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})`)
|
||||
if (
|
||||
((!check_if_duplicated || check_if_duplicated === 2)
|
||||
&& is_liked)
|
||||
|| ((check_if_duplicated === 1 || check_if_duplicated === 2)
|
||||
&& dyids_map.get(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');
|
||||
|| (!hasOfficialLottery && chatmodel[1] === '1'),
|
||||
{ blacklist: remote_blacklist } = use_public_blacklist === false
|
||||
? { blacklist: "" }
|
||||
: global_var.get("remoteconfig"),
|
||||
/**
|
||||
* 获取黑名单并去重合并
|
||||
* @type {string[]}
|
||||
*/
|
||||
new_blacklist = remote_blacklist
|
||||
? [
|
||||
...new Set([...blacklist.split(','),
|
||||
...remote_blacklist.split(',')])
|
||||
]
|
||||
: blacklist.split(','),
|
||||
keys = [dyid, m_uid, ori_uid];
|
||||
|
||||
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("筛选动态", `包含屏蔽词(${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()
|
||||
: blacklist;
|
||||
if ((new RegExp(dyid + '|' + uid)).test(new_blacklist)) {
|
||||
log.info("筛选动态", `黑名单用户(${dyid})`)
|
||||
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 = {};
|
||||
|
||||
@@ -304,8 +395,8 @@ class Monitor extends Searcher {
|
||||
/**初始化待关注列表 */
|
||||
onelotteryinfo.uid = []
|
||||
|
||||
if (!isFollowed) {
|
||||
onelotteryinfo.uid.push(uid);
|
||||
if (!realIsFollowed) {
|
||||
onelotteryinfo.uid.push(real_uid);
|
||||
}
|
||||
|
||||
onelotteryinfo.dyid = dyid;
|
||||
@@ -340,7 +431,7 @@ class Monitor extends Searcher {
|
||||
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 +440,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 +464,7 @@ class Monitor extends Searcher {
|
||||
|
||||
alllotteryinfo.push(onelotteryinfo);
|
||||
} else {
|
||||
log.info("筛选动态", `非抽奖动态(${dyid})`)
|
||||
log.info("筛选动态", `非抽奖动态(https://t.bilibili.com/${dyid})`)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -382,13 +474,27 @@ class Monitor extends Searcher {
|
||||
* 关注转发评论
|
||||
* @param {LotteryOptions} option
|
||||
* @returns {Promise<number>}
|
||||
* 0 - 成功
|
||||
* 9 - 评论黑名单/评论区关闭/动态删除
|
||||
* 11 - 评论错误
|
||||
* 19 - 关注黑名单
|
||||
* 21 - 关注错误
|
||||
* 22 - 关注异常
|
||||
* 31 - 转发失败
|
||||
* - 成功 0
|
||||
* - 评论 未知错误 1001
|
||||
* - 评论 原动态已删除 1002
|
||||
* - 评论 评论区已关闭 1003
|
||||
* - 评论 需要输入验证码 1004
|
||||
* - 评论 已被对方拉入黑名单 1005
|
||||
* - 评论 黑名单用户无法互动 1006
|
||||
* - 评论 UP主已关闭评论区 1007
|
||||
* - 关注 未知错误 2001
|
||||
* - 关注 您已被对方拉入黑名单 2002
|
||||
* - 关注 黑名单用户无法关注 2003
|
||||
* - 关注 账号异常 2004
|
||||
* - 关注 关注已达上限 2005
|
||||
* - 分区 移动失败 3001
|
||||
* - 点赞 未知错误 4001
|
||||
* - 点赞 点赞异常 4002
|
||||
* - 点赞 点赞频繁 4003
|
||||
* - 转发 未知错误 5001
|
||||
* - 转发 该动态不能转发分享 5002
|
||||
* - 转发 请求数据发生错误,请刷新或稍后重试 5003
|
||||
* - 转发 操作太频繁了,请稍后重试 5004
|
||||
*/
|
||||
async go(option) {
|
||||
log.debug('正在转发的动态信息', option);
|
||||
@@ -397,63 +503,72 @@ class Monitor extends Searcher {
|
||||
return 0
|
||||
}
|
||||
|
||||
const { uid, dyid, chat_type, rid, relay_chat, ctrl } = option;
|
||||
let status = 0
|
||||
const
|
||||
{ uid, dyid, chat_type, rid, relay_chat, ctrl } = option,
|
||||
{ chat, check_if_duplicated } = config;
|
||||
|
||||
/* 评论 */
|
||||
if (rid && chat_type) {
|
||||
let status = 0
|
||||
const
|
||||
{ chat } = config,
|
||||
retry = [...new Array(5).keys()],
|
||||
max_retry_times = retry.length;
|
||||
await try_for_each(retry, async (times) => {
|
||||
status = await bili.sendChat(rid, getRandomOne(chat), chat_type)
|
||||
switch (status) {
|
||||
case 0:
|
||||
return true
|
||||
case -1:
|
||||
log.warn('抽奖信息', `uid: ${uid},dyid: ${dyid}`)
|
||||
return true
|
||||
default:
|
||||
log.error('抽奖信息', `uid: ${uid},dyid: ${dyid}`)
|
||||
log.info('自动评论', `将在 ${times + 1} 分钟后再次发送评论(${times + 1}/${max_retry_times})`)
|
||||
await delay(60 * 1000 * (times + 1))
|
||||
return false
|
||||
}
|
||||
})
|
||||
if (status) return 10 + status;
|
||||
|
||||
status = await retryfn(
|
||||
5,
|
||||
[1, 4],
|
||||
() => bili.sendChat(rid, getRandomOne(chat), chat_type)
|
||||
)
|
||||
|
||||
if (status) {
|
||||
log.warn("抽奖信息", `dyid: ${dyid}, rid: ${rid}, chat_type: ${chat_type}`)
|
||||
return 1000 + status
|
||||
}
|
||||
}
|
||||
|
||||
/* 关注 */
|
||||
if (uid.length) {
|
||||
let status = 0
|
||||
await try_for_each(uid, async (u) => {
|
||||
status = await bili.autoAttention(u)
|
||||
switch (status) {
|
||||
case 0:
|
||||
if (await bili.movePartition(u, this.tagid)) {
|
||||
log.error('抽奖信息', `uid: ${u},dyid: ${dyid}`)
|
||||
}
|
||||
return false
|
||||
case -1:
|
||||
case 2:
|
||||
log.warn('抽奖信息', `uid: ${u},dyid: ${dyid}`)
|
||||
return true
|
||||
default:
|
||||
log.error('抽奖信息', `uid: ${u},dyid: ${dyid}`)
|
||||
return true
|
||||
if (status) {
|
||||
log.warn("抽奖信息", `dyid: ${dyid}, uid: ${u}`)
|
||||
return true
|
||||
} else if (await bili.movePartition(u, this.tagid)) {
|
||||
log.warn("抽奖信息", `dyid: ${dyid}, uid: ${u} tagid: ${this.tagid}`)
|
||||
/* 3000系错误 */
|
||||
status = 1001
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
if (status) return 20 + status
|
||||
if (status) return 2000 + status
|
||||
}
|
||||
|
||||
/* 点赞 */
|
||||
await bili.autolike(dyid)
|
||||
if (!check_if_duplicated) {
|
||||
status = await retryfn(
|
||||
5,
|
||||
[1, 2, 3],
|
||||
() => bili.autolike(dyid)
|
||||
)
|
||||
|
||||
if (status) {
|
||||
log.warn("抽奖信息", `dyid: ${dyid}`)
|
||||
return 4000 + status
|
||||
}
|
||||
}
|
||||
|
||||
/* 转发 */
|
||||
if (await bili.autoRelay(global_var.get("myUID"), dyid, relay_chat, ctrl)) return 31;
|
||||
status = await retryfn(
|
||||
5,
|
||||
[1, 3, 4],
|
||||
() => bili.autoRelay(global_var.get("myUID"), dyid, relay_chat, ctrl)
|
||||
)
|
||||
|
||||
return 0
|
||||
if (status) {
|
||||
log.warn("抽奖信息", `dyid: ${dyid}`)
|
||||
return 5000 + status
|
||||
}
|
||||
|
||||
return status
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+58
-45
@@ -1,7 +1,8 @@
|
||||
const utils = require('../utils');
|
||||
const bili = require('../net/bili');
|
||||
const { send } = require("../net/http");
|
||||
const { article_scan_page, article_create_time, not_check_article, get_dynamic_detail_wait, uid_scan_page, search_wait, tag_scan_page } = require("../data/config");
|
||||
const { check_if_duplicated, article_scan_page, article_create_time, not_check_article, get_dynamic_detail_wait, uid_scan_page, search_wait, tag_scan_page } = require("../data/config");
|
||||
const d_storage = require("../helper/d_storage")
|
||||
|
||||
const { log } = utils
|
||||
|
||||
@@ -74,8 +75,11 @@ 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)) || '';
|
||||
/* 转发者的描述 纯文字内容 图片动态描述 后两个分别是视频动态的描述和视频本身的描述*/
|
||||
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 +97,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
|
||||
@@ -234,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}的动态信息`);
|
||||
@@ -363,6 +367,7 @@ class Searcher {
|
||||
for (const dyid of dyids_set) {
|
||||
if (dyid.length === utils.dyid_length) {
|
||||
|
||||
log.info('获取动态', `查看专栏中所提及动态(${dyid}) (${length--})`)
|
||||
const card = await bili.getOneDynamicByDyid(dyid)
|
||||
|
||||
if (card) {
|
||||
@@ -371,8 +376,12 @@ class Searcher {
|
||||
const parsed_card = parseDynamicCard(card)
|
||||
, { is_liked } = parsed_card;
|
||||
|
||||
log.info('获取动态', `查看专栏中所提及动态(${dyid})是否点赞 (${length--})`)
|
||||
if (is_liked) {
|
||||
if (
|
||||
((!check_if_duplicated || check_if_duplicated === 2)
|
||||
&& is_liked)
|
||||
|| ((check_if_duplicated === 1 || check_if_duplicated === 2)
|
||||
&& await d_storage.searchDyid(dyid))
|
||||
) {
|
||||
log.info('获取动态', `动态(${dyid})已转发过`)
|
||||
_weight += 1;
|
||||
}
|
||||
@@ -439,23 +448,27 @@ class Searcher {
|
||||
if (length) {
|
||||
const lottery_info = raw_lottery_info
|
||||
.reduce(async (pre, cur) => {
|
||||
const results = await pre
|
||||
let results = await pre
|
||||
, { dyid } = cur;
|
||||
|
||||
const card = await bili.getOneDynamicByDyid(dyid)
|
||||
|
||||
if (card) {
|
||||
await utils.delay(get_dynamic_detail_wait)
|
||||
|
||||
const { is_liked } = parseDynamicCard(card)
|
||||
|
||||
if (!check_if_duplicated || check_if_duplicated === 2) {
|
||||
log.info('获取动态', `查看动态(${dyid})是否点赞 (${length--})`)
|
||||
if (is_liked) {
|
||||
log.info('获取动态', `动态(${dyid})已转发过`)
|
||||
} else {
|
||||
cur.is_liked = is_liked
|
||||
return [...results, cur]
|
||||
const card = await bili.getOneDynamicByDyid(dyid)
|
||||
|
||||
if (card) {
|
||||
await utils.delay(get_dynamic_detail_wait)
|
||||
|
||||
const { is_liked } = parseDynamicCard(card)
|
||||
|
||||
if (is_liked) {
|
||||
log.info('获取动态', `动态(${dyid})已转发过`)
|
||||
} else {
|
||||
cur.is_liked = is_liked
|
||||
results.push(cur)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
results.push(cur)
|
||||
}
|
||||
|
||||
return results
|
||||
|
||||
+26
-5
@@ -49,8 +49,8 @@ const config = {
|
||||
* 符合js正则表达式的字符串
|
||||
*/
|
||||
key_words: [
|
||||
"[抽奖]",
|
||||
"[转关].*[转关]"
|
||||
"[抽奖送揪]|福利",
|
||||
"[转关评粉]|参与"
|
||||
],
|
||||
|
||||
/**
|
||||
@@ -69,6 +69,15 @@ const config = {
|
||||
*/
|
||||
chatmodel: '01',
|
||||
|
||||
/**
|
||||
* 检查是否重复转发
|
||||
* - 不检查 -1
|
||||
* - 通过是否点赞判断 0
|
||||
* - 检索本地dyids文件 1
|
||||
* - 通过是否点赞判断+检索本地dyids文件 2
|
||||
*/
|
||||
check_if_duplicated: 1,
|
||||
|
||||
/**
|
||||
* - 动态创建时间
|
||||
* - 多少天前
|
||||
@@ -221,15 +230,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: ["脚本", "抽奖号", "钓鱼"],
|
||||
|
||||
/**
|
||||
* 转发评语
|
||||
@@ -258,6 +272,11 @@ const config = {
|
||||
*/
|
||||
is_exception: false,
|
||||
|
||||
/**
|
||||
* 是否关注已达上限
|
||||
*/
|
||||
is_outof_maxfollow: false,
|
||||
|
||||
/**
|
||||
* - 中奖通知关键词(满足一个就推送)
|
||||
* - 符合js正则表达式的字符串
|
||||
@@ -266,7 +285,9 @@ const config = {
|
||||
*/
|
||||
notice_key_words: [
|
||||
"~预约成功|预约主题",
|
||||
"中奖|获得|填写|写上|提供|收货地址|支付宝账号|码|大会员"
|
||||
"中奖|获得|填写|写上|提供|收货地址|支付宝账号|码|大会员",
|
||||
"~你的账号在新设备或平台登录成功",
|
||||
"~你预约的直播已开始"
|
||||
],
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const { getRemoteConfig } = require("../utils");
|
||||
const { getRemoteConfig, createDir, createFile } = require("../utils");
|
||||
const config = require("../data/config");
|
||||
|
||||
const key_map = new Map([['DedeUserID', 'myUID'], ['bili_jct', 'csrf']]);
|
||||
@@ -15,10 +15,11 @@ let global_var = {
|
||||
* 全局变量初始化
|
||||
* 更新config
|
||||
* @param {string} cookie
|
||||
* @param {string} num
|
||||
*/
|
||||
async init(cookie) {
|
||||
async init(cookie, num) {
|
||||
if (cookie) {
|
||||
config.updata(process.env.NUMBER);
|
||||
config.updata(num);
|
||||
|
||||
this.set('cookie', cookie);
|
||||
|
||||
@@ -37,6 +38,8 @@ let global_var = {
|
||||
]);
|
||||
this.set('remoteconfig', await getRemoteConfig());
|
||||
}
|
||||
await createDir('dyids');
|
||||
await createFile(num < 2 ? 'dyid.txt' : `dyid${num}.txt`, '', 'a')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
const { log, readDyidFile, writeDyidFile, dyid_length } = require("../utils");
|
||||
|
||||
const d_storage = {
|
||||
/**
|
||||
* 搜索dyid
|
||||
* @param {string} dyid
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
searchDyid: (dyid) => {
|
||||
return new Promise((resolve) => {
|
||||
const Rdyid = new RegExp(dyid);
|
||||
const rs = readDyidFile(Number(process.env.NUMBER));
|
||||
let status = false;
|
||||
rs.on('data', chunk => {
|
||||
if (Rdyid.test(chunk)) {
|
||||
status = true
|
||||
}
|
||||
})
|
||||
rs.on('end', () => {
|
||||
resolve(status)
|
||||
})
|
||||
rs.on('error', err => {
|
||||
log.error('搜索dyid', err)
|
||||
resolve(status)
|
||||
})
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 更新dyid
|
||||
* @param {string} dyid
|
||||
*/
|
||||
updateDyid: (dyid) => {
|
||||
log.info('更新dyid', `写入${dyid}`);
|
||||
if (dyid.length !== dyid_length) {
|
||||
log.error('更新dyid', `dyid(${dyid})长度不为18 若出现此问题请即时通知开发者`)
|
||||
}
|
||||
return new Promise((resolve) => {
|
||||
const ws = writeDyidFile(Number(process.env.NUMBER));
|
||||
ws.write(dyid + ',', () => {
|
||||
ws.destroy();
|
||||
resolve()
|
||||
})
|
||||
ws.on('error', err => {
|
||||
log.error('更新dyid', err)
|
||||
resolve()
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module.exports = d_storage;
|
||||
+86
-48
@@ -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);
|
||||
@@ -607,11 +618,13 @@ const bili_client = {
|
||||
case 0:
|
||||
return [false, 0, '关注+1']
|
||||
case 22002:
|
||||
return [false, -1, '您已被对方拉入黑名单']
|
||||
return [false, 2, '您已被对方拉入黑名单']
|
||||
case 22003:
|
||||
return [false, -1, '黑名单用户无法关注', -1]
|
||||
return [false, 3, '黑名单用户无法关注']
|
||||
case 22015:
|
||||
return [false, 2, '账号异常', 2]
|
||||
return [false, 4, '账号异常']
|
||||
case 22009:
|
||||
return [false, 5, '关注已达上限']
|
||||
default:
|
||||
return [true, 1, `未知错误\n${responseText}`]
|
||||
}
|
||||
@@ -623,10 +636,12 @@ const bili_client = {
|
||||
* @param {Number} uid
|
||||
* 被关注者的UID
|
||||
* @returns {Promise<number>}
|
||||
* -1 - 黑名单
|
||||
* 0 - 成功
|
||||
* 1 - 失败
|
||||
* 2 - 异常
|
||||
* - 成功 0
|
||||
* - 未知错误 1
|
||||
* - 您已被对方拉入黑名单 2
|
||||
* - 黑名单用户无法关注 3
|
||||
* - 账号异常 4
|
||||
* - 关注已达上限 5
|
||||
*/
|
||||
autoAttention(uid) {
|
||||
return this._autoAttention.run(uid)
|
||||
@@ -636,8 +651,8 @@ const bili_client = {
|
||||
* @param {number} uid
|
||||
* @param {number} tagid 关注分区的ID
|
||||
* @returns {Promise<number>}
|
||||
* 0 - 成功
|
||||
* 1 - 失败
|
||||
* - 成功 0
|
||||
* - 失败 1
|
||||
*/
|
||||
async movePartition(uid, tagid) {
|
||||
const responseText = await post({
|
||||
@@ -689,25 +704,36 @@ const bili_client = {
|
||||
* 动态自动点赞
|
||||
* @param {string} dyid
|
||||
* @returns {Promise<number>}
|
||||
* 0 - 成功
|
||||
* 1 - 失败
|
||||
* - 成功 0
|
||||
* - 未知错误 1
|
||||
* - 点赞异常 2
|
||||
* - 点赞频繁 3
|
||||
*/
|
||||
async autolike(dyid) {
|
||||
const responseText = await post({
|
||||
url: API.DYNAMIC_LIKE_THUMB,
|
||||
contents: {
|
||||
uid: GlobalVar.get("myUID"),
|
||||
dynamic_id: dyid,
|
||||
up: 1,
|
||||
csrf: GlobalVar.get("csrf")
|
||||
}
|
||||
});
|
||||
if (/^{"code":0/.test(responseText)) {
|
||||
log.info('自动点赞', '点赞成功');
|
||||
return 0;
|
||||
} else {
|
||||
log.error('自动点赞', `点赞失败\n${responseText}`);
|
||||
return 1;
|
||||
const
|
||||
responseText = await post({
|
||||
url: API.DYNAMIC_LIKE_THUMB,
|
||||
contents: {
|
||||
uid: GlobalVar.get("myUID"),
|
||||
dynamic_id: dyid,
|
||||
up: 1,
|
||||
csrf: GlobalVar.get("csrf")
|
||||
}
|
||||
}),
|
||||
res = strToJson(responseText);
|
||||
switch (res.code) {
|
||||
case 0:
|
||||
log.info('自动点赞', '点赞成功');
|
||||
return 0;
|
||||
case 1000113:
|
||||
log.warn('自动点赞', '点赞异常');
|
||||
return 2;
|
||||
case 1000001:
|
||||
log.warn('自动点赞', '点赞频繁');
|
||||
return 3;
|
||||
default:
|
||||
log.error('自动点赞', `未知错误\n${responseText}`);
|
||||
return 1;
|
||||
}
|
||||
},
|
||||
/**
|
||||
@@ -719,8 +745,11 @@ const bili_client = {
|
||||
* @param {string} [msg]
|
||||
* 动态的ID
|
||||
* @returns {Promise<number>}
|
||||
* 0 - 成功
|
||||
* 1 - 失败
|
||||
* - 成功 0
|
||||
* - 未知错误 1
|
||||
* - 该动态不能转发分享 2
|
||||
* - 请求数据发生错误,请刷新或稍后重试 3
|
||||
* - 操作太频繁了,请稍后重试 4
|
||||
*/
|
||||
async autoRelay(uid, dyid, msg = '转发动态', ctrl = '[]') {
|
||||
const len = msg.length;
|
||||
@@ -742,18 +771,22 @@ const bili_client = {
|
||||
}
|
||||
}),
|
||||
res = strToJson(responseText);
|
||||
if (res.code === 0) {
|
||||
log.info('转发动态', '成功转发一条动态');
|
||||
return 0;
|
||||
} else if (res.code === 1101004) {
|
||||
log.warn('转发动态', '该动态不能转发分享');
|
||||
return 0;
|
||||
} else if (res.code === 2201116) {
|
||||
log.warn('转发动态', '请求数据发生错误,请刷新或稍后重试');
|
||||
return 0;
|
||||
} else {
|
||||
log.error('转发动态', `转发动态失败\n${responseText}`);
|
||||
return 1;
|
||||
switch (res.code) {
|
||||
case 0:
|
||||
log.info('转发动态', '成功转发一条动态');
|
||||
return 0;
|
||||
case 1101004:
|
||||
log.warn('转发动态', '该动态不能转发分享');
|
||||
return 2;
|
||||
case 2201116:
|
||||
log.warn('转发动态', '请求数据发生错误,请刷新或稍后重试');
|
||||
return 3;
|
||||
case 1101008:
|
||||
log.warn('转发动态', '操作太频繁了,请稍后重试');
|
||||
return 4;
|
||||
default:
|
||||
log.error('转发动态', `未知错误\n${responseText}`);
|
||||
return 1;
|
||||
}
|
||||
},
|
||||
/**
|
||||
@@ -883,8 +916,13 @@ const bili_client = {
|
||||
* 17(无图)
|
||||
* @returns {Promise<number>}
|
||||
* - 成功 0
|
||||
* - 失败 1
|
||||
* - 黑名单/评论区关闭/动态删除 -1
|
||||
* - 未知错误 1
|
||||
* - 原动态已删除 2
|
||||
* - 评论区已关闭 3
|
||||
* - 需要输入验证码 4
|
||||
* - 已被对方拉入黑名单 5
|
||||
* - 黑名单用户无法互动 6
|
||||
* - UP主已关闭评论区 7
|
||||
*/
|
||||
async sendChat(rid, msg, type) {
|
||||
const
|
||||
@@ -904,22 +942,22 @@ const bili_client = {
|
||||
return 0;
|
||||
case -404:
|
||||
log.error('自动评论', '原动态已删除');
|
||||
return -1;
|
||||
return 2;
|
||||
case 12002:
|
||||
log.error('自动评论', '评论区已关闭');
|
||||
return -1;
|
||||
return 3;
|
||||
case 12015:
|
||||
log.error('自动评论', '需要输入验证码');
|
||||
return 1;
|
||||
return 4;
|
||||
case 12035:
|
||||
log.error('自动评论', `已被对方拉入黑名单`);
|
||||
return -1;
|
||||
return 5;
|
||||
case 12053:
|
||||
log.error('自动评论', '黑名单用户无法互动');
|
||||
return -1;
|
||||
return 6;
|
||||
case 12061:
|
||||
log.error('自动评论', 'UP主已关闭评论区');
|
||||
return -1;
|
||||
return 7;
|
||||
default:
|
||||
log.error('自动评论', `未知错误\n${responseText}`);
|
||||
return 1;
|
||||
|
||||
@@ -13,6 +13,8 @@ const utils = {
|
||||
env_file: path.join(process.cwd(), "env.js"),
|
||||
/**配置文件 */
|
||||
config_file: path.join(process.cwd(), "my_config.js"),
|
||||
/**dyids存放目录 */
|
||||
dyids_dir: path.join(process.cwd(), "dyids"),
|
||||
/**dyid长度 */
|
||||
dyid_length: 18,
|
||||
/**
|
||||
@@ -57,6 +59,25 @@ const utils = {
|
||||
if (await fn(item)) break
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @template T
|
||||
* @param {number} max_times
|
||||
* @param {Array<T>} unexpected
|
||||
* @param {() => Promise<T>} fn
|
||||
*/
|
||||
async retryfn(max_times, unexpected, fn) {
|
||||
let ret = null;
|
||||
for (let times = 0; times < max_times; times++) {
|
||||
ret = await fn()
|
||||
if (unexpected.includes(ret)) {
|
||||
utils.log.warn('自动重试', `将在 ${times + 1} 分钟后再次尝试(${times + 1}/${max_times})`)
|
||||
await utils.delay(60 * 1000 * (times + 1))
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
/**
|
||||
* 函数柯里化
|
||||
* @template T
|
||||
@@ -306,6 +327,50 @@ const utils = {
|
||||
resolve()
|
||||
})
|
||||
});
|
||||
},
|
||||
/**
|
||||
* CreateFile
|
||||
* @param {string} filepath 相对于dyids的文件路径
|
||||
* @param {string} [defaultValue] 写入默认值
|
||||
* @param {string} flag
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
createFile(filepath, defaultValue, flag) {
|
||||
const fpath = path.join(utils.dyids_dir, filepath);
|
||||
const buffer = Buffer.from(defaultValue);
|
||||
return new Promise((resolve, rejects) => {
|
||||
fs.open(fpath, flag, (err, fd) => {
|
||||
if (err) {
|
||||
rejects(err)
|
||||
} else {
|
||||
fs.write(fd, buffer, 0, buffer.length, 0, err => {
|
||||
if (err) {
|
||||
rejects(err)
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 读取dyid文件
|
||||
* @param {number} num
|
||||
* @returns {fs.ReadStream}
|
||||
*/
|
||||
readDyidFile(num) {
|
||||
const fpath = num < 2 ? path.join(utils.dyids_dir, 'dyid.txt') : path.join(utils.dyids_dir, `dyid${num}.txt`);
|
||||
return fs.createReadStream(fpath, { encoding: 'utf8', highWaterMark: (utils.dyid_length + 1) * 1000 })
|
||||
},
|
||||
/**
|
||||
* 追加dyid
|
||||
* @param {number} num
|
||||
* @returns {fs.WriteStream}
|
||||
*/
|
||||
writeDyidFile(num) {
|
||||
const fpath = num < 2 ? path.join(utils.dyids_dir, 'dyid.txt') : path.join(utils.dyids_dir, `dyid${num}.txt`);
|
||||
return fs.createWriteStream(fpath, { flags: 'a' })
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -10,8 +10,7 @@ const metainfo = [
|
||||
` __/ | | | `,
|
||||
` |___/ |_| `,
|
||||
` `,
|
||||
` Verison: v${ve}`,
|
||||
` Written By shanmite`,
|
||||
` This: v${ve} Nodejs: ${process.version} Written By shanmite`,
|
||||
]
|
||||
/**多账号存储 */
|
||||
let multiple_account = [];
|
||||
@@ -46,7 +45,7 @@ async function main() {
|
||||
process.env.ENABLE_MULTIPLE_ACCOUNT = ENABLE_MULTIPLE_ACCOUNT;
|
||||
} else if (COOKIE) {
|
||||
const global_var = require("./lib/data/global_var");
|
||||
await global_var.init(COOKIE, Number(NUMBER));
|
||||
await global_var.init(COOKIE, NUMBER);
|
||||
|
||||
/**引入基础功能 */
|
||||
const { start, isMe, clear, update, checkCookie } = require("./lib/index");
|
||||
|
||||
+28
-6
@@ -48,7 +48,7 @@ module.exports = Object.freeze({
|
||||
* API传回数据类型 {RespondBody}
|
||||
* 获取抽奖信息的链接字符串
|
||||
* @example
|
||||
* "https://raw.fastgit.org/spiritLHL/sync_lottery/master/archive_datas/datas.json"
|
||||
* "https://github.com/spiritLHL/sync_lottery"
|
||||
*/
|
||||
APIs: [],
|
||||
|
||||
@@ -63,8 +63,8 @@ module.exports = Object.freeze({
|
||||
* 符合js正则表达式的字符串
|
||||
*/
|
||||
key_words: [
|
||||
"[抽奖]",
|
||||
"[转关].*[转关]"
|
||||
"[抽奖送揪]|福利",
|
||||
"[转关评粉]|参与"
|
||||
],
|
||||
|
||||
/**
|
||||
@@ -83,6 +83,15 @@ module.exports = Object.freeze({
|
||||
*/
|
||||
chatmodel: '01',
|
||||
|
||||
/**
|
||||
* 检查是否重复转发
|
||||
* - 不检查 -1
|
||||
* - 通过是否点赞判断 0
|
||||
* - 检索本地dyids文件 1
|
||||
* - 通过是否点赞判断+检索本地dyids文件 2
|
||||
*/
|
||||
check_if_duplicated: 1,
|
||||
|
||||
/**
|
||||
* - 动态创建时间
|
||||
* - 多少天前
|
||||
@@ -235,15 +244,21 @@ module.exports = Object.freeze({
|
||||
at_users: [['转发抽奖娘', 294887687], ['你的工具人老公', 100680137]],
|
||||
|
||||
/**
|
||||
* - 自动同步 https://gitee.com/shanmite/lottery-notice/raw/master/notice.json
|
||||
* - 动态dyid或UID
|
||||
* - 英文逗号分隔 如: 1,2,3
|
||||
*/
|
||||
blacklist: '',
|
||||
|
||||
/**
|
||||
* - 自动同步 https://gitee.com/shanmite/lottery-notice/raw/master/notice.json
|
||||
* - 使用公共黑名单
|
||||
*/
|
||||
use_public_blacklist: true,
|
||||
|
||||
/**
|
||||
* 屏蔽词
|
||||
*/
|
||||
blockword: ["脚本抽奖", "恭喜", "结果", "抽奖号", "钓鱼", "涨粉"],
|
||||
blockword: ["脚本", "抽奖号", "钓鱼"],
|
||||
|
||||
/**
|
||||
* 转发评语
|
||||
@@ -272,6 +287,11 @@ module.exports = Object.freeze({
|
||||
*/
|
||||
is_exception: false,
|
||||
|
||||
/**
|
||||
* 是否关注已达上限
|
||||
*/
|
||||
is_outof_maxfollow: false,
|
||||
|
||||
/**
|
||||
* - 中奖通知关键词(满足一个就推送)
|
||||
* - 符合js正则表达式的字符串
|
||||
@@ -280,7 +300,9 @@ module.exports = Object.freeze({
|
||||
*/
|
||||
notice_key_words: [
|
||||
"~预约成功|预约主题",
|
||||
"中奖|获得|填写|写上|提供|收货地址|支付宝账号|码|大会员"
|
||||
"中奖|获得|填写|写上|提供|收货地址|支付宝账号|码|大会员",
|
||||
"~你的账号在新设备或平台登录成功",
|
||||
"~你预约的直播已开始"
|
||||
],
|
||||
|
||||
/**
|
||||
|
||||
+4
-3
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "lottery-auto-script",
|
||||
"version": "2.3.7",
|
||||
"version": "2.4.4",
|
||||
"description": "自动参与B站动态抽奖",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
@@ -8,7 +8,8 @@
|
||||
"clear": "node main.js clear",
|
||||
"check": "node main.js check",
|
||||
"update": "node main.js update",
|
||||
"build_all": "bash script/build/pkg.sh"
|
||||
"build_all": "bash script/build/pkg.sh",
|
||||
"changelog": "bash script/build/changelog.sh"
|
||||
},
|
||||
"files": [
|
||||
"lib",
|
||||
@@ -53,4 +54,4 @@
|
||||
"chalk": "^4.1.2",
|
||||
"nodemailer": "^6.7.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# version: <major.minor.patch>
|
||||
level=patch
|
||||
|
||||
npm version $level \
|
||||
--no-commit-hooks \
|
||||
--no-git-tag-version
|
||||
|
||||
OLD_VERSION_ARRAY=($(npm view lottery-auto-script version | tr '.' ' '))
|
||||
major=${OLD_VERSION_ARRAY[0]}
|
||||
minor=${OLD_VERSION_ARRAY[1]}
|
||||
patch=${OLD_VERSION_ARRAY[2]}
|
||||
|
||||
case "${level}" in
|
||||
"major")
|
||||
((major += 1))
|
||||
minor=0
|
||||
patch=0
|
||||
;;
|
||||
"minor")
|
||||
((minor += 1))
|
||||
patch=0
|
||||
;;
|
||||
*)
|
||||
((patch += 1))
|
||||
;;
|
||||
esac
|
||||
|
||||
NEW_VERSION="$major.$minor.$patch"
|
||||
|
||||
echo "New Version: $NEW_VERSION"
|
||||
|
||||
GIT_LOG="$(git log --pretty=format:"* %h %s" | sed -e '/CHANGELOG/,$d' | sed ':a;N;s/\n/\\n/g;ta')"
|
||||
|
||||
sed -i "/# CHANGELOG/a\## 主要变化($NEW_VERSION)\n$GIT_LOG\n\n_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_\n" CHANGELOG.md
|
||||
|
||||
git add .
|
||||
git commit -m "docs: 更新CHANGELOG"
|
||||
+6
-3
@@ -35,13 +35,16 @@ for file in "$TARGET_DIR/"*; do
|
||||
for item in "${BATS[@]}"; do
|
||||
create_win_bat "${item}" >"$TMPDIR/$item.bat"
|
||||
done
|
||||
mv "$TMPDIR/$BIN_NAME" "$TMPDIR/$BIN_NAME.exe"
|
||||
else
|
||||
ZIP_NAME=latest_version0
|
||||
cat >"$TMPDIR/update.sh" <<-EOF
|
||||
#!/bin/bash
|
||||
./lottery update
|
||||
if [[ -r "latest_version.zip" ]]; then
|
||||
unzip latest_version.zip
|
||||
rm latest_version0.zip
|
||||
ZIP_NAME=$ZIP_NAME
|
||||
if [[ -r "\$ZIP_NAME.zip" ]]; then
|
||||
unzip \$ZIP_NAME.zip
|
||||
rm \$ZIP_NAME.zip
|
||||
chmod u+x lottery
|
||||
fi
|
||||
EOF
|
||||
|
||||
Reference in New Issue
Block a user