Compare commits

...
8 Commits
Author SHA1 Message Date
shanmite 5d3103102e docs: 更新CHANGELOG 2022-09-11 17:58:13 +08:00
shanmite 7ab38f258c feat: 弃用update_loop_wait(#180)
Fixed #180
2022-09-11 17:55:02 +08:00
shanmite 35fe4481fa feat: 预约抽奖参与间隔reserve_lottery_wait(#191)
Fixed #191
2022-09-11 17:42:23 +08:00
shanmite 58edd4129c fix: 该动态不能转发分享(#189)
Fixed #189
2022-09-11 17:24:43 +08:00
shanmite c8e1a328ec fix: 关注UP主7天以上的人可发评论(#192)
Fixed #192
2022-09-11 17:12:50 +08:00
shanmite 4f8f50f90b ci: docker 2022-08-29 10:47:01 +08:00
shanmite 3b4b85bc42 ci: pkg 2022-08-29 09:25:11 +08:00
shanmite db11265b28 docker: sh change to bash 2022-08-29 09:18:07 +08:00
13 changed files with 84 additions and 42 deletions
+1 -1
View File
@@ -31,4 +31,4 @@ jobs:
with:
push: true
tags: ${{ secrets.DOCKERHUB_REPO }}
platforms: "linux/amd64,linux/386,linux/arm64,linux/arm/v7,linux/arm/v6,linux/riscv64"
platforms: "linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/ppc64le,linux/s390x"
+3
View File
@@ -2,6 +2,9 @@ name: "Package Node.js project into an executable"
on:
push:
branches:
- main
- pkg
paths:
- "lib/**"
- "*.js"
+11
View File
@@ -1,5 +1,16 @@
<!-- markdownlint-disable MD036 MD024-->
# CHANGELOG
## 主要变化(2.6.2)
* 7ab38f2 feat: 弃用`update_loop_wait`(#180)
* 35fe448 feat: 预约抽奖参与间隔`reserve_lottery_wait`(#191)
* 58edd41 fix: 该动态不能转发分享(#189)
* c8e1a32 fix: 关注UP主7天以上的人可发评论(#192)
* 4f8f50f ci: docker
* 3b4b85b ci: pkg
* db11265 docker: change sh to bash
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.6.1)
* 82efbb4 ci: pkg arm64 use podman
* 886ccff fix: cookie缺少`buvid3`导致412(#182)(#185)
+2 -2
View File
@@ -1,4 +1,4 @@
FROM --platform=$BUILDPLATFORM node:lts-alpine
FROM node:lts-alpine
LABEL author="shanmite" version="1.1" description="自动参与B站动态抽奖"
@@ -12,4 +12,4 @@ COPY ["main.js", "./"]
COPY ["lib/", "lib/"]
ENTRYPOINT ["npm", "run"]
CMD ["start"]
CMD ["start"]
+4 -1
View File
@@ -184,6 +184,7 @@ class Monitor extends Searcher {
case 1008:
case 1009:
case 1010:
case 1011:
case 2002:
case 2003:
case 4001:
@@ -255,7 +256,7 @@ class Monitor extends Searcher {
/** 所有抽奖信息 */
let alllotteryinfo = [];
const
{ check_if_duplicated, set_lottery_info_url, disable_reserve_lottery, sneaktower, key_words, model, chatmodel, chat: chats, relay: relays, block_dynamic_type, max_create_time, is_imitator, only_followed, at_users, blockword, blacklist, use_public_blacklist } = config,
{ check_if_duplicated, set_lottery_info_url, disable_reserve_lottery, reserve_lottery_wait, sneaktower, key_words, model, chatmodel, chat: chats, relay: relays, block_dynamic_type, max_create_time, is_imitator, only_followed, at_users, blockword, blacklist, use_public_blacklist } = config,
now_ts = Date.now() / 1000;
/**
@@ -410,6 +411,7 @@ class Monitor extends Searcher {
if (hasEnv('NOT_GO_LOTTERY')) {
log.info('NOT_GO_LOTTERY', 'ON');
} else {
await delay(reserve_lottery_wait);
await bili.reserve_lottery(reserve_id)
}
}
@@ -532,6 +534,7 @@ class Monitor extends Searcher {
* - 评论 内容包含敏感信息 1008
* - 评论 重复评论 1009
* - 评论 帐号未登录 1010
* - 评论 关注UP主7天以上的人可发评论 1011
* - 关注 未知错误 2001
* - 关注 您已被对方拉入黑名单 2002
* - 关注 黑名单用户无法关注 2003
+6 -1
View File
@@ -170,7 +170,6 @@ const config = {
lottery_loop_wait: 0,
check_loop_wait: 0,
clear_loop_wait: 0,
update_loop_wait: 0,
/**
* - 转发间隔时间
@@ -221,6 +220,12 @@ const config = {
*/
random_dynamic_wait: 2000,
/**
* - 预约抽奖间隔
* - 单位毫秒
*/
reserve_lottery_wait: 6000,
/**
* - up主粉丝数限制
*/
+1 -2
View File
@@ -1,7 +1,6 @@
const { isMe } = require('./check');
const { clear } = require('./clear');
const { start } = require('./lottery');
const { update } = require('./update');
const global_var = require('./data/global_var')
const bili = require('./net/bili')
const { log } = require('./utils')
@@ -24,4 +23,4 @@ async function checkCookie(num) {
}
module.exports = { start, isMe, clear, update, checkCookie }
module.exports = { start, isMe, clear, checkCookie }
+28 -18
View File
@@ -919,24 +919,30 @@ const bili_client = {
* @return {boolean} isError true
*/
async shareVideo(uid, aid) {
const responseText = await post({
url: API.DYNAMIC_REPOST_SHARE,
contents: {
platform: "pc",
uid,
type: 8,
content: "分享视频",
repost_code: 20000,
rid: aid,
csrf_token: GlobalVar.get("csrf")
}
});
if (/^{"code":0/.test(responseText)) {
log.info('转发视频', `成功转发视频(av${aid})`);
return false
} else {
log.error('转发视频', `转发失败\n${responseText}`);
return true
const
responseText = await post({
url: API.DYNAMIC_REPOST_SHARE,
contents: {
platform: "pc",
uid,
type: 8,
content: "分享视频",
repost_code: 20000,
rid: aid,
csrf_token: GlobalVar.get("csrf")
}
}),
res = strToJson(responseText);
switch (res.code) {
case 0:
log.info('转发视频', `成功转发视频(av${aid})`);
return false
case 1101015:
log.warn('转发视频', `该动态不能转发分享(av${aid})`);
return false
default:
log.error('转发视频', `转发失败\n${responseText}`);
return true
}
},
/**
@@ -984,6 +990,7 @@ const bili_client = {
* - 评论内容包含敏感信息 8
* - 重复评论 9
* - 帐号未登录 10
* - 关注UP主7天以上的人可发评论 11
*/
async sendChat(rid, msg, type) {
const
@@ -1028,6 +1035,9 @@ const bili_client = {
case -101:
log.error('自动评论', '帐号未登录');
return 10;
case 12078:
log.error('自动评论', '关注UP主7天以上的人可发评论');
return 11;
default:
log.error('自动评论', `未知错误\n${responseText}`);
return 1;
+9 -7
View File
@@ -49,14 +49,14 @@ async function main() {
await global_var.init(COOKIE, NUMBER);
/**引入基础功能 */
const { start, isMe, clear, update, checkCookie } = require("./lib/index");
const { start, isMe, clear, checkCookie } = require("./lib/index");
log.info('main', '当前为第' + NUMBER + '个账号');
if (await checkCookie(NUMBER)) {
const mode = process.env.lottery_mode;
const help_msg = "用法: lottery [OPTIONS]\n\nOPTIONS:\n\tstart 启动抽奖\n\tcheck 中奖检查\n\tclear 清理动态和关注\n\tupdate 检查更新\n\thelp 帮助信息";
const { lottery_loop_wait, check_loop_wait, clear_loop_wait, update_loop_wait } = require("./lib/data/config");
const { lottery_loop_wait, check_loop_wait, clear_loop_wait } = require("./lib/data/config");
switch (mode) {
case 'start':
log.info('抽奖', '开始运行');
@@ -75,11 +75,6 @@ async function main() {
await clear();
}
break;
case 'update':
log.info('检查更新', '开始')
loop_wait = update_loop_wait;
await update()
break;
case 'help':
return help_msg
case undefined:
@@ -150,6 +145,13 @@ function initConfig() {
/**OPTIONS */
process.env.lottery_mode = process.argv[2]
if (process.env.lottery_mode === "update") {
log.info('检查更新', '开始')
await require("./lib/update").update()
log.info('检查更新', '请手动解压替换可执行文件')
return
}
const err_msg = await main();
if (err_msg) {
log.error('错误', err_msg);
+6 -1
View File
@@ -183,7 +183,6 @@ module.exports = Object.freeze({
lottery_loop_wait: 0,
check_loop_wait: 0,
clear_loop_wait: 0,
update_loop_wait: 0,
/**
* - 转发间隔时间
@@ -234,6 +233,12 @@ module.exports = Object.freeze({
*/
random_dynamic_wait: 2000,
/**
* - 预约抽奖间隔
* - 单位毫秒
*/
reserve_lottery_wait: 6000,
/**
* - up主粉丝数限制
*/
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "lottery-auto-script",
"version": "2.6.1",
"version": "2.6.2",
"description": "自动参与B站动态抽奖",
"main": "main.js",
"scripts": {
+7 -7
View File
@@ -49,7 +49,7 @@ docker -v && docker pull $DOCKER_REPO
echo "create start.sh"
cat >start.sh <<EOF
#!/bin/sh
#!/bin/env bash
NAME=shanmite-lottery-start
if [[ -z "\$(docker ps -a | grep \$NAME)" ]]; then
docker run \\
@@ -70,7 +70,7 @@ chmod +x start.sh
echo "create check.sh"
cat >check.sh <<EOF
#!/bin/sh
#!/bin/env bash
NAME=shanmite-lottery-check
if [[ -z "\$(docker ps -a | grep \$NAME)" ]]; then
docker run \\
@@ -91,7 +91,7 @@ chmod +x check.sh
echo "create clear.sh"
cat >clear.sh <<EOF
#!/bin/sh
#!/bin/env bash
NAME=shanmite-lottery-clear
if [[ -z "\$(docker ps -a | grep \$NAME)" ]]; then
docker run \\
@@ -112,14 +112,14 @@ chmod +x clear.sh
echo "create debug.sh"
cat >debug.sh <<EOF
#!/bin/sh
#!/bin/env bash
NAME=shanmite-lottery-debug
echo "create temporary debug container"
docker run \\
-it \\
--name \$NAME \\
--entrypoint /bin/sh \\
$DOCKER_REPO -c sh
--entrypoint /bin/bash \\
$DOCKER_REPO -c bash
echo "remove temporary debug container"
docker rm -v \$NAME
EOF
@@ -127,7 +127,7 @@ chmod +x debug.sh
echo "create remove_all.sh"
cat >remove_all.sh <<EOF
#!/bin/sh
#!/bin/env bash
echo "remove all containers about $DOCKER_REPO"
docker rm -v \$(docker ps -a | awk '/shanmite\/lottery_auto_docker/ {print \$1}')
echo "remove image $DOCKER_REPO"
+5 -1
View File
@@ -24,8 +24,12 @@ const util = require('./util');
1),
3
)
}, async () => {
},
async () => {
assert.notEqual((await bili_client.searchArticlesByKeyword("专栏")).length, 0)
},
async () => {
assert.notEqual(await bili_client.sendChat("703886913053917267", "t", 17), 1)
}
])