mirror of
https://github.com/shanmiteko/LotteryAutoScript.git
synced 2026-07-22 21:13:47 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
092bd843e1 | ||
|
|
2f2eaabc57 | ||
|
|
da8d460dc6 | ||
|
|
3825be45df | ||
|
|
248c78d669 |
@@ -26,8 +26,8 @@ jobs:
|
||||
nodev: 18
|
||||
- platform: win
|
||||
nodev: 18
|
||||
- platform: win
|
||||
nodev: 12
|
||||
# - platform: win
|
||||
# nodev: 12
|
||||
steps:
|
||||
- name: "Checkout codes"
|
||||
uses: actions/checkout@v3
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
<!-- markdownlint-disable MD036 MD024-->
|
||||
# CHANGELOG
|
||||
## 主要变化(2.8.3)
|
||||
* 2f2eaab fix: 预约抽奖包月抽奖识别异常 (#288)
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.8.2)
|
||||
* 3825be4 feat: 查看帐号信息
|
||||
* 248c78d feat: 快速移除关注模式新增粉丝数限制 (#305)
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.8.1)
|
||||
* d44981b fix: 随机cookie参数buvid3
|
||||
* 3bfc93f fix: 目前回复无法正常推送 (#302)
|
||||
|
||||
@@ -112,22 +112,20 @@ buvid3亦可不填 使用随机生成值
|
||||
4. 在`my_config.js`中自定义设置
|
||||
5. 在当前目录下**打开终端**运行可执行文件`lottery`(勿直接点击`lottery`)
|
||||
- windows 可直接点击对应的`*.bat`文件
|
||||
- unix-like
|
||||
```sh
|
||||
## 进入脚本所在目录
|
||||
## 授予执行权限
|
||||
$ chmod u+x lottery
|
||||
## 启动脚本
|
||||
$ ./lottery start
|
||||
## 检测中奖
|
||||
$ ./lottery check
|
||||
## 清理关注动态
|
||||
$ ./lottery clear
|
||||
## 下载最新版本
|
||||
$ ./lottery update
|
||||
|
||||
```
|
||||
用法: lottery [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
start 启动抽奖
|
||||
check 中奖检查
|
||||
acount 查看帐号信息
|
||||
clear 清理动态和关注
|
||||
update 检查更新
|
||||
help 帮助信息
|
||||
```
|
||||
|
||||
7. 运行截图
|
||||
1. 运行截图
|
||||

|
||||
|
||||
#### 以源码方式运行
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
const bili = require('./net/bili')
|
||||
const { log } = require('./utils')
|
||||
|
||||
async function account() {
|
||||
const my_info = await bili.getMyinfo();
|
||||
const stat = await bili.getStat();
|
||||
if (my_info && stat) {
|
||||
log.info("帐号信息", `${my_info.name} Lv${my_info.level} ${my_info.silence ? "已封禁" : "未封禁"} 升级还需${my_info.level_exp.next_exp - my_info.level_exp.current_exp}经验`)
|
||||
log.info("帐号信息", `当前关注数:${stat.following} 粉丝数:${stat.follower} 动态数量:${stat.dynamic_count}`)
|
||||
} else {
|
||||
log.error("帐号信息", "获取失败");
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { account }
|
||||
+12
-8
@@ -33,7 +33,7 @@ async function getFollowList(partition) {
|
||||
* 清理动态和关注
|
||||
*/
|
||||
async function clear() {
|
||||
const { search_wait, clear_white_list, clear_max_day, clear_quick_remove_attention, clear_remove_dynamic, clear_remove_attention, clear_remove_delay, clear_dynamic_type, clear_partition } = config;
|
||||
const { search_wait, clear_white_list, clear_max_day, clear_quick_remove_attention, clear_quick_remove_attention_fans_number_smallest, clear_remove_dynamic, clear_remove_attention, clear_remove_delay, clear_dynamic_type, clear_partition } = config;
|
||||
let success = true;
|
||||
const uid_list = (await Promise.all(clear_partition.split(',').map(getFollowList))).flat();
|
||||
if (!uid_list.length) {
|
||||
@@ -45,13 +45,17 @@ async function clear() {
|
||||
log.info('清理关注', '进入只清理关注模式')
|
||||
/* 专清关注 */
|
||||
for (const [index, uid] of uid_list.entries()) {
|
||||
log.info('清理关注', `(${index}) (${uid})`)
|
||||
/* 取消关注 */
|
||||
if (await retryfn(3, [false], () => bili.cancelAttention(uid))) {
|
||||
log.info('清理关注', '成功')
|
||||
} else {
|
||||
log.error('清理关注', '失败')
|
||||
break
|
||||
const fannumber = await bili.getUserInfo(uid);
|
||||
log.info('清理关注', `粉丝数${fannumber}`)
|
||||
if (fannumber !== -1 && fannumber < clear_quick_remove_attention_fans_number_smallest) {
|
||||
log.info('清理关注', `(${index}) (${uid})`)
|
||||
/* 取消关注 */
|
||||
if (await retryfn(3, [false], () => bili.cancelAttention(uid))) {
|
||||
log.info('清理关注', '成功')
|
||||
} else {
|
||||
log.error('清理关注', '失败')
|
||||
break
|
||||
}
|
||||
}
|
||||
/* 延时 */
|
||||
await delay(clear_remove_delay);
|
||||
|
||||
+20
-3
@@ -103,7 +103,15 @@ function parseDynamicCard(dynamic_detail_card) {
|
||||
obj.reserve_lottery_text = text;
|
||||
}
|
||||
}
|
||||
if (JSON.stringify(add_on_card_info).match(/充电专属抽奖/)) {
|
||||
if (extendjsonToJson[""]) {
|
||||
let r = extendjsonToJson[""].reserve || {};
|
||||
let { reserve_id, reserve_lottery } = r;
|
||||
if (reserve_lottery === 1) {
|
||||
obj.reserve_id = reserve_id + "";
|
||||
obj.reserve_lottery_text = "信息丢失";
|
||||
}
|
||||
}
|
||||
if (extend_json.match(/"":\{"lottery/)) {
|
||||
obj.is_charge_lottery = true
|
||||
}
|
||||
/* 是否有官方抽奖 */
|
||||
@@ -119,9 +127,10 @@ function parseDynamicCard(dynamic_detail_card) {
|
||||
|| '';
|
||||
/* 转发 */
|
||||
if (obj.type === 1) {
|
||||
const { origin_extension, origin } = cardToJson
|
||||
const { origin_extension, origin, origin_extend_json } = cardToJson
|
||||
, originToJson = strToJson(origin)
|
||||
, { add_on_card_info = [] } = display.origin || {}
|
||||
, originExtendjsonToJson = strToJson(origin_extend_json)
|
||||
, { user, item } = originToJson;
|
||||
/* 源动态的ts10 */
|
||||
obj.origin_create_time = desc.origin.timestamp;
|
||||
@@ -150,7 +159,15 @@ function parseDynamicCard(dynamic_detail_card) {
|
||||
obj.origin_reserve_lottery_text = text;
|
||||
}
|
||||
}
|
||||
if (JSON.stringify(add_on_card_info).match(/充电专属抽奖/)) {
|
||||
if (originExtendjsonToJson[""]) {
|
||||
let r = originExtendjsonToJson[""].reserve || {};
|
||||
let { reserve_id, reserve_lottery } = r;
|
||||
if (reserve_lottery === 1) {
|
||||
obj.origin_reserve_id = reserve_id + "";
|
||||
obj.origin_reserve_lottery_text = "信息丢失";
|
||||
}
|
||||
}
|
||||
if (origin_extend_json.match(/"":\{"lottery/)) {
|
||||
obj.origin_is_charge_lottery = true
|
||||
}
|
||||
/* 是否有官方抽奖 */
|
||||
|
||||
+8
-1
@@ -408,6 +408,13 @@ const config = {
|
||||
*/
|
||||
clear_quick_remove_attention: false,
|
||||
|
||||
/**
|
||||
* - 快速移除关注
|
||||
* - 不加判断只去除关注
|
||||
* - 移除粉丝数小于指定数量的
|
||||
*/
|
||||
clear_quick_remove_attention_fans_number_smallest: Infinity,
|
||||
|
||||
/**
|
||||
* 是否移除动态
|
||||
*/
|
||||
@@ -419,7 +426,7 @@ const config = {
|
||||
clear_remove_attention: true,
|
||||
|
||||
/**
|
||||
* 清除动态延时(毫秒)
|
||||
* 清除延时(毫秒)
|
||||
*/
|
||||
clear_remove_delay: 8000,
|
||||
|
||||
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
const { isMe } = require('./check');
|
||||
const { clear } = require('./clear');
|
||||
const { start } = require('./lottery');
|
||||
const { account } = require("./account");
|
||||
const global_var = require('./data/global_var')
|
||||
const bili = require('./net/bili')
|
||||
const { log } = require('./utils')
|
||||
@@ -23,4 +24,4 @@ async function checkCookie(num) {
|
||||
}
|
||||
|
||||
|
||||
module.exports = { start, isMe, clear, checkCookie }
|
||||
module.exports = { start, isMe, clear, checkCookie, account }
|
||||
@@ -41,5 +41,6 @@ module.exports = Object.freeze({
|
||||
TOPIC_SVR_TOPIC_NEW: 'https://api.vc.bilibili.com/topic_svr/v1/topic_svr/topic_new',
|
||||
V2_REPLAY: "https://api.bilibili.com/x/v2/reply",
|
||||
WEB_INTERFACE_CARD: 'https://api.bilibili.com/x/web-interface/card',
|
||||
WEB_INTERFACE_NAV_STAT: "https://api.bilibili.com/x/web-interface/nav/stat",
|
||||
WEB_INTERFACE_SEARCH_TYPE: 'https://api.bilibili.com/x/web-interface/search/type',
|
||||
})
|
||||
+20
-4
@@ -134,7 +134,7 @@ function post({ url, config, contents, query }) {
|
||||
const bili_client = {
|
||||
/**
|
||||
* 判断是否成功登录
|
||||
* @returns {Promise<boolean>}
|
||||
* @returns {Promise<Object?>}
|
||||
*/
|
||||
async getMyinfo() {
|
||||
const
|
||||
@@ -144,9 +144,25 @@ const bili_client = {
|
||||
res = strToJson(responseText);
|
||||
if (res.code === 0) {
|
||||
GlobalVar.set("myUNAME", res.data.name)
|
||||
return true;
|
||||
return res.data;
|
||||
} else {
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 帐号统计
|
||||
* @returns {Promise<Object?>}
|
||||
*/
|
||||
async getStat() {
|
||||
const
|
||||
responseText = await get({
|
||||
url: API.WEB_INTERFACE_NAV_STAT
|
||||
}),
|
||||
res = strToJson(responseText);
|
||||
if (res.code === 0) {
|
||||
return res.data;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
/**
|
||||
@@ -895,7 +911,7 @@ const bili_client = {
|
||||
},
|
||||
/**
|
||||
* 预约抽奖
|
||||
* @param {number} reserve_id
|
||||
* @param {string} reserve_id
|
||||
* @returns
|
||||
*/
|
||||
async reserve_lottery(reserve_id) {
|
||||
|
||||
@@ -49,14 +49,14 @@ async function main() {
|
||||
await global_var.init(COOKIE, NUMBER);
|
||||
|
||||
/**引入基础功能 */
|
||||
const { start, isMe, clear, checkCookie } = require("./lib/index");
|
||||
const { start, isMe, clear, account, checkCookie } = require("./lib/index");
|
||||
|
||||
log.info('main', '当前为第' + NUMBER + '个账号');
|
||||
log._cache.length = 0
|
||||
|
||||
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 help_msg = "用法: lottery [OPTIONS]\n\nOPTIONS:\n\tstart 启动抽奖\n\tcheck 中奖检查\n\tacount 查看帐号信息\n\tclear 清理动态和关注\n\tupdate 检查更新\n\thelp 帮助信息";
|
||||
const { lottery_loop_wait, check_loop_wait, clear_loop_wait, save_lottery_info_to_file } = require("./lib/data/config");
|
||||
switch (mode) {
|
||||
case 'start':
|
||||
@@ -81,6 +81,10 @@ async function main() {
|
||||
break;
|
||||
case 'help':
|
||||
return help_msg
|
||||
case 'account':
|
||||
log.info('检查帐号信息', '开始运行');
|
||||
await account();
|
||||
break;
|
||||
case undefined:
|
||||
return "未提供以下参数\n\t[OPTIONS]\n\n" + help_msg
|
||||
default:
|
||||
|
||||
@@ -418,6 +418,13 @@ module.exports = Object.freeze({
|
||||
*/
|
||||
clear_quick_remove_attention: false,
|
||||
|
||||
/**
|
||||
* - 快速移除关注
|
||||
* - 不加判断只去除关注
|
||||
* - 移除粉丝数小于指定数量的
|
||||
*/
|
||||
clear_quick_remove_attention_fans_number_smallest: Infinity,
|
||||
|
||||
/**
|
||||
* 是否移除动态
|
||||
*/
|
||||
@@ -429,7 +436,7 @@ module.exports = Object.freeze({
|
||||
clear_remove_attention: true,
|
||||
|
||||
/**
|
||||
* 清除动态延时(毫秒)
|
||||
* 清除延时(毫秒)
|
||||
*/
|
||||
clear_remove_delay: 8000,
|
||||
|
||||
|
||||
+3
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "lottery-auto-script",
|
||||
"version": "2.8.1",
|
||||
"version": "2.8.3",
|
||||
"description": "自动参与B站动态抽奖",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
@@ -9,6 +9,8 @@
|
||||
"clear": "node main.js clear",
|
||||
"check": "node main.js check",
|
||||
"update": "node main.js update",
|
||||
"account": "node main.js account",
|
||||
"help": "node main.js help",
|
||||
"pkg": "bash script/build/pkg.sh",
|
||||
"changelog": "bash script/build/changelog.sh"
|
||||
},
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ for file in "$TARGET_DIR/"*; do
|
||||
cp $TEMPLATE_CONFIG_FILE "$TMPDIR.d/$CONFIG_FILE"
|
||||
cp $TEMPLATE_ENV_FILE "$TMPDIR.d/$ENV_FILE"
|
||||
if [ "$(echo $file | grep '.exe')" ]; then
|
||||
BATS=("start" "check" "clear" "update")
|
||||
BATS=("start" "check" "clear" "account" "update")
|
||||
for item in "${BATS[@]}"; do
|
||||
create_win_bat "${item}" >"$TMPDIR.d/$item.bat"
|
||||
done
|
||||
|
||||
+28
-6
@@ -8,7 +8,7 @@ PACKAGE_UPDATE=("! apt-get update && apt-get --fix-broken install -y && apt-get
|
||||
PACKAGE_INSTALL=("apt-get -y install" "apt-get -y install" "yum -y install" "yum -y install" "yum -y install" "pacman -Sy --noconfirm --needed")
|
||||
PACKAGE_REMOVE=("apt-get -y remove" "apt-get -y remove" "yum -y remove" "yum -y remove" "yum -y remove" "pacman -Rsc --noconfirm")
|
||||
PACKAGE_UNINSTALL=("apt-get -y autoremove" "apt-get -y autoremove" "yum -y autoremove" "yum -y autoremove" "yum -y autoremove" "")
|
||||
CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')" "$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)")
|
||||
CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')" "$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)")
|
||||
SYS="${CMD[0]}"
|
||||
[[ -n $SYS ]] || exit 1
|
||||
for ((int = 0; int < ${#REGEX[@]}; int++)); do
|
||||
@@ -19,12 +19,12 @@ for ((int = 0; int < ${#REGEX[@]}; int++)); do
|
||||
done
|
||||
if ! systemctl is-active docker >/dev/null 2>&1; then
|
||||
if [ $SYSTEM = "CentOS" ]; then
|
||||
${PACKAGE_INSTALL[int]} yum-utils
|
||||
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo &&
|
||||
${PACKAGE_INSTALL[int]} docker-ce docker-ce-cli containerd.io
|
||||
systemctl enable --now docker
|
||||
${PACKAGE_INSTALL[int]} yum-utils
|
||||
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo &&
|
||||
${PACKAGE_INSTALL[int]} docker-ce docker-ce-cli containerd.io
|
||||
systemctl enable --now docker
|
||||
else
|
||||
${PACKAGE_INSTALL[int]} docker.io
|
||||
${PACKAGE_INSTALL[int]} docker.io
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -118,6 +118,28 @@ fi
|
||||
EOF
|
||||
chmod +x check.sh
|
||||
|
||||
echo "create account.sh"
|
||||
cat >account.sh <<EOF
|
||||
#!$(which env) bash
|
||||
NAME=shanmite-lottery-account
|
||||
if [[ -z "\$(docker ps -a | grep \$NAME)" ]]; then
|
||||
docker run \\
|
||||
-v $PWD/$ENV_FILE:/lottery/$ENV_FILE \\
|
||||
-v $PWD/$CONFIG_FILE:/lottery/$CONFIG_FILE \\
|
||||
--network host \\
|
||||
--name \$NAME \\
|
||||
$DOCKER_REPO \\
|
||||
account
|
||||
else
|
||||
echo "container \$NAME already existed"
|
||||
echo "history logs -> docker logs \$NAME"
|
||||
echo "close this -> docker stop \$NAME"
|
||||
echo "start \$NAME"
|
||||
docker start \$NAME
|
||||
fi
|
||||
EOF
|
||||
chmod +x account.sh
|
||||
|
||||
echo "create clear.sh"
|
||||
cat >clear.sh <<EOF
|
||||
#!$(which env) bash
|
||||
|
||||
@@ -39,6 +39,7 @@ EOF
|
||||
create start
|
||||
create check
|
||||
create clear
|
||||
create account
|
||||
|
||||
cd $NAME
|
||||
npm i
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ const util = require('./util');
|
||||
const { parseDynamicCard } = require('../lib/core/searcher');
|
||||
|
||||
(async () => {
|
||||
assert(await bili_client.getMyinfo());
|
||||
assert.notEqual(await bili_client.getMyinfo(), null);
|
||||
|
||||
await util.par_run([0, 3], [
|
||||
// 0
|
||||
|
||||
@@ -4,7 +4,7 @@ const searcher = require("../lib/core/searcher");
|
||||
const util = require('./util');
|
||||
|
||||
(async () => {
|
||||
await util.par_run([0, 1, 2, 3, 4, 5, 6], [
|
||||
await util.par_run([0, 1, 2, 3, 4, 5, 6, 7, 8], [
|
||||
// 0
|
||||
async () => {
|
||||
let info = await bili_client.getOneDynamicByDyid("728424890210713624");
|
||||
@@ -12,7 +12,7 @@ const util = require('./util');
|
||||
},
|
||||
// 1
|
||||
async () => {
|
||||
let info = await bili_client.getOneDynamicByDyid("728455586333589522");
|
||||
let info = await bili_client.getOneDynamicByDyid("768874900850999300");
|
||||
assert(searcher.parseDynamicCard(info).origin_is_charge_lottery);
|
||||
},
|
||||
// 2
|
||||
@@ -50,6 +50,18 @@ const util = require('./util');
|
||||
const card = searcher.parseDynamicCard(dy)
|
||||
assert.notEqual(card.description + "", undefined + "");
|
||||
},
|
||||
// 7
|
||||
async () => {
|
||||
const dy = await bili_client.getOneDynamicByDyid("832208853440397352");
|
||||
const card = searcher.parseDynamicCard(dy)
|
||||
assert.equal(card.reserve_id, "3106984");
|
||||
},
|
||||
// 8
|
||||
async () => {
|
||||
const dy = await bili_client.getOneDynamicByDyid("832966468497834066");
|
||||
const card = searcher.parseDynamicCard(dy)
|
||||
assert.equal(card.origin_reserve_id, "3106984");
|
||||
},
|
||||
])
|
||||
|
||||
console.log("dynamic_card.test ... ok!");
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ const { parseDynamicCard } = require('../lib/core/searcher');
|
||||
await util.par_run([], [
|
||||
// 0
|
||||
async () => {
|
||||
assert(await bili_client.getMyinfo());
|
||||
assert.notEqual(await bili_client.getMyinfo(), null);
|
||||
|
||||
const rid = parseDynamicCard(await bili_client.getOneDynamicByDyid("551416252543796684")).rid_str;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user