Compare commits

..
6 Commits
Author SHA1 Message Date
shanmite f9ebbb30eb docs: 更新CHANGELOG 2021-12-03 19:16:39 +08:00
shanmite b36c555c13 ci: auto gen changelog 2021-12-03 19:15:34 +08:00
shanmite 7338e09caf feat: 更新notice_key_words
更新屏蔽通知词
"~你的账号在新设备或平台登录成功",
"~你预约的直播已开始"
2021-12-03 18:46:28 +08:00
shanmite 80a54e87f8 ci: *.exe latest_version0 2021-12-03 15:49:17 +08:00
shanmite 1a6291471a feat: 新增设置is_outof_maxfollow(#80)
关注已达上限时自动切换
2021-12-03 15:29:21 +08:00
shanmite 449c8d9272 docs: update README 2021-12-02 21:53:27 +08:00
9 changed files with 114 additions and 23 deletions
+9
View File
@@ -1,5 +1,14 @@
<!-- markdownlint-disable MD036 MD024-->
# CHANGELOG
## 主要变化(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`
+2
View File
@@ -230,6 +230,8 @@ $ tree
└── start.sh
```
[![asciicast](https://asciinema.org/a/453237.svg)](https://asciinema.org/a/453237)
3.更新
进入lottery上一级目录
+36 -13
View File
@@ -63,6 +63,15 @@ class Monitor extends Searcher {
config.is_exception = true;
event_bus.emit('Turn_on_the_Monitor')
break
case 23:
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 31:
event_bus.emit('Turn_off_the_Monitor', '转发失败')
break
@@ -89,12 +98,23 @@ 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
@@ -109,10 +129,10 @@ class Monitor extends Searcher {
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
}
@@ -135,14 +155,17 @@ class Monitor extends Searcher {
randomDynamic(number)
}
status = await this.go(Lottery)
status = await this.go(lottery)
switch (status) {
case 0:
case 9:
case 19:
break;
case 22:
is_exception = true
is_exception = 22
break;
case 23:
is_outof_maxfollow = 23
break;
default:
return status
@@ -151,11 +174,9 @@ class Monitor extends Searcher {
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
@@ -403,6 +424,7 @@ class Monitor extends Searcher {
* 19 - 关注黑名单
* 21 - 关注错误
* 22 - 关注异常
* 23 - 关注已达上限
* 31 - 转发失败
*/
async go(option) {
@@ -452,6 +474,7 @@ class Monitor extends Searcher {
return false
case -1:
case 2:
case 3:
log.warn('抽奖信息', `uid: ${u},dyid: ${dyid}`)
return true
default:
+8 -1
View File
@@ -263,6 +263,11 @@ const config = {
*/
is_exception: false,
/**
* 是否关注已达上限
*/
is_outof_maxfollow: false,
/**
* - 中奖通知关键词(满足一个就推送)
* - 符合js正则表达式的字符串
@@ -271,7 +276,9 @@ const config = {
*/
notice_key_words: [
"~预约成功|预约主题",
"中奖|获得|填写|写上|提供|收货地址|支付宝账号|码|大会员"
"中奖|获得|填写|写上|提供|收货地址|支付宝账号|码|大会员",
"~你的账号在新设备或平台登录成功",
"~你预约的直播已开始"
],
/**
+5 -2
View File
@@ -620,9 +620,11 @@ const bili_client = {
case 22002:
return [false, -1, '您已被对方拉入黑名单']
case 22003:
return [false, -1, '黑名单用户无法关注', -1]
return [false, -1, '黑名单用户无法关注']
case 22015:
return [false, 2, '账号异常', 2]
return [false, 2, '账号异常']
case 22009:
return [false, 3, '关注已达上限']
default:
return [true, 1, `未知错误\n${responseText}`]
}
@@ -638,6 +640,7 @@ const bili_client = {
* 0 - 成功
* 1 - 失败
* 2 - 异常
* 3 - 关注已达上限
*/
autoAttention(uid) {
return this._autoAttention.run(uid)
+8 -1
View File
@@ -277,6 +277,11 @@ module.exports = Object.freeze({
*/
is_exception: false,
/**
* 是否关注已达上限
*/
is_outof_maxfollow: false,
/**
* - 中奖通知关键词(满足一个就推送)
* - 符合js正则表达式的字符串
@@ -285,7 +290,9 @@ module.exports = Object.freeze({
*/
notice_key_words: [
"~预约成功|预约主题",
"中奖|获得|填写|写上|提供|收货地址|支付宝账号|码|大会员"
"中奖|获得|填写|写上|提供|收货地址|支付宝账号|码|大会员",
"~你的账号在新设备或平台登录成功",
"~你预约的直播已开始"
],
/**
+4 -3
View File
@@ -1,6 +1,6 @@
{
"name": "lottery-auto-script",
"version": "2.3.8",
"version": "2.3.9",
"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"
}
}
}
+36
View File
@@ -0,0 +1,36 @@
#!/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")
((minor += 1))
;;
*)
((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
View File
@@ -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