Compare commits

..
73 Commits
Author SHA1 Message Date
shanmite df3e97d3bf ci: fix "an artifact with this name already exists on the workflow run" 2024-04-25 09:29:58 +08:00
shanmite 5a86a0407a docs: 更新CHANGELOG 2024-04-25 08:57:47 +08:00
NevideblaandGitHub d9f6bf247c feat: 中奖检测屏蔽自动回复 (#381)
* 中奖检测屏蔽自动回复

根据消息类型屏蔽掉关注自动回复和营销广告,避免误判

* fix
2024-04-25 08:55:49 +08:00
shanmite ded981e4d7 fix: 动态卡片解析出错导致程序停止 2024-04-25 08:46:07 +08:00
ypw96andGitHub 93d372761a fix: searcher.js typo fix (#379) 2024-04-22 14:30:54 +08:00
shanmite e9c341dce0 docs: 更新CHANGELOG 2024-04-12 14:49:42 +08:00
shanmite 60e211ef3a fix: 读取uid出错 (#369)
Fixed #369
2024-04-12 14:47:59 +08:00
shanmite 5aa50484fe docs: 更新CHANGELOG 2024-04-12 07:59:55 +08:00
shanmite 5b33ae3bb6 fix: 读取uid出错 (#369)
Fixed #369
2024-04-12 07:59:15 +08:00
7e4650ced4 feat: env可自定义UA (#371)
Co-authored-by: 简佳 <[email protected]>
2024-04-10 17:17:05 +08:00
shanmite 364bcd1325 docs: 更新CHANGELOG 2024-04-05 10:12:55 +08:00
shanmite 469a6dc7b5 fix: add getOneDynamicByDyid v1 2024-04-05 10:10:01 +08:00
shanmite 7a8682ce76 docs: 更新CHANGELOG 2024-03-25 16:16:15 +08:00
shanmite 7b6356ac25 fix: 风控导致动态全为过时 2024-03-25 15:44:23 +08:00
shanmite d337fb235d fix: 查询动态详情的接口失效 (#349) 2024-03-25 15:15:20 +08:00
shanmite d9dba6f0ff fix: Cannot read properties of null (reading 'is_liked') 2024-03-25 10:43:38 +08:00
shanmite eafa7c7ae4 fix: Cannot read properties of null (reading 'length') (#360)
Fixed #360
2024-03-25 10:35:22 +08:00
ypw96andGitHub e2976cc9b7 docs: 文档更新cookie获取方式 (#357)
* Add files via upload

* Update README.md

新增COOKIE获取方式
2024-03-25 10:22:16 +08:00
shanmite 759a87140e docs: 更新CHANGELOG 2024-03-09 15:13:51 +08:00
shanmite f5bdd289d5 fix: update api getOneDynamicByDyid 2024-03-09 15:13:15 +08:00
ypw96andGitHub cb6fad05e4 fix: get_dynamic_detail api (#351)
* Update api.bili.js

* Update api.bili.js

* Update bili.js
2024-03-06 21:30:34 +08:00
shanmiteandGitHub 780a3a9840 fix: update get_dynamic_detail api (#350)
* Update api.bili.js

* Update bili.js

* Update bili.js
2024-03-06 19:36:18 +08:00
shanmite 92fab1774d docs: 更新CHANGELOG 2023-12-01 10:22:40 +08:00
shanmite addb9c65fe fix: ghproxy.com->mirror.ghproxy.com (#333)
Fixed #333
2023-12-01 10:21:08 +08:00
shanmite b86e756520 fix: at错位 2023-12-01 10:16:11 +08:00
shanmite f3af8dff17 docs: 更新CHANGELOG 2023-11-25 13:46:42 +08:00
shanmite 5d30178bd3 ci: docker构建 2023-11-25 11:21:31 +08:00
shanmite 0c610701cb fix: 评论并转发 (#259)
Fixed #259
2023-11-25 10:42:17 +08:00
shanmite 6dfee7efb8 fix: 出现帐号未登录错误时自动跳转下一个帐号 2023-11-25 10:20:13 +08:00
shanmite 13e847825b docs: 更新CHANGELOG 2023-09-22 09:57:36 +08:00
shanmite 6496a8f0bc fix: fs.close 2023-09-22 09:55:07 +08:00
shanmite 198a69011c docs: 更新CHANGELOG 2023-09-22 07:54:05 +08:00
shanmite e32c3c9e8b fix: 已经关注用户未转发 2023-09-22 07:51:35 +08:00
shanmite 3bd77b3114 fix: fs.close 2023-09-22 07:38:40 +08:00
shanmite 6adc42ae23 docs: 更新CHANGELOG 2023-09-09 16:45:07 +08:00
shanmite 588feba10b docs: update readme 2023-09-09 16:44:17 +08:00
shanmite 5d5858f82b fix: 无法已读未关注未读私信 2023-09-09 16:30:58 +08:00
andywang425andshanmite 1526519e86 docs: 添加gotify推送说明 2023-09-03 17:56:08 +08:00
andywang425andshanmite 69c297ecaa feat: 添加Gotify推送 2023-09-02 18:26:18 +08:00
andywang425andshanmite 201770573e feat: autoAttention API增加对重复关注的处理 2023-09-02 18:26:18 +08:00
shanmite 16c113fd87 docs: update readme 2023-09-01 14:46:59 +08:00
shanmite 50887948b4 docs: 更新CHANGELOG 2023-09-01 09:43:31 +08:00
shanmite 54af8444db fix: 专栏无法获取 2023-09-01 09:42:58 +08:00
shanmite b568208990 docs: 更新CHANGELOG 2023-08-30 16:25:36 +08:00
shanmite 62768ddc71 fix: 修改win脚本 2023-08-30 16:17:28 +08:00
shanmite 101df0a7a6 fix: login等待时间过长 2023-08-30 13:59:58 +08:00
shanmite f8829b5d4b fix: 清理动态检索动态延时 2023-08-29 10:30:18 +08:00
shanmite be6552a321 docs: 更新CHANGELOG 2023-08-29 08:43:21 +08:00
shanmite 83e19d44e3 docs: 扫码登陆使用说明 2023-08-29 08:41:32 +08:00
KirDeerandshanmite c238c27d7d fix:多账号login添加时延进行间隔 2023-08-29 08:14:01 +08:00
KirDeerandshanmite 8addc9078d fix:登录跳过执行正常状态的账号 2023-08-29 08:14:01 +08:00
KirDeerandshanmite 288851b491 feat: 扫码登录获取移动端的CK更新账号,带sid可减小掉号频率 2023-08-28 10:35:07 +08:00
shanmite ddcfceecef fix: 移除公共黑名单设置 2023-08-28 09:05:33 +08:00
shanmite 49ef4070ca docs: 更新CHANGELOG 2023-08-26 08:37:03 +08:00
shanmite 0024b19cbf feat: 移除远程设置启用自动更新 2023-08-26 08:36:12 +08:00
shanmite 04c25a88fc docs: 更新CHANGELOG 2023-08-25 09:31:42 +08:00
shanmite 9ab605a186 feat: 新增本地dyids抽奖新信息获取方式 (#311)(#287)
Fixed #311
2023-08-25 09:27:50 +08:00
shanmite a83c5ab91a fix: extend_json undefined 2023-08-24 13:45:52 +08:00
shanmite 092bd843e1 docs: 更新CHANGELOG 2023-08-23 16:28:35 +08:00
shanmite 2f2eaabc57 fix: 预约抽奖包月抽奖识别异常 (#288)
Fixed #288
2023-08-23 16:20:45 +08:00
shanmite da8d460dc6 docs: 更新CHANGELOG 2023-08-18 10:15:22 +08:00
shanmite 3825be45df feat: 查看帐号信息 2023-08-18 10:13:18 +08:00
shanmite 248c78d669 feat: 快速移除关注模式新增粉丝数限制 (#305)
Fixed #305
2023-08-05 16:37:17 +08:00
shanmite 3d90e11b96 docs: 更新CHANGELOG 2023-07-27 10:49:47 +08:00
shanmite d44981b7eb fix: 随机cookie参数buvid3 2023-07-27 10:47:24 +08:00
shanmite 3bfc93fd4e fix: 目前回复无法正常推送 (#302)
Fixed #302
2023-07-27 10:15:35 +08:00
shanmite ef8366be66 fix: tg推送代理设置出错 (#298)
Fixed #289
2023-07-10 10:48:48 +08:00
shanmite a7e31b484e docs: update 2023-07-10 09:49:36 +08:00
shanmite f4f45c5107 fix: cookie参数buvid3错误导致专栏获取滞后 2023-07-04 13:37:43 +08:00
shanmite c8876a7fd1 docs: 更新CHANGELOG 2023-06-30 14:50:21 +08:00
shanmite 2f935bbebb chore: update env.js 2023-06-30 14:49:19 +08:00
shanmite eec22ffd76 feat: 验证码自动识别 2023-06-30 14:42:43 +08:00
shanmite 909fb83f79 chore: update qinglong script 2023-06-30 08:05:00 +08:00
40 changed files with 1028 additions and 456 deletions
+2 -2
View File
@@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
@@ -31,4 +31,4 @@ jobs:
with:
push: true
tags: ${{ secrets.DOCKERHUB_REPO }}
platforms: "linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/ppc64le,linux/s390x"
platforms: "linux/amd64,linux/arm64"
+1 -1
View File
@@ -10,7 +10,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Mirror + trigger CI
+1 -1
View File
@@ -12,7 +12,7 @@ jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
+9 -9
View File
@@ -26,20 +26,20 @@ jobs:
nodev: 18
- platform: win
nodev: 18
- platform: win
nodev: 12
# - platform: win
# nodev: 12
steps:
- name: "Checkout codes"
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: "Use Node.js"
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: "*"
- name: "Pkg this"
run: |
npm run pkg "node${{ matrix.nodev }}-${{ matrix.platform }}-x64"
- name: "Upload to artifact"
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: node${{ matrix.nodev }}-${{ matrix.platform }}-x64
path: "dist/*.zip"
@@ -62,14 +62,14 @@ jobs:
- platform: alpine
steps:
- name: "Checkout codes"
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: "Pkg this"
run: |
npm run pkg "${{ matrix.platform }}-arm64"
npm run pkg "node18-${{ matrix.platform }}-arm64"
- name: "Upload to artifact"
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: arm64
name: node18-${{ matrix.platform }}-arm64
path: "dist/*.zip"
- name: "Upload to release draft"
uses: xresloader/upload-to-github-release@v1
+1
View File
@@ -3,6 +3,7 @@ node_modules/
tests/
dyids/
lottery_info/
lottery_dyids/
dist/
.env
*.log
+133
View File
@@ -1,5 +1,138 @@
<!-- markdownlint-disable MD036 MD024-->
# CHANGELOG
## 主要变化(2.8.19)
* d9f6bf2 feat: 中奖检测屏蔽自动回复 (#381)
* ded981e fix: 动态卡片解析出错导致程序停止
* 93d3727 fix: searcher.js typo fix (#379)
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.8.17)
* 60e211e fix: 读取uid出错 (#369)
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.8.17)
* 5b33ae3 fix: 读取uid出错 (#369)
* 7e4650c feat: env可自定义UA (#371)
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.8.16)
* 469a6dc fix: add getOneDynamicByDyid v1
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.8.15)
* 7b6356a fix: 风控导致动态全为过时
* d337fb2 fix: 查询动态详情的接口失效 (#349)
* d9dba6f fix: Cannot read properties of null (reading 'is_liked')
* eafa7c7 fix: Cannot read properties of null (reading 'length') (#360)
* e2976cc docs: 文档更新cookie获取方式 (#357)
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.8.14)
* f5bdd28 fix: update api getOneDynamicByDyid
* cb6fad0 fix: get_dynamic_detail api (#351)
* 780a3a9 fix: update get_dynamic_detail api (#350)
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.8.13)
* addb9c6 fix: ghproxy.com->mirror.ghproxy.com (#333)
* b86e756 fix: at错位
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.8.12)
* 5d30178 ci: docker构建
* 0c61070 fix: 评论并转发 (#259)
* 6dfee7e fix: 出现帐号未登录错误时自动跳转下一个帐号
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.8.11)
* 6496a8f fix: fs.close
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.8.10)
* e32c3c9 fix: 已经关注用户未转发
* 3bd77b3 fix: fs.close
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.8.9)
* 588feba docs: update readme
* 5d5858f fix: 无法已读未关注未读私信
* 1526519 docs: 添加gotify推送说明
* 69c297e feat: 添加Gotify推送
* 2017705 feat: autoAttention API增加对重复关注的处理
* 16c113f docs: update readme
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.8.8)
* 54af844 fix: 专栏无法获取
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.8.7)
* 62768dd fix: 修改win脚本
* 101df0a fix: login等待时间过长
* f8829b5 fix: 清理动态检索动态延时
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.8.6)
* 83e19d4 docs: 扫码登陆使用说明
* c238c27 fix:多账号login添加时延进行间隔
* 8addc90 fix:登录跳过执行正常状态的账号
* 288851b feat: 扫码登录获取移动端的CK更新账号,带sid可减小掉号频率
* ddcfcee fix: 移除公共黑名单设置
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.8.5)
* 0024b19 feat: 移除远程设置启用自动更新
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.8.4)
* 9ab605a feat: 新增本地dyids抽奖新信息获取方式 (#311)(#287)
* a83c5ab fix: extend_json undefined
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(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)
* ef8366b fix: tg推送代理设置出错 (#298)
* a7e31b4 docs: update
* f4f45c5 fix: cookie参数buvid3错误导致专栏获取滞后
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.8.0)
* 2f935bb chore: update env.js
* eec22ff feat: 验证码自动识别
* 909fb83 chore: update qinglong script
* 41b0369 ci: fix pkg.yml
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
## 主要变化(2.7.11)
* 5a3c16d fix: 专栏获取内容不正确,需要排除推荐内容 (#293)
+69 -28
View File
@@ -3,16 +3,19 @@
- [AutoScript](#autoscript)
- [操作步骤](#操作步骤)
- [获取COOKIE](#获取cookie)
- [扫码登陆](#扫码登陆)
- [手动获取](#手动获取)
- [本地运行](#本地运行)
- [可执行文件](#可执行文件)
- [以源码方式运行](#以源码方式运行)
- [Docker](#docker)
- [青龙面板](#青龙面板)
- [防重复转发(可选)](#防重复转发可选)
- [检测中奖](#检测中奖)
- [检测未读信息, 已读未读信息](#检测未读信息-已读未读信息)
- [中奖推送(可选)](#中奖推送可选)
- [中奖推送](#中奖推送)
- [设置说明](#设置说明)
- [评论验证码识别](#评论验证码识别)
- [其他](#其他)
- [Awesome](#awesome)
[Github仓库链接](https://github.com/shanmiteko/LotteryAutoScript)
@@ -53,6 +56,43 @@
### 获取COOKIE
#### 扫码登陆
`env.js`文件填`COOKIE`的对应位置写入`"DedeUserID=你的UID"`即可使用`lottery login`扫码自动获取Cookie
`COOKIE`中包含`DedeUserID=你的UID`的都会被自动替换
#### 手动获取
第一种
进入[B站主页](https://www.bilibili.com/)点击个人头像进入个人主页获取Cookie用于登录
Chrome浏览器:
进入个人主页后
1. `F12`打开控制台
2. F5刷新
3. 根据图中找到network/网络 搜索nav,点击找到的nav,点标头,下滑,找到COOKIE全部复制
![image](doc/pic/getCookies2.png)
注意!!!!!!!!!!!
注意!!!!!!!!!!!
注意!!!!!!!!!!!
所有网页端获取的COOKIE,每次打开网页端时,都会有概率刷新COOKIE,点击退出账号则会退出当前COOKIE。可以利用Chrome内核的浏览器创建多用户,专门用于获取COOKIE。
注意!!!!!!!!!!!
注意!!!!!!!!!!!
注意!!!!!!!!!!!
第二种
进入[B站主页](https://www.bilibili.com/)获取Cookie用于登录
Chrome浏览器:
@@ -73,7 +113,7 @@ Chrome浏览器:
.cookie
.split(/\s*;\s*/)
.map(it => it.split('='))
.filter(it => ['DedeUserID','bili_jct', 'SESSDATA'].indexOf(it[0]) > -1)
.filter(it => ['DedeUserID','bili_jct', 'SESSDATA', 'buvid3'].indexOf(it[0]) > -1)
.map(it => it.join('='))
.join('; ')
.split()
@@ -82,7 +122,9 @@ Chrome浏览器:
也可以采用**其他方式获取**所需的Cookie
只需含有 `DedeUserID=...;SESSDATA=...;bili_jct=...` 三项即可
只需含有 `DedeUserID=...;SESSDATA=...;bili_jct=...;buvid3=...` 即可
buvid3亦可不填 使用随机生成值
(分号分割, 不要换行, 顺序随意)
@@ -109,23 +151,22 @@ Chrome浏览器:
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 检查更新
login 扫码登录更新CK
help 帮助信息
```
7. 运行截图
![lottery_start](https://raw.githubusercontents.com/shanmiteko/LotteryAutoScript/main/doc/pic/lottery_start.png)
1. 运行截图
![lottery_start](https://raw.githubusercontents.com/shanmiteko/LotteryAutoScript/main/doc/pic/lottery_start.png)
#### 以源码方式运行
@@ -145,14 +186,6 @@ Chrome浏览器:
----------------------------------------
## 防重复转发(可选)
- 脚本将转发过的动态和被过滤的动态都写入`dyids/dyid*.txt`文件中
- 是否点赞
----------------------------------------
## 检测中奖
### 检测未读信息, 已读未读信息
@@ -165,7 +198,7 @@ Chrome浏览器:
关键词有限 可能会有**漏掉**的或**误报**
### 中奖推送(可选)
### 中奖推送
> 填写在env.js内
@@ -199,11 +232,19 @@ Chrome浏览器:
| `SMTP_USER` | 电子邮件 | 发送方的电子邮件 如: `xxxxxxxxx@qq.com` |
| `SMTP_PASS` | 电子邮件 | smtp服务对应的授权码 |
| `SMTP_TO_USER` | 电子邮件 | 接收方电子邮件 |
| `GOTIFY_URL` | gotify推送 | gotify消息推送地址(例如 http://localhost:8008/message)[官方文档](https://gotify.net/docs/) |
| `GOTIFY_APPKEY` | gotify推送 | 一个gotify application的token[官方文档](https://gotify.net/docs/) |
----------------------------------------
## 设置说明
### 评论验证码识别
[点击跳转](doc/chat_captcha_orc.md)
### 其他
详见[env.example.js](./env.example.js)文件内部注释
详见[my_config.example.js](./my_config.example.js)文件内部注释
+18
View File
@@ -0,0 +1,18 @@
使用此功能前需启动OCR服务
## 拉取镜像
```
docker pull shanmite/ocr_api_server
```
## 启动容器
```
docker run -p 9898:9898 -d ocr_api_server
```
### 非docker启动方式
![ocr server](pic/ocr1.png)
[ocr_api_server](https://github.com/shanmiteko/ocr_api_server)
![start](pic/ocr0.png)
Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 328 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 292 KiB

+1 -1
View File
@@ -1,7 +1,7 @@
1.初始化
```bash
curl -fsSL https://cdn.staticaly.com/gh/shanmiteko/LotteryAutoScript/main/script/docker/init.sh | sudo sh
curl -fsSL https://ghproxy.com/https://raw.githubusercontent.com/shanmiteko/LotteryAutoScript/main/script/docker/init.sh | sudo bash
```
进入`lottery`文件夹
+15 -14
View File
@@ -5,20 +5,20 @@ module.exports = Object.freeze({
* - `NOTE` 帐号备注
* - `NUMBER` 表示是第几个账号
* - `CLEAR` 是否启用清理功能
* - `ACCOUNT_UA` 账号UA, 可在浏览器控制台输入 navigator.userAgent 查看
* ## 高级功能
* - `ENABLE_CHAT_CAPTCHA_OCR` 开启评论验证码识别 使用方法见README
* - `ENABLE_MULTIPLE_ACCOUNT` 是否启用多账号
* - `MULTIPLE_ACCOUNT_PARM` 多账号参数(JSON格式)
* ## 代理相关
* - `ENABLE_PROXY` 启用代理
* - `XMDL_ORDERNNO` 熊猫动态代理订单号
* - `XMDL_SECRET` 熊猫动态代理密钥
* - `MULTIPLE_ACCOUNT_PARM` 多账号参数(JSON格式) <不推荐使用
* ## 调试相关
* - `LOTTERY_LOG_LEVEL` 输出日志等级 Error<Warn<Info<Debug 1<2<3<4
* - `NOT_GO_LOTTERY` 关闭抽奖行为
*
* ## 多账号
* 1. 将 ENABLE_MULTIPLE_ACCOUNT 的值改为true
* 2. 将账号信息依次填写于 multiple_account_parm 中, 参考例子类推
* - `WAIT` 表示下一个账号运行等待时间(毫秒)
*
*
* **按顺序依次执行, 防止访问频繁封禁IP**
*/
account_parm: {
@@ -26,13 +26,11 @@ module.exports = Object.freeze({
NOTE: "",
NUMBER: 1,
CLEAR: true,
ACCOUNT_UA: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36",
ENABLE_CHAT_CAPTCHA_OCR: "",
ENABLE_MULTIPLE_ACCOUNT: false,
ENABLE_PROXY: "",
XMDL_ORDERNNO: "",
XMDL_SECRET: "",
MULTIPLE_ACCOUNT_PARM: "",
LOTTERY_LOG_LEVEL: 3,
NOT_GO_LOTTERY: ""
@@ -41,7 +39,7 @@ module.exports = Object.freeze({
/**
* 为防止环境变量过长, 请将多账号填在此处
* 以 **大括号内容** 为模板依次复制(包含大括号),逗号分割
*
*
* ```txt
* [
* {
@@ -63,7 +61,8 @@ module.exports = Object.freeze({
NOTE: "",
NUMBER: 1,
CLEAR: true,
WAIT: 60 * 1000
WAIT: 60 * 1000,
ACCOUNT_UA: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"
}
],
@@ -96,6 +95,8 @@ module.exports = Object.freeze({
SMTP_PORT: "",
SMTP_USER: "",
SMTP_PASS: "",
SMTP_TO_USER: ""
SMTP_TO_USER: "",
GOTIFY_URL: "",
GOTIFY_APPKEY: ""
}
})
})
+15
View File
@@ -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 }
+1 -2
View File
@@ -84,12 +84,11 @@ async function isMe(num) {
}
if (follow_unread) {
log.info('中奖检测', '<-- 正在检查已关注者的私信')
await check(1)
}
if (unfollow_unread) {
log.info('中奖检测', '<-- 正在检查未关注者的私信')
await check(2)
}
await check("1")
log.info('中奖检测', '--> OK');
}
if (desp) {
+15 -8
View File
@@ -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);
@@ -104,6 +108,7 @@ async function clear() {
log.error("清理失败", "出现错误")
break
}
/* 延时 */
await delay(clear_remove_delay);
} else {
@@ -120,6 +125,8 @@ async function clear() {
log.info('清理动态', `此动态类型为${type} != 要清理的动态类型${clear_dynamic_type}`)
}
}
/* 延时 */
await delay(clear_remove_delay);
log.info('清理动态', `${page + 1}页(${allModifyDynamicResArray.length})中的转发动态与关注全部处理成功`)
if (next_offset === '0' || !success) break;
}
+27 -26
View File
@@ -26,7 +26,8 @@ class Monitor extends Searcher {
['UIDs', this.getLotteryInfoByUID.bind(this)],
['TAGs', this.getLotteryInfoByTag.bind(this)],
['Articles', this.getLotteryInfoByArticle.bind(this)],
['APIs', this.getLotteryInfoByAPI.bind(this)]
['APIs', this.getLotteryInfoByAPI.bind(this)],
['TxT', this.getLotteryInfoByTxT.bind(this)]
]);
}
/**
@@ -55,6 +56,9 @@ class Monitor extends Searcher {
case 1001:
event_bus.emit('Turn_off_the_Monitor', '评论失败')
break;
case 1010:
event_bus.emit('Turn_off_the_Monitor', '已掉号')
break;
case 1004:
event_bus.emit('Turn_off_the_Monitor', '需要输入验证码')
break
@@ -62,7 +66,7 @@ class Monitor extends Searcher {
event_bus.emit('Turn_off_the_Monitor', '关注出错')
break;
case 3001:
event_bus.emit('Turn_off_the_Monitor', '分区移动出错')
event_bus.emit('Turn_off_the_Monitor', '分区移动出错 可于设置处关闭移动分区')
break;
case 2004:
case 4005:
@@ -193,7 +197,6 @@ class Monitor extends Searcher {
case 1007:
case 1008:
case 1009:
case 1010:
case 1011:
case 2002:
case 2003:
@@ -216,6 +219,7 @@ class Monitor extends Searcher {
is_outof_maxfollow = 2005
break;
case 1001:
case 1010:
case 1004:
case 2001:
case 3001:
@@ -280,7 +284,6 @@ class Monitor extends Searcher {
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;
@@ -367,7 +370,7 @@ class Monitor extends Searcher {
}
/* 超过指定时间退出 */
if (now_ts - create_time > max_create_time * 86400) {
if (create_time && now_ts - create_time > max_create_time * 86400) {
log.info("筛选动态", `过时动态(https://t.bilibili.com/${dyid})`)
return false
}
@@ -398,25 +401,12 @@ class Monitor extends Searcher {
isSendChat =
(hasOfficialLottery && chatmodel[0] === '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, type, isRelayDynamic, key_words, has_key_words, blockword, isBlock, isLottery, isSendChat })
if (
new_blacklist.some(id => keys.some(key => {
blacklist.split(',').some(id => keys.some(key => {
if (key + '' === id) {
log.info("筛选动态", `黑名单匹配(${id})(https://t.bilibili.com/${dyid})`)
return true
@@ -471,7 +461,6 @@ class Monitor extends Searcher {
}
if (isLottery) {
const { uname_map = {} } = global_var.get("remoteconfig")
let onelotteryinfo = {};
onelotteryinfo.isOfficialLottery = hasOfficialLottery;
@@ -488,7 +477,7 @@ class Monitor extends Searcher {
let
/**转发评语 */
RandomStr = (getRandomOne(relays) || "!!!")
.replace(/\$\{uname\}/g, uname_map[real_uid] || uname),
.replace(/\$\{uname\}/g, uname),
/**控制字段 */
new_ctrl = [];
@@ -541,7 +530,7 @@ class Monitor extends Searcher {
if (isSendChat) {
onelotteryinfo.rid = rid
onelotteryinfo.chat = (getRandomOne(chats) || "!!!")
.replace(/\$\{uname\}/g, uname_map[real_uid] || uname)
.replace(/\$\{uname\}/g, uname)
}
alllotteryinfo.push(onelotteryinfo);
@@ -607,21 +596,25 @@ class Monitor extends Searcher {
.replace(
new RegExp(copy_chat[0], 'g'),
global_var.get("myUNAME") || '')
} else {
if (is_repost_then_chat) {
chat = chat + relay_chat
}
}
status = await retryfn(
6,
[4],
() => bili.sendChat(
() => bili.sendChatWithOcr(
rid,
is_repost_then_chat ? relay_chat.split('//')[0] : chat,
chat,
chat_type
)
)
if (status === 8 ||
status === 9) {
status = await bili.sendChat(
status = await bili.sendChatWithOcr(
rid,
"[doge][doge][doge][doge][doge]",
chat_type
@@ -638,6 +631,10 @@ class Monitor extends Searcher {
if (uid.length) {
await try_for_each(uid, async (u) => {
status = await bili.autoAttention(u)
if (status === 6) {
status = 0;
return false
}
if (status) {
log.warn("抽奖信息", `dyid: ${dyid}, uid: ${u}`)
return true
@@ -678,7 +675,11 @@ class Monitor extends Searcher {
status = await retryfn(
5,
[3, 4],
() => bili.autoRelay(global_var.get("myUID"), dyid, relay_chat, ctrl)
() => bili.autoRelay(
global_var.get("myUID"),
dyid,
relay_chat,
ctrl)
)
if (status) {
+171 -85
View File
@@ -62,79 +62,33 @@ function parseDynamicCard(dynamic_detail_card) {
const { strToJson } = utils;
/**临时储存单个动态中的信息 */
let obj = {};
const { desc, card, extension, extend_json, display = {} } = dynamic_detail_card
, { is_liked = 1, user_profile = {} } = desc
, { info = {} } = user_profile
, cardToJson = strToJson(card)
, extendjsonToJson = strToJson(extend_json)
, { add_on_card_info = [] } = display
, { item } = cardToJson;
const dy_type2chat_type = new Map([[1, 17], [2, 11], [4, 17], [8, 1], [64, 12]]);
/* 转发者的UID */
obj.uid = desc.uid
/* 转发者的name */
obj.uname = info.uname || ''
/* 动态是否点过赞 */
obj.is_liked = is_liked > 0
/* 动态的ts10 */
obj.create_time = desc.timestamp
/* 动态类型 */
obj.type = desc.type
/* 用于发送评论 */
obj.rid_str = desc.rid_str.length > 12 ? desc.dynamic_id_str : desc.rid_str;
/* 用于发送评论 */
obj.chat_type = dy_type2chat_type.get(obj.type) || 0;
/* 转发者的动态ID !!!!此为大数需使用字符串值,不然JSON.parse()会有丢失精度 */
obj.dynamic_id = desc.dynamic_id_str;
/* 定位@信息 */
obj.ctrl = (extendjsonToJson.ctrl) || [];
/* 预约抽奖信息 */
if (add_on_card_info.length > 0) {
const [status, oid_str, text] = add_on_card_info
.filter(it => typeof it.reserve_attach_card !== 'undefined'
&& typeof it.reserve_attach_card.reserve_lottery !== 'undefined'
&& typeof it.reserve_attach_card.reserve_button !== 'undefined')
.map(({ reserve_attach_card }) => [
reserve_attach_card.reserve_button.status,
reserve_attach_card.oid_str,
reserve_attach_card.reserve_lottery.text])[0] || [];
if (status === 1) {
obj.reserve_id = oid_str;
obj.reserve_lottery_text = text;
}
}
if (JSON.stringify(add_on_card_info).match(/充电专属抽奖/)) {
obj.is_charge_lottery = true
}
/* 是否有官方抽奖 */
obj.hasOfficialLottery = extension && extension.lott && true;
/* 转发者的描述 纯文字内容 图片动态描述 后两个分别是视频动态的描述和视频本身的描述*/
obj.description =
(item && ((item.content || '') + (item.description || '')))
|| (
(cardToJson.dynamic || '')
+ (cardToJson.desc || '')
+ (cardToJson.vest && cardToJson.vest.content || '')
)
|| '';
/* 转发 */
if (obj.type === 1) {
const { origin_extension, origin } = cardToJson
, originToJson = strToJson(origin)
, { add_on_card_info = [] } = display.origin || {}
, { user, item } = originToJson;
/* 源动态的ts10 */
obj.origin_create_time = desc.origin.timestamp;
/* 被转发者的UID */
obj.origin_uid = desc.origin.uid;
/* 源动态类型 */
obj.origin_type = desc.orig_type
/* 被转发者的rid(用于发评论) */
obj.origin_rid_str = desc.origin.rid_str.length > 12 ? desc.origin.dynamic_id_str : desc.origin.rid_str;
try {
const { desc = {}, card = "{}", extension = {}, extend_json = "{}", display = {} } = dynamic_detail_card
, { is_liked = 1, user_profile = {} } = desc || {}
, { info = {} } = user_profile || {}
, cardToJson = strToJson(card)
, extendjsonToJson = strToJson(extend_json)
, { add_on_card_info = [] } = display || {}
, { item = {} } = cardToJson;
const dy_type2chat_type = new Map([[1, 17], [2, 11], [4, 17], [8, 1], [64, 12]]);
/* 转发者的UID */
obj.uid = desc.uid
/* 转发者的name */
obj.uname = info.uname || ''
/* 动态是否点过赞 */
obj.is_liked = is_liked > 0
/* 动态的ts10 */
obj.create_time = desc.timestamp
/* 动态类型 */
obj.type = desc.type
/* 用于发送评论 */
obj.origin_chat_type = dy_type2chat_type.get(obj.origin_type) || 0
/* 被转发者的动态的ID !!!!此为大数需使用字符串值,不然JSON.parse()会有丢失精度 */
obj.origin_dynamic_id = desc.orig_dy_id_str;
obj.rid_str = desc.rid_str.length > 12 ? desc.dynamic_id_str : desc.rid_str;
/* 用于发送评论 */
obj.chat_type = dy_type2chat_type.get(obj.type) || 0;
/* 转发者的动态ID !!!!此为大数需使用字符串值,不然JSON.parse()会有丢失精度 */
obj.dynamic_id = desc.dynamic_id_str;
/* 定位@信息 */
obj.ctrl = (extendjsonToJson.ctrl) || [];
/* 预约抽奖信息 */
if (add_on_card_info.length > 0) {
const [status, oid_str, text] = add_on_card_info
@@ -146,22 +100,89 @@ function parseDynamicCard(dynamic_detail_card) {
reserve_attach_card.oid_str,
reserve_attach_card.reserve_lottery.text])[0] || [];
if (status === 1) {
obj.origin_reserve_id = oid_str;
obj.origin_reserve_lottery_text = text;
obj.reserve_id = oid_str;
obj.reserve_lottery_text = text;
}
}
if (JSON.stringify(add_on_card_info).match(/充电专属抽奖/)) {
obj.origin_is_charge_lottery = true
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
}
/* 是否有官方抽奖 */
obj.origin_hasOfficialLottery = origin_extension && origin_extension.lott;
/* 转发者的name */
obj.origin_uname = (user && (user.name || user.uname)) || '';
/* 被转发者的描述 */
obj.origin_description =
(item && (item.content || '' + item.description || ''))
|| (originToJson.dynamic || '' + originToJson.desc || '')
obj.hasOfficialLottery = extension && extension.lott && true;
/* 转发者的描述 纯文字内容 图片动态描述 后两个分别是视频动态的描述和视频本身的描述*/
obj.description =
(item && ((item.content || '') + (item.description || '')))
|| (
(cardToJson.dynamic || '')
+ (cardToJson.desc || '')
+ (cardToJson.vest && cardToJson.vest.content || '')
)
|| '';
/* 转发 */
if (obj.type === 1) {
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;
/* 被转发者的UID */
obj.origin_uid = desc.origin.uid;
/* 源动态类型 */
obj.origin_type = desc.orig_type
/* 被转发者的rid(用于发评论) */
obj.origin_rid_str = desc.origin.rid_str.length > 12 ? desc.origin.dynamic_id_str : desc.origin.rid_str;
/* 用于发送评论 */
obj.origin_chat_type = dy_type2chat_type.get(obj.origin_type) || 0
/* 被转发者的动态的ID !!!!此为大数需使用字符串值,不然JSON.parse()会有丢失精度 */
obj.origin_dynamic_id = desc.orig_dy_id_str;
/* 预约抽奖信息 */
if (add_on_card_info.length > 0) {
const [status, oid_str, text] = add_on_card_info
.filter(it => typeof it.reserve_attach_card !== 'undefined'
&& typeof it.reserve_attach_card.reserve_lottery !== 'undefined'
&& typeof it.reserve_attach_card.reserve_button !== 'undefined')
.map(({ reserve_attach_card }) => [
reserve_attach_card.reserve_button.status,
reserve_attach_card.oid_str,
reserve_attach_card.reserve_lottery.text])[0] || [];
if (status === 1) {
obj.origin_reserve_id = oid_str;
obj.origin_reserve_lottery_text = text;
}
}
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
}
/* 是否有官方抽奖 */
obj.origin_hasOfficialLottery = origin_extension && origin_extension.lott;
/* 被转发者的name */
obj.origin_uname = (user && (user.name || user.uname)) || '';
/* 被转发者的描述 */
obj.origin_description =
(item && (item.content || '' + item.description || ''))
|| (originToJson.dynamic || '' + originToJson.desc || '')
|| '';
}
} catch (e) {
log.error("动态卡片解析", e)
}
return obj
@@ -175,14 +196,14 @@ function parseDynamicCard(dynamic_detail_card) {
function modifyDynamicRes(res) {
const
{ data, code } = utils.strToJson(res),
{ cards = [], has_more, offset } = data || {};
{ cards, has_more, offset } = data || {};
if (code !== 0) {
log.error('处理动态数据', '获取动态数据出错,可能是访问太频繁 \n' + res);
return null;
}
if (!cards.length) {
if (cards == null || !cards || !cards.length) {
log.warn('处理动态数据', '未找到任何动态信息')
}
@@ -588,6 +609,71 @@ class Searcher {
}
});
}
/**
* 从本地文件中获取抽奖信息
* @param {string} txt
* @returns {Promise<LotteryInfo[] | null>}
*/
async getLotteryInfoByTxT(txt) {
log.info('获取动态', `开始获取${utils.lottery_dyids}`);
const dyids = await utils.getLocalLotteryTxt(txt);
let
length = dyids.length,
dyinfos = [];
for (const dyid of dyids) {
if (typeof dyid === "string"
&& dyid.length === utils.dyid_length) {
log.info('获取动态', `查看Txt中所提及动态(${dyid}) (${length--})`)
const card = await bili.getOneDynamicByDyid(dyid)
if (card) {
await utils.delay(get_dynamic_detail_wait)
const parsed_card = parseDynamicCard(card)
, { is_liked } = parsed_card;
if (
((!check_if_duplicated || check_if_duplicated >= 2)
&& is_liked)
|| ((check_if_duplicated >= 1)
&& await d_storage.searchDyid(dyid))
) {
log.info('获取动态', `动态(${dyid})已转发过`)
continue
}
dyinfos.push(parsed_card);
}
} else {
log.warn('获取动态', `动态(${dyid})无效 (${length--})`)
}
}
const fomatdata = dyinfos.map(o => {
return {
lottery_info_type: 'txt',
create_time: o.create_time,
is_liked: o.is_liked,
uids: [o.uid, o.origin_uid],
uname: o.uname,
ctrl: o.ctrl,
dyid: o.dynamic_id,
reserve_id: o.reserve_id,
reserve_lottery_text: o.reserve_lottery_text,
is_charge_lottery: o.is_charge_lottery,
rid: o.rid_str,
chat_type: o.chat_type,
des: o.description,
type: o.type,
hasOfficialLottery: o.hasOfficialLottery
};
})
log.info('获取动态', `成功获取txt信息`);
return fomatdata
}
}
module.exports = { Searcher, parseDynamicCard };
+15 -7
View File
@@ -47,12 +47,19 @@ const config = {
*/
APIs: [],
/**
* lottery_dyids目录下抽奖动态文件名(如dyids.txt)
* 一行一个dyids
*/
TxT: [],
/**
* 抽奖参与顺序组合
* * 0 - UIDs
* * 1 - TAGs
* * 2 - Articles
* * 3 - APIs
* * 4 - TxT
* @example
* [3,2,1,0]
* [1,2,1,2,1]
@@ -298,12 +305,6 @@ const config = {
*/
blacklist: '',
/**
* - 自动同步 https://gitee.com/shanmite/lottery-notice/raw/master/notice.json
* - 使用公共黑名单
*/
use_public_blacklist: true,
/**
* 屏蔽词
*/
@@ -408,6 +409,13 @@ const config = {
*/
clear_quick_remove_attention: false,
/**
* - 快速移除关注
* - 不加判断只去除关注
* - 移除粉丝数小于指定数量的
*/
clear_quick_remove_attention_fans_number_smallest: Infinity,
/**
* 是否移除动态
*/
@@ -419,7 +427,7 @@ const config = {
clear_remove_attention: true,
/**
* 清除动态延时(毫秒)
* 清除延时(毫秒)
*/
clear_remove_delay: 8000,
+21 -5
View File
@@ -1,4 +1,4 @@
const { getRemoteConfig, createDir, createFile, dyids_dir } = require("../utils");
const { getRandomOne, createDir, createFile, dyids_dir } = require("../utils");
const config = require("../data/config");
let global_var = {
@@ -25,11 +25,28 @@ let global_var = {
[0, "UIDs"],
[1, "TAGs"],
[2, "Articles"],
[3, "APIs"]]);
[3, "APIs"],
[4, "TxT"],
]);
config.updata(num);
this.set('cookie', cookie + ';buvid3=AAAAAAAA-BBBB-CCCC-DDDD-DDDDDDDDDDDDDDDDDinfoc');
if (!/buvid3/.test(cookie)) {
const charset = "0123456789ABCDEF".split("");
const buvid3 = "x".repeat(8).split("").map(() => getRandomOne(charset)).join("")
+ "-"
+ "x".repeat(4).split("").map(() => getRandomOne(charset)).join("")
+ "-"
+ "x".repeat(4).split("").map(() => getRandomOne(charset)).join("")
+ "-"
+ "x".repeat(4).split("").map(() => getRandomOne(charset)).join("")
+ "-"
+ "x".repeat(17).split("").map(() => getRandomOne(charset)).join("")
+ "infoc";
this.set('cookie', cookie + ";" + buvid3);
} else {
this.set('cookie', cookie);
}
cookie.split(/\s*;\s*/).forEach(item => {
const _item = item.split('=');
@@ -45,7 +62,6 @@ let global_var = {
.map(lottery_option => config[lottery_option].map(it => [lottery_option, it]))
.flat()
);
this.set('remoteconfig', await getRemoteConfig());
}
await createDir('dyids');
await createFile(dyids_dir, num < 2 ? 'dyid.txt' : `dyid${num}.txt`, '', 'a')
@@ -53,4 +69,4 @@ let global_var = {
};
module.exports = global_var;
module.exports = global_var;
+55 -4
View File
@@ -80,6 +80,13 @@ let SMTP_USER = '';
let SMTP_PASS = '';
let SMTP_TO_USER = '';
// ====================================Gotify======================================
// 官方文档:https://gotify.net/docs/pushmsg
// 此处填你的Gotify消息推送地址(例如:http://localhost/message
let GOTIFY_URL = '';
// 此处填你想推送的Application的Token(不包含推送时额外添加的前缀 Bearer )
let GOTIFY_APPKEY = '';
//==========================云端环境变量的判断与接收=========================
if (process.env.SCKEY) {
SCKEY = process.env.SCKEY;
@@ -190,6 +197,13 @@ if (process.env.SMTP_TO_USER) {
SMTP_TO_USER = process.env.SMTP_TO_USER;
}
if (process.env.GOTIFY_URL) {
GOTIFY_URL = process.env.GOTIFY_URL;
if (process.env.GOTIFY_APPKEY) {
GOTIFY_APPKEY = process.env.GOTIFY_APPKEY
}
}
//==========================云端环境变量的判断与接收=========================
async function sendNotify(text, desp, params = {}) {
@@ -223,7 +237,9 @@ async function sendNotify(text, desp, params = {}) {
// Qmsg
qmsg(text, desp),
//电子邮件
email(text, desp)
email(text, desp),
// Gotify
gotifyNotify(text, desp)
])
}
@@ -495,8 +511,8 @@ function tgBotNotify(text, desp) {
}
if (TG_PROXY_HOST && TG_PROXY_PORT) {
options.proxy = {
hostname: TG_PROXY_HOST,
port: TG_PROXY_PORT * 1
url: "http://" + TG_PROXY_HOST + ":" + TG_PROXY_PORT,
auth_headers: []
}
}
send(options)
@@ -820,6 +836,41 @@ function pushPlusNotify(text, desp) {
})
}
function gotifyNotify(text, desp) {
return new Promise(resolve => {
if (GOTIFY_APPKEY) {
send({
method: 'POST',
url: GOTIFY_URL,
contents: {
title: text,
message: desp,
},
config: {
retry: false
},
headers: {
accept: 'application/json, text/plain, */*',
'content-type': 'application/json',
'authorization': 'Bearer ' + GOTIFY_APPKEY
},
success: () => {
// HTTP 响应码 200 就说明成功了
log.info('发送通知', 'Gotify 发送通知消息成功')
resolve();
},
failure: err => {
log.error('发送通知', 'Gotify 发送通知调用API失败!!' + err)
resolve();
}
})
} else {
log.debug('发送通知', '您未提供Gotify推送所需的GOTIFY_APPKEY,取消Gotify推送消息通知');
resolve()
}
})
}
async function qmsg(text, desp) {
return new Promise(resolve => {
if (QMSG_KEY) {
@@ -889,4 +940,4 @@ async function email(text, desp) {
}
}
module.exports = { sendNotify }
module.exports = { sendNotify }
-26
View File
@@ -1,26 +0,0 @@
const { log } = require('../utils');
const crypto = require('crypto');
/**
* [熊猫代理](http://www.xiongmaodaili.com)
* @returns {import("../net/http").ProxyConfig}
*/
function xiongmaodaili() {
log.info("熊猫代理", "开始")
let timestamp = parseInt(new Date().getTime() / 1000);
let orderno = process.env["XMDL_ORDERNNO"];
let secret = process.env["XMDL_SECRET"];
let txt = 'orderno=' + orderno + ',secret=' + secret + ',timestamp=' + timestamp;
let md5 = crypto.createHash('md5');
let sign = md5.update(txt).digest('hex').toUpperCase();
return {
url: "http://dtan.xiongmaodaili.com:8088",
auth_headers: [
["Proxy-Authorization", 'sign=' + sign + '&orderno=' + orderno + "&timestamp=" + timestamp]
]
}
}
module.exports = { xiongmaodaili }
+3 -1
View File
@@ -1,6 +1,8 @@
const { login } = require('./login');
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 +25,4 @@ async function checkCookie(num) {
}
module.exports = { start, isMe, clear, checkCookie }
module.exports = { login, start, isMe, clear, checkCookie, account }
+58
View File
@@ -0,0 +1,58 @@
const { readFileSync, writeFileSync } = require('fs');
const { log, env_file } = require("./utils");
/**
* 扫码登陆
* @param {string} num
*/
async function login(num) {
try {
const { pcLogin } = require('@catlair/blogin');
const loginInfo = await pcLogin();
if (!loginInfo) {
log.error("扫码登陆", "失败/取消");
return;
}
log.info("扫码登陆", "登录成功");
JSON.stringify(loginInfo, null, 2);
const uid = `${loginInfo.mid}`;
const cookie = `${loginInfo.cookie}`;
log.info("账号UID", uid);
log.info("Cookie", cookie);
if (replaceCookie(env_file, uid, cookie)) {
log.info("扫码登陆", `账号${num}已进行cookie自动更新,如未能生效请手动复制在env.js内替换。路径:${env_file}`);
}
} catch (error) {
log.error(error);
}
}
/**
* 正则检索uid更新cookie
* @param {string} filePath
* @param {string} uid
* @param {string} oldCK
*/
function replaceCookie(filePath, uid, oldCK) {
try {
const content = readFileSync(filePath, 'utf-8');
const DedeUserID = `DedeUserID=${uid}`;
const reg = new RegExp(`['"]?COOKIE['"]?:\\s?['"](.*${DedeUserID}.*)['"]`, 'g');
const newCK = content.replaceAll(reg, substring => {
let quote = substring.at(0) || '';
/['"]/.test(quote) || (quote = '');
const quote2 = oldCK.includes("'")
? '"'
: substring.match(/^['"]?COOKIE['"]?:\s?(['"])/)?.[1] || '"';
return `${quote}COOKIE${quote}: ${quote2}${oldCK}${quote2}`;
});
if (content === newCK) return false;
writeFileSync(filePath, newCK);
return true;
} catch (error) {
log.error("扫码登陆", error);
}
return false;
}
module.exports = { login }
+4 -8
View File
@@ -5,12 +5,7 @@ module.exports = Object.freeze({
DYNAMIC_REPOST_SHARE: 'https://api.vc.bilibili.com/dynamic_repost/v1/dynamic_repost/share',
DYNAMIC_SVR_CREATE_DRAW: 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/create_draw',
DYNAMIC_SVR_CREATE: 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/create',
DYNAMIC_SVR_GET_DYNAMIC_DETAIL_V2: 'https://api.vc.bilibili.com/dynamic_svr/v2/dynamic_svr/get_dynamic_detail',
DYNAMIC_SVR_GET_DYNAMIC_DETAIL_V3: 'https://api.vc.bilibili.com/dynamic_svr/v3/dynamic_svr/get_dynamic_detail',
DYNAMIC_SVR_GET_DYNAMIC_DETAIL_V4: 'https://api.vc.bilibili.com/dynamic_svr/v4/dynamic_svr/get_dynamic_detail',
DYNAMIC_SVR_GET_DYNAMIC_DETAIL_V5: 'https://api.vc.bilibili.com/dynamic_svr/v5/dynamic_svr/get_dynamic_detail',
DYNAMIC_SVR_GET_DYNAMIC_DETAIL_V6: 'https://api.vc.bilibili.com/dynamic_svr/v6/dynamic_svr/get_dynamic_detail',
DYNAMIC_SVR_GET_DYNAMIC_DETAIL_V7: 'https://api.vc.bilibili.com/dynamic_svr/v7/dynamic_svr/get_dynamic_detail',
DYNAMIC_SVR_GET_DYNAMIC_DETAIL_V: 'https://api.vc.bilibili.com/dynamic_svr/v{{v}}/dynamic_svr/get_dynamic_detail',
DYNAMIC_SVR_RM_DYNAMIC: 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/rm_dynamic',
DYNAMIC_SVR_SPACE_HISTORY: 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/space_history',
FEED_GET_ATTENTION_LIST: 'https://api.vc.bilibili.com/feed/v1/feed/get_attention_list',
@@ -20,7 +15,7 @@ module.exports = Object.freeze({
MSGFEED_AT: 'https://api.bilibili.com/x/msgfeed/at',
MSGFEED_REPLAY: 'https://api.bilibili.com/x/msgfeed/reply',
MSGFEED_UNREAD: 'https://api.bilibili.com/x/msgfeed/unread',
READ_CV: 'https://www.bilibili.com/read/cv{{cv}}',
READ_CV: 'https://www.bilibili.com/read/cv{{cv}}/',
RELATION_BATCH_MODIFY: 'https://api.bilibili.com/x/relation/batch/modify',
RELATION_MODIFY: 'https://api.bilibili.com/x/relation/modify',
RELATION_STAT: 'https://api.bilibili.com/x/relation/stat',
@@ -41,5 +36,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',
})
})
+167 -107
View File
@@ -1,8 +1,7 @@
const GlobalVar = require('../data/global_var');
const { strToJson, log, hasEnv } = require('../utils');
const { strToJson, log, ocr, hasEnv } = require('../utils');
const { send } = require('./http');
const API = require('./api.bili');
const proxies = require("../helper/proxies");
class Line {
/**
@@ -89,7 +88,7 @@ class Line {
*/
function get({ url, config, contents, query }) {
return new Promise((resolve) => {
let ro = {
send({
url,
method: 'GET',
config,
@@ -101,11 +100,7 @@ function get({ url, config, contents, query }) {
contents,
success: res => resolve(res.body),
failure: err => resolve(err)
}
if (hasEnv("ENABLE_PROXY")) {
ro.proxy = proxies.xiongmaodaili();
}
send(ro)
})
})
}
@@ -116,24 +111,20 @@ function get({ url, config, contents, query }) {
*/
function post({ url, config, contents, query }) {
return new Promise((resolve) => {
let ro = {
send({
url,
method: 'POST',
config,
headers: {
"accept": 'application/json, text/plain, */*',
"content-type": 'application/x-www-form-urlencoded; charset=utf-8',
"content-type": 'application/x-www-form-urlencoded; charset=UTF-8',
"cookie": GlobalVar.get("cookie")
},
query,
contents,
success: res => resolve(res.body),
failure: err => resolve(err)
};
if (hasEnv("ENABLE_PROXY")) {
ro.proxy = proxies.xiongmaodaili();
}
send(ro)
})
})
}
@@ -143,7 +134,7 @@ function post({ url, config, contents, query }) {
const bili_client = {
/**
* 判断是否成功登录
* @returns {Promise<boolean>}
* @returns {Promise<Object?>}
*/
async getMyinfo() {
const
@@ -153,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;
}
},
/**
@@ -227,7 +234,9 @@ const bili_client = {
items = data.items || [];
log.info('获取一页回复', `成功(${items.length})`);
return items
.filter(it => it.item.type === 'reply')
.filter(it => it.item !== undefined
&& it.user !== undefined
&& it.reply_time !== undefined)
.map(it => {
return {
nickname: it.user.nickname,
@@ -250,11 +259,11 @@ const bili_client = {
* @property {number} sender_uid
* @property {number} talker_id
* @property {number} msg_seqno
*
*
* @typedef SessionInfo
* @property {number} has_more
* @property {SessionData[]} data
*
*
* @param {number} session_type 1 已关注 2 未关注 3 应援团
* @param {string} [ts_16]
* @returns {Promise<SessionInfo>}
@@ -310,7 +319,7 @@ const bili_client = {
const msgs = res.data.messages
if (msgs instanceof Array) {
log.info('私信细节', `${talker_id}${size}条未读私信`)
return msgs.map(it => it.content).join('\n')
return msgs.filter(it => ![5, 8, 9, 10, 11].includes(it.msg_source)).map(it => it.content).join('\n')
} else {
log.warn('私信细节', `${talker_id}无私信`)
}
@@ -388,7 +397,7 @@ const bili_client = {
}
},
/**
* @param {string} short_id
* @param {string} short_id
* @returns {Promise<string>}
*/
async shortDynamicIdToDyid(short_id) {
@@ -403,67 +412,46 @@ const bili_client = {
return dyid
})
},
_getOneDynamicByDyid: new Line('获取一个动态的细节', [
(dynamic_id) => get({
url: API.DYNAMIC_SVR_GET_DYNAMIC_DETAIL_V2,
config: { retry: false },
query: {
dynamic_id
}
}),
(dynamic_id) => get({
url: API.DYNAMIC_SVR_GET_DYNAMIC_DETAIL_V3,
config: { retry: false },
query: {
dynamic_id
}
}),
(dynamic_id) => get({
url: API.DYNAMIC_SVR_GET_DYNAMIC_DETAIL_V4,
config: { retry: false },
query: {
dynamic_id
}
}),
(dynamic_id) => get({
url: API.DYNAMIC_SVR_GET_DYNAMIC_DETAIL_V5,
config: { retry: false },
query: {
dynamic_id
}
}),
(dynamic_id) => get({
url: API.DYNAMIC_SVR_GET_DYNAMIC_DETAIL_V6,
config: { retry: false },
query: {
dynamic_id
}
}),
(dynamic_id) => get({
url: API.DYNAMIC_SVR_GET_DYNAMIC_DETAIL_V7,
config: { retry: false },
query: {
dynamic_id
}
}),
], responseText => {
const
res = strToJson(responseText),
{ code, data } = res,
{ card } = data || {};
switch (code) {
case 0:
if (card) {
return [false, card, `ok`];
} else {
return [false, undefined, `动态不存在`];
_getOneDynamicByDyid: new Line(
'获取一个动态的细节',
[
(dynamic_id) => get({
url: API.DYNAMIC_SVR_GET_DYNAMIC_DETAIL_V.replace('{{v}}', 1),
config: { retry: false },
query: {
dynamic_id
}
case 500207:
return [false, undefined, `该动态为包月充电专属可以给UP主充电后观看`];
default:
return [true, undefined, `获取动态数据出错:\n${responseText}`]
}
}),
}),
...Array(10)
.fill(
(dynamic_id) => get({
url: API.DYNAMIC_SVR_GET_DYNAMIC_DETAIL_V.replace('{{v}}', Math.floor(Math.random() * 10 ** 10)),
config: { retry: false },
query: {
dynamic_id
}
})
)
]
, responseText => {
const
res = strToJson(responseText),
{ code, data } = res,
{ card } = data || {},
{ desc } = card || {};
switch (code) {
case 0:
if (card && desc) {
return [false, card, `ok`];
} else {
return [false, undefined, `获取动态数据异常:\n${responseText}`];
}
case 500207:
return [false, undefined, `该动态为包月充电专属可以给UP主充电后观看`];
default:
return [true, undefined, `获取动态数据出错:\n${responseText}`]
}
}),
/**
* 获取一个动态的细节
* @param {string} dynamic_id
@@ -728,6 +716,8 @@ const bili_client = {
return [false, 4, '账号异常']
case 22009:
return [false, 5, '关注已达上限']
case 22014:
return [false, 6, '已经关注用户,无法重复关注']
default:
return [true, 1, `未知错误\n${responseText}`]
}
@@ -739,12 +729,13 @@ const bili_client = {
* @param {Number} uid
* 被关注者的UID
* @returns {Promise<number>}
* - 成功 0
* - 未知错误 1
* - 您已被对方拉入黑名单 2
* - 黑名单用户无法关注 3
* - 账号异常 4
* - 关注已达上限 5
* - 成功 0
* - 未知错误 1
* - 您已被对方拉入黑名单 2
* - 黑名单用户无法关注 3
* - 账号异常 4
* - 关注已达上限 5
* - 已经关注用户 6
*/
autoAttention(uid) {
return this._autoAttention.run(uid)
@@ -754,8 +745,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({
@@ -807,7 +798,7 @@ const bili_client = {
* 动态自动点赞
* @param {string} dyid
* @returns {Promise<number>}
* - 成功 0
* - 成功 0
* - 未知错误 1
* - 点赞异常 2
* - 点赞频繁 3
@@ -856,11 +847,11 @@ const bili_client = {
* @param {string} [msg]
* 动态的ID
* @returns {Promise<number>}
* - 成功 0
* - 未知错误 1
* - 该动态不能转发分享 2
* - 请求数据发生错误,请刷新或稍后重试 3
* - 操作太频繁了,请稍后重试 4
* - 成功 0
* - 未知错误 1
* - 该动态不能转发分享 2
* - 请求数据发生错误,请刷新或稍后重试 3
* - 操作太频繁了,请稍后重试 4
*/
async autoRelay(uid, dyid, msg = '转发动态', ctrl = '[]') {
const len = msg.length;
@@ -902,8 +893,8 @@ const bili_client = {
},
/**
* 预约抽奖
* @param {number} reserve_id
* @returns
* @param {string} reserve_id
* @returns
*/
async reserve_lottery(reserve_id) {
const
@@ -1059,15 +1050,16 @@ const bili_client = {
* cid_str
* @param {string} msg
* @param {number} type
* @param {string} code
* 1(视频)
* 11(有图)
* 17(无图)
* @returns {Promise<number>}
* @returns {Promise<number|string>}
* - 成功 0
* - 未知错误 1
* - 原动态已删除 2
* - 评论区已关闭 3
* - 需要输入验证码 4
* - 需要输入验证码 4 -> url
* - 已被对方拉入黑名单 5
* - 黑名单用户无法互动 6
* - UP主已关闭评论区 7
@@ -1075,8 +1067,9 @@ const bili_client = {
* - 重复评论 9
* - 帐号未登录 10
* - 关注UP主7天以上的人可发评论 11
* - 验证码错误 12
*/
async sendChat(rid, msg, type) {
async sendChat(rid, msg, type, code) {
const
responseText = await post({
url: API.REPLY_ADD,
@@ -1084,6 +1077,7 @@ const bili_client = {
oid: rid,
type: type,
message: msg,
code,
csrf: GlobalVar.get("csrf")
}
}),
@@ -1100,7 +1094,7 @@ const bili_client = {
return 3;
case 12015:
log.error('自动评论', '需要输入验证码');
return 4;
return res.data.url;
case 12035:
log.error('自动评论', `已被对方拉入黑名单`);
return 5;
@@ -1122,11 +1116,77 @@ const bili_client = {
case 12078:
log.error('自动评论', '关注UP主7天以上的人可发评论');
return 11;
case 12073:
log.error('自动评论', '验证码错误');
return 12;
default:
log.error('自动评论', `未知错误\n${responseText}`);
return 1;
}
},
/**
* 发送评论 自动识别验证码
* @param {string} rid
* cid_str
* @param {string} msg
* @param {number} type
* 1(视频)
* 11(有图)
* 17(无图)
* @returns {Promise<number>}
* - 成功 0
* - 未知错误 1
* - 原动态已删除 2
* - 评论区已关闭 3
* - 需要输入验证码 4 -> url
* - 已被对方拉入黑名单 5
* - 黑名单用户无法互动 6
* - UP主已关闭评论区 7
* - 评论内容包含敏感信息 8
* - 重复评论 9
* - 帐号未登录 10
* - 关注UP主7天以上的人可发评论 11
* - 验证码错误 12
*/
async sendChatWithOcr(rid, msg, type) {
let need_captcha = false;
let url = "";
let status = 0;
do {
if (need_captcha) {
const code = await ocr(url);
if (code) {
log.info("验证码识别", `${url} -> ${code}`);
status = await bili_client.sendChat(
rid,
msg,
type,
code
);
if (status === 0) {
need_captcha = false
} else if (status === 12) {
need_captcha = true
} else {
need_captcha = false
}
}
} else {
url = await bili_client.sendChat(
rid,
msg,
type
)
if (typeof url === "string"
&& hasEnv("ENABLE_CHAT_CAPTCHA_OCR")) {
need_captcha = true
} else {
status = url
}
}
} while (need_captcha);
return status;
},
/**
* 查询评论
* @param {*} rid
@@ -1160,9 +1220,9 @@ const bili_client = {
}
},
/**
* 检查分区
* 不存在指定分区时创建
* 获取到tagid添加为对象的属性
* 检查分区
* 不存在指定分区时创建
* 获取到tagid添加为对象的属性
* @param {string} [name]
* @returns {Promise<number>}
*/
@@ -1254,4 +1314,4 @@ const bili_client = {
};
module.exports = bili_client
module.exports = bili_client
+1 -1
View File
@@ -56,7 +56,7 @@ const DEFAULT_REDIRECT = false;
/**错误尝试次数 */
const DEFAULT_RETRY_TIMES = 6;
/**Google Chrome */
const DEFAULT_UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36';
const DEFAULT_UA = process.env.ACCOUNT_UA || 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36';
/**默认url编码 */
const DEFAULT_CONTENT_TYPE = 'application/x-www-form-urlencoded; charset=UTF-8';
/**
+20 -16
View File
@@ -56,8 +56,9 @@ function checkPlatform(releases) {
/**
* 半自动更新
* @param {boolean} isDdownload
*/
async function update() {
async function update(isDdownload) {
try {
const { tag_name, assets, body: text } = await getLatestRelease('shanmiteko', 'LotteryAutoScript')
if (checkVersion(version) < checkVersion(tag_name)) {
@@ -65,20 +66,23 @@ async function update() {
.filter(({ name }) => checkPlatform(name))
.map(({ browser_download_url }) => browser_download_url)
if (download_url.length) {
await try_for_each(download_url.entries(), async ([i, url]) => {
let proxy_url = "https://ghproxy.com/";
proxy_url += url
log.warn('自动下载', `切换代理${proxy_url}`)
await download(proxy_url, `latest_version${i}.zip`)
.catch(async err => {
log.error('自动下载', err)
proxy_url = url
log.warn('自动下载', `使用原始链接${proxy_url}`)
await download(proxy_url, `latest_version${i}.zip`)
})
return false
})
log.info('自动下载', '成功下载到当前目录')
if (isDdownload) {
await try_for_each(download_url.entries(), async ([i, url]) => {
let proxy_url = "https://mirror.ghproxy.com/";
proxy_url += url
log.warn('自动下载', `切换代理${proxy_url}`)
await download(proxy_url, `latest_version${i}.zip`)
.catch(async err => {
log.error('自动下载', err)
proxy_url = url
log.warn('自动下载', `使用原始链接${proxy_url}`)
await download(proxy_url, `latest_version${i}.zip`)
})
return false
})
log.info('自动下载', '成功下载到当前目录')
log.info('检查更新', '请手动解压替换可执行文件');
}
log.info('更新说明', '\n' + text + '\n')
} else {
throw `未找到能在此平台(${process.platform})-(${process.arch})上运行的版本,建议以源码运行`
@@ -87,7 +91,7 @@ async function update() {
throw '当前已是最新版本'
}
} catch (error) {
log.error('更新脚本', error)
log.warn('更新脚本', error)
}
}
+44 -30
View File
@@ -17,6 +17,8 @@ const utils = {
dyids_dir: path.join(process.cwd(), "dyids"),
/**lottery_info存放目录 */
lottery_info_dir: path.join(process.cwd(), "lottery_info"),
/**本地抽奖信息存放目录 */
lottery_dyids: path.join(process.cwd(), "lottery_dyids"),
/**dyid长度 */
dyid_length: 18,
/**
@@ -42,7 +44,8 @@ const utils = {
try {
const obj = JSON.parse(str);
return typeof obj === 'object' ? obj : false
} catch (_) {
} catch (e) {
utils.log.error("json解析", e + "\n" + params)
return false;
}
} else {
@@ -275,6 +278,29 @@ const utils = {
}
}
},
/**
* 验证码识别
* @param {string} url
* @returns {Promise<string>}
*/
ocr(url) {
return new Promise((resolve) => {
send({
method: 'POST',
url: 'http://127.0.0.1:9898/ocr/url/text',
headers: {
"content-type": 'application/x-www-form-urlencoded; charset=UTF-8',
},
contents: { url },
success: res => {
resolve(res.body)
},
failure: () => {
resolve()
}
})
})
},
/**
* 下载文件
* @param {string} url
@@ -313,35 +339,6 @@ const utils = {
})
});
},
/**
* 获取远程设置
* @returns {Promise<JSON>}
*/
getRemoteConfig() {
return new Promise((resolve) => {
send({
method: 'GET',
url: 'https://gitee.com/shanmite/lottery-notice/raw/master/notice.json',
headers: {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36',
},
success: res => {
try {
const body = JSON.parse(Buffer.from(res.body, "base64").toString());
if (body.node_msg) utils.log.info('公告', '\n' + body.node_msg + '\n');
resolve(body.config)
} catch (error) {
utils.log.error('获取远程设置', '获取远程设置错误: ' + error);
resolve({})
}
},
failure: err => {
utils.log.error('获取远程设置', '获取远程设置错误: ' + err);
resolve({})
}
})
})
},
/**
* 是否存在文件或目录
* @param {string} path
@@ -387,6 +384,7 @@ const utils = {
rejects(err)
} else {
fs.write(fd, buffer, 0, buffer.length, 0, err => {
fs.close(fd)
if (err) {
rejects(err)
} else {
@@ -459,6 +457,22 @@ const utils = {
async clearLotteryInfo() {
await utils.createDir(utils.lottery_info_dir);
await utils.createFile(utils.lottery_info_dir, `lottery_info_${Number(process.env.NUMBER)}.json`, "{}", "w")
},
/**
* 获取含抽奖dyids
* @param {string} filename
* @returns {Promise<Array<String>>}
*/
getLocalLotteryTxt(filename) {
return new Promise((resolve) => {
fs.readFile(path.join(utils.lottery_dyids, filename), (err, data) => {
if (err) {
resolve([])
} else {
resolve(data.toString("utf8").split(/[^0123456789]+/))
}
})
});
}
};
+32 -9
View File
@@ -16,6 +16,9 @@ const metainfo = [
let multiple_account = [];
/**循环等待时间 */
let loop_wait = 0;
/**账号状态标记 1正常 -1失效 */
// eslint-disable-next-line no-unused-vars
let ck_flag = 0
/**
* @returns {Promise<string>} 错误信息
@@ -34,11 +37,16 @@ async function main() {
process.env.NUMBER = acco.NUMBER;
process.env.CLEAR = acco.CLEAR;
process.env.NOTE = acco.NOTE;
process.env.ACCOUNT_UA = acco.ACCOUNT_UA;
const err_msg = await main();
if (err_msg) {
return err_msg
} else {
await delay(acco.WAIT);
if (ck_flag === 1) {
await delay(acco.WAIT);
} else {
await delay(3 * 1000);
}
}
}
@@ -49,15 +57,16 @@ async function main() {
await global_var.init(COOKIE, NUMBER);
/**引入基础功能 */
const { start, isMe, clear, checkCookie } = require("./lib/index");
const { start, isMe, clear, account, checkCookie, login } = require("./lib/index");
log.info('main', '当前为第' + NUMBER + '个账号');
log._cache.length = 0
const mode = process.env.lottery_mode;
const help_msg = "用法: lottery [OPTIONS]\n\nOPTIONS:\n\tstart 启动抽奖\n\tcheck 中奖检查\n\tacount 查看帐号信息\n\tclear 清理动态和关注\n\tlogin 扫码登录更新CK\n\tupdate 检查更新\n\thelp 帮助信息";
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, save_lottery_info_to_file } = require("./lib/data/config");
ck_flag = 1;
switch (mode) {
case 'start':
log.info('抽奖', '开始运行');
@@ -79,8 +88,15 @@ async function main() {
await clear();
}
break;
case 'login':
log.info('登录状态', '正常,跳过扫码');
break;
case 'help':
return help_msg
case 'account':
log.info('检查帐号信息', '开始运行');
await account();
break;
case undefined:
return "未提供以下参数\n\t[OPTIONS]\n\n" + help_msg
default:
@@ -88,7 +104,12 @@ async function main() {
}
} else {
log.error('Cookie已失效', '切换账号时不要点击退出账号而应直接删除Cookie退出')
return
ck_flag = -1;
if (mode === "login") {
log.info('登陆', '开始扫码');
await login(NUMBER);
await delay(1000);
}
}
} else {
return '请查看README文件, 在env.js指定位置填入cookie'
@@ -149,11 +170,13 @@ function initConfig() {
/**OPTIONS */
process.env.lottery_mode = process.argv[2]
log.info('检查更新', '开始')
if (process.env.lottery_mode === "update") {
log.info('检查更新', '开始')
await require("./lib/update").update()
log.info('检查更新', '请手动解压替换可执行文件')
await require("./lib/update").update(true)
return
} else {
await require("./lib/update").update(false)
}
const err_msg = await main();
@@ -168,7 +191,7 @@ function initConfig() {
if (initEnv() || initConfig()) return;
await main()
}
log.info('结束运行', '未在config.js中设置休眠时间')
log.info('结束运行', '未在my_config.js中设置休眠时间')
}
process.exit(0);
+15 -7
View File
@@ -51,12 +51,19 @@ module.exports = Object.freeze({
*/
APIs: ["file://lottery_info_1.json"],
/**
* lottery_dyids目录下抽奖动态文件名(如dyids.txt)
* 一行一个dyids(非数字字符分割即可)
*/
TxT: ["dyids.txt"],
/**
* 抽奖参与顺序组合
* * 0 - UIDs
* * 1 - TAGs
* * 2 - Articles
* * 3 - APIs
* * 4 - TxT
* @example
* [3,2,1,0]
* [1,2,1,2,1]
@@ -303,12 +310,6 @@ module.exports = Object.freeze({
*/
blacklist: '',
/**
* - 自动同步 https://gitee.com/shanmite/lottery-notice/raw/master/notice.json
* - 使用公共黑名单
*/
use_public_blacklist: true,
/**
* 屏蔽词
*/
@@ -418,6 +419,13 @@ module.exports = Object.freeze({
*/
clear_quick_remove_attention: false,
/**
* - 快速移除关注
* - 不加判断只去除关注
* - 移除粉丝数小于指定数量的
*/
clear_quick_remove_attention_fans_number_smallest: Infinity,
/**
* 是否移除动态
*/
@@ -429,7 +437,7 @@ module.exports = Object.freeze({
clear_remove_attention: true,
/**
* 清除动态延时(毫秒)
* 清除延时(毫秒)
*/
clear_remove_delay: 8000,
+6 -2
View File
@@ -1,14 +1,17 @@
{
"name": "lottery-auto-script",
"version": "2.7.11",
"version": "2.8.19",
"description": "自动参与B站动态抽奖",
"main": "main.js",
"scripts": {
"login": "node main.js login",
"start": "node main.js start",
"test": "node test/index.js",
"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"
},
@@ -44,6 +47,7 @@
"chalk": "^4.1.2",
"http-proxy-agent": "^7.0.0",
"https-proxy-agent": "^7.0.0",
"nodemailer": "^6.7.0"
"nodemailer": "^6.7.0",
"@catlair/blogin": "^0.0.8"
}
}
+6 -5
View File
@@ -12,7 +12,8 @@ TARGET_DIR="dist"
BIN_NAME="lottery"
create_win_bat() {
echo "@echo off && lottery $1 && pause"
echo "set NODE_SKIP_PLATFORM_CHECK=1" >>$2
echo "lottery $1 & pause" >>$2
}
if [ -d "$TARGET_DIR" ]; then
@@ -27,12 +28,12 @@ mkdir -p $TARGET_DIR
npm install
if [[ "$1" == *"arm"* ]]; then
OUTFILE="$TARGET_DIR/lottery-auto-script-node18-$1"
OUTFILE="$TARGET_DIR/lottery-auto-script-$1"
sudo podman run --rm --privileged multiarch/qemu-user-static --reset -p yes
podman run -it \
--rm \
-v ${PWD}:/root/lottery \
shanmite/pkg-arm64 -t "node18.5.0-$1" -o "$OUTFILE" .
shanmite/pkg-arm64 -t "node18-$1" -o "$OUTFILE" .
elif [[ "$1" == *"x64"* ]]; then
OUTFILE="$TARGET_DIR/lottery-auto-script-$1"
npx pkg -t "$1" -o "$OUTFILE" .
@@ -49,9 +50,9 @@ 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" "login")
for item in "${BATS[@]}"; do
create_win_bat "${item}" >"$TMPDIR.d/$item.bat"
create_win_bat "${item}" "$TMPDIR.d/$item.bat"
done
mv "$TMPDIR.d/$BIN_NAME" "$TMPDIR.d/$BIN_NAME.exe"
else
+54 -6
View File
@@ -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
@@ -82,6 +82,7 @@ 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 \\
start
@@ -103,6 +104,7 @@ 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 \\
check
@@ -116,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
@@ -124,6 +148,7 @@ 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 \\
clear
@@ -144,6 +169,7 @@ NAME=shanmite-lottery-debug
echo "create temporary debug container"
docker run \\
-it \\
--network host \\
--name \$NAME \\
--entrypoint /bin/bash \\
$DOCKER_REPO -c bash
@@ -162,3 +188,25 @@ docker image rm -f shanmite/lottery_auto_docker
echo "see you next time!"
EOF
chmod +x remove_all.sh
echo "create login.sh"
cat >login.sh <<EOF
#!$(which env) bash
NAME=shanmite-lottery-login
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 \\
login
else
echo "container \$NAME already existed"
echo "history logs -> docker logs \$NAME"
echo "close this -> docker stop \$NAME"
echo "login \$NAME"
docker login \$NAME
fi
EOF
chmod +x login.sh
+4 -1
View File
@@ -2,6 +2,7 @@
set -e
NAME=LotteryAutoScript
BRABCH=main
# 视网络情况选择链接
GIT_REPO=https://github.com/shanmiteko/${NAME}.git
@@ -12,7 +13,7 @@ if [ -d "$NAME" ]; then
git pull
cd ..
else
git clone $GIT_REPO $NAME --depth=1
git clone -b $BRABCH $GIT_REPO $NAME
fi
if [ -f "$NAME/my_config.js" ]; then
@@ -38,6 +39,8 @@ EOF
create start
create check
create clear
create account
create login
cd $NAME
npm i
+6 -2
View File
@@ -4,9 +4,9 @@ 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, 1, 2, 3, 4, 5], [
await util.par_run([0, 3], [
// 0
async () => {
assert.equal((await bili_client.getTopRcmd()).length, 10)
@@ -45,6 +45,10 @@ const { parseDynamicCard } = require('../lib/core/searcher');
async () => {
assert.equal(await bili_client.autolike("761391835139538967"), 4)
},
// 7
async () => {
assert(await bili_client.rmDynamic("835102428771647513"))
},
])
console.log("api.test ... ok!");
+14 -2
View File
@@ -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 -2
View File
@@ -3,11 +3,10 @@ const global_var = require("../lib/data/global_var");
const { log } = require('../lib/utils');
const fs = require('fs');
log._level = 2
log._level = 4
env.init()
global_var.init(process.env["COOKIE"], 1)
fs.readdirSync(module.path)
.filter(file => file.endsWith(".test.js"))
.forEach(file => require(`${module.path}/${file}`))
+23
View File
@@ -0,0 +1,23 @@
const assert = require('assert');
const bili_client = require("../lib/net/bili");
const util = require('./util');
const { parseDynamicCard } = require('../lib/core/searcher');
(async () => {
await util.par_run([], [
// 0
async () => {
assert.notEqual(await bili_client.getMyinfo(), null);
const rid = parseDynamicCard(await bili_client.getOneDynamicByDyid("551416252543796684")).rid_str;
for (let index = 0; index < 100; index++) {
console.log(index);
await bili_client.sendChatWithOcr(
rid,
Date.now().toString(),
17,
)
}
},]);
})()
-38
View File
@@ -1,38 +0,0 @@
const util = require('./util');
const crypto = require('crypto');
const { send } = require('../lib/net/http');
(async () => {
await util.par_run([], [
// 0
async () => {
let timestamp = parseInt(new Date().getTime() / 1000);
let orderno = process.env["XMDL_ORDERNNO"];
let secret = process.env["XMDL_SECRET"];
if (orderno && secret) {
let txt = 'orderno=' + orderno + ',secret=' + secret + ',timestamp=' + timestamp;
let md5 = crypto.createHash('md5');
let sign = md5.update(txt).digest('hex').toUpperCase();
console.log(await new Promise((resolve) => {
send({
url: "https://api.bilibili.com/client_info",
proxy: {
url: "http://dtan.xiongmaodaili.com:8088",
auth_headers: [
["Proxy-Authorization", 'sign=' + sign + '&orderno=' + orderno + "&timestamp=" + timestamp]
]
},
config: {
retry: false
},
success: (res) => { resolve(JSON.parse(res.body)) },
failure: resolve
})
}));
console.log("proxy.test ... ok!");
}
},
])
})()