mirror of
https://github.com/shanmiteko/LotteryAutoScript.git
synced 2026-07-22 21:13:47 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ae4d1fde91 | ||
|
|
ca1acd21e8 | ||
|
|
dabf8f9d75 | ||
|
|
affe24f441 | ||
|
|
3a5a8d0ded | ||
|
|
5d3103102e | ||
|
|
7ab38f258c | ||
|
|
35fe4481fa | ||
|
|
58edd4129c | ||
|
|
c8e1a328ec | ||
|
|
4f8f50f90b | ||
|
|
3b4b85bc42 | ||
|
|
db11265b28 | ||
|
|
6df137201a | ||
|
|
82efbb4219 | ||
|
|
886ccff341 | ||
|
|
0d5f5eca1d | ||
|
|
f75d2b66c4 | ||
|
|
29bf439288 | ||
|
|
d3a8b86f55 | ||
|
|
d205cb5ddc | ||
|
|
223a6e13c9 | ||
|
|
664e33b3a6 | ||
|
|
5a7b6721b9 | ||
|
|
aae3de84f4 | ||
|
|
3491888f88 | ||
|
|
f6aa0d0544 | ||
|
|
1415f18fea | ||
|
|
f498ee39b4 | ||
|
|
292b8e05eb | ||
|
|
ca6549dc6f | ||
|
|
e03b4832e4 | ||
|
|
3e01e423b7 | ||
|
|
00b5310b59 | ||
|
|
ba100e0444 | ||
|
|
29676d5c4b | ||
|
|
dd9ff1b3c8 | ||
|
|
d53881cbbd | ||
|
|
4238ee50a6 | ||
|
|
784f148d75 | ||
|
|
607b2d7055 | ||
|
|
03e24b9b84 | ||
|
|
73f04a357a | ||
|
|
2742dcbd4f | ||
|
|
329c5e506f | ||
|
|
3bc7dafe3e | ||
|
|
23432edb74 | ||
|
|
df7b3210a3 | ||
|
|
31e8941415 | ||
|
|
f329457c9a | ||
|
|
0eddee4f15 | ||
|
|
ce2c9e58dd | ||
|
|
f1bbc9d1da | ||
|
|
29bb2f32a3 | ||
|
|
22e4d2aaa1 | ||
|
|
354d8cff1a | ||
|
|
1b80f853ed | ||
|
|
b1f478cb8e | ||
|
|
39d69e0448 | ||
|
|
45ac58e312 |
+6
-1
@@ -1,4 +1,9 @@
|
||||
**/**
|
||||
!lib/
|
||||
!script/
|
||||
!test/
|
||||
!main.js
|
||||
!package.json
|
||||
!main.js
|
||||
!env.example.js
|
||||
!my_config.example.js
|
||||
!README.md
|
||||
|
||||
@@ -8,6 +8,7 @@ on:
|
||||
- "lib/**"
|
||||
- "*.js"
|
||||
- "*.json"
|
||||
- ".github/workflows/docker.yml"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
@@ -16,13 +17,18 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Build and push
|
||||
env:
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
repo: ${{ secrets.DOCKERHUB_REPO }}
|
||||
run: |
|
||||
curl -fsSL https://get.docker.com | bash -s docker
|
||||
docker build -t $repo .
|
||||
docker login -p $password -u $username
|
||||
docker push $repo
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
push: true
|
||||
tags: ${{ secrets.DOCKERHUB_REPO }}
|
||||
platforms: "linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/ppc64le,linux/s390x"
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
name: Mirror and run GitLab CI
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Mirror + trigger CI
|
||||
uses: SvanBoxel/gitlab-mirror-and-ci-action@master
|
||||
with:
|
||||
args: "https://gitlab.com/shanmiteko/LotteryAutoScript"
|
||||
env:
|
||||
FORCE_PUSH: "true"
|
||||
GITLAB_HOSTNAME: "gitlab.com"
|
||||
GITLAB_USERNAME: "shanmiteko"
|
||||
GITLAB_PASSWORD: ${{ secrets.GITLAB_PASSWORD }}
|
||||
GITLAB_PROJECT_ID: "36365601"
|
||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
@@ -4,32 +4,70 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- pkg
|
||||
paths:
|
||||
- "lib/**"
|
||||
- "*.js"
|
||||
- "*.json"
|
||||
- ".github/workflows/pkg.yml"
|
||||
- "script/build/pkg.sh"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build_all:
|
||||
x64:
|
||||
runs-on: ubuntu-latest
|
||||
name: node${{ matrix.nodev }}-${{ matrix.platform }}-x64
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- platform: linux
|
||||
nodev: 18
|
||||
- platform: macos
|
||||
nodev: 18
|
||||
- platform: win
|
||||
nodev: 18
|
||||
- platform: win
|
||||
nodev: 12
|
||||
steps:
|
||||
- name: "Checkout codes"
|
||||
uses: actions/checkout@v2
|
||||
- name: "Use Node.js"
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: "16"
|
||||
node-version: "*"
|
||||
- name: "Pkg this"
|
||||
run: |
|
||||
sudo apt install zip unzip
|
||||
npm install
|
||||
npm run build_all
|
||||
npm run pkg "node${{ matrix.nodev }}-${{ matrix.platform }}-x64"
|
||||
- name: "Upload to artifact"
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: all_platform
|
||||
path: dist/
|
||||
name: node${{ matrix.nodev }}-${{ matrix.platform }}-x64
|
||||
path: "dist/*.zip"
|
||||
- name: "Upload to release draft"
|
||||
uses: xresloader/upload-to-github-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
with:
|
||||
file: "dist/*.zip"
|
||||
delete_file: "dist/*.zip"
|
||||
tag_name: "v2"
|
||||
overwrite: true
|
||||
arm64:
|
||||
runs-on: ubuntu-latest
|
||||
name: arm64
|
||||
steps:
|
||||
- name: "Checkout codes"
|
||||
uses: actions/checkout@v2
|
||||
- name: "Pkg this"
|
||||
run: |
|
||||
sudo podman run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
||||
npm run pkg arm
|
||||
- name: "Upload to artifact"
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: arm64
|
||||
path: "dist/*.zip"
|
||||
- name: "Upload to release draft"
|
||||
uses: xresloader/upload-to-github-release@v1
|
||||
env:
|
||||
|
||||
+100
@@ -1,5 +1,105 @@
|
||||
<!-- markdownlint-disable MD036 MD024-->
|
||||
# CHANGELOG
|
||||
## 主要变化(2.6.3)
|
||||
* ca1acd2 fix: 转发随机动态视频新的错误码(#201)
|
||||
* dabf8f9 fix: 关注出错(#199)
|
||||
* affe24f fix: 发布随机动态显示转发请求不合法(#197)
|
||||
* 3a5a8d0 feat: 青龙面板(#200)
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(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)
|
||||
* 0d5f5ec ci(docker): support more platforms
|
||||
* f75d2b6 fix: `checkAllDynamic`重试与`null`检测
|
||||
* 29bf439 fix: 中途掉号账号未登录(#179)
|
||||
* d3a8b86 fix: 重复评论(#184)
|
||||
* d205cb5 fix: 未知错误1004(#175)
|
||||
* 223a6e1 fix: 获取推荐412(#182)
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.6.0)
|
||||
* 5a7b672 fix: `LotteryOrder`设置(#176)
|
||||
* aae3de8 fix: 仅在评论需要验证码时退出(#175)
|
||||
* 3491888 feat: 抽奖顺序可调`LotteryOrder`(#176)
|
||||
* f6aa0d0 fix: 未知错误带状态码(#175)
|
||||
* 1415f18 fix: 无屏蔽词时全屏蔽
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.5.9)
|
||||
* 292b8e0 fix: 动态数据为null时异常退出
|
||||
* ca6549d feat: 程序在请求多次输入验证码时切换下一个账号 (#167)
|
||||
* e03b483 fix: 远程设置换源gitee
|
||||
* 3e01e42 feat: 预约抽奖奖品屏蔽词 (#159)
|
||||
* 00b5310 feat: 自动点赞且检索本地(#162)
|
||||
* ba100e0 docs: 更新docker运行说明(#160)
|
||||
* 29676d5 ci: mirror to gitlab
|
||||
* dd9ff1b docs: 修改changelog.sh使用http链接
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.5.8)
|
||||
* 4238ee5 fix: 预约验重(#158)
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.5.7)
|
||||
* 607b2d7 feat: 新增设置`disable_reserve_lottery`
|
||||
* 03e24b9 fix: `extend_json`中的`reserve`获取失败(#155)
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.5.6)
|
||||
* 2742dcb feat: 清理动态加入错误重试(#140)
|
||||
* 329c5e5 feat: 自动参与预约抽奖(#155)
|
||||
* 3bc7daf doc: 图片换源gitlab
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.5.5)
|
||||
* df7b321 fix: 远程设置换源gitlab
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.5.4)
|
||||
* f329457 fix: 评论包含敏感词(#150)
|
||||
* 0eddee4 Merge pull request #147 from spiritLHLS/patch-1
|
||||
* ce2c9e5 Update README.md
|
||||
* f1bbc9d Update README.md
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.5.3)
|
||||
* 22e4d2a fix: 转发了不含关键词的抽奖动态(#136)
|
||||
* 354d8cf fix: 推送异常(#132)
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.5.2)
|
||||
* b1f478c feat: 可选通知现阶段运行到哪个账号(#132)
|
||||
* 新增设置`notice_running_state`
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.5.1)
|
||||
* 45ac58e fix: 评论与转发相同时去掉动态原文(#128)
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.5.0)
|
||||
* 41b9540 fix: 未知错误退出
|
||||
|
||||
|
||||
+1
-1
@@ -12,4 +12,4 @@ COPY ["main.js", "./"]
|
||||
COPY ["lib/", "lib/"]
|
||||
|
||||
ENTRYPOINT ["npm", "run"]
|
||||
CMD ["start"]
|
||||
CMD ["start"]
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
FROM arm64v8/node
|
||||
|
||||
WORKDIR /root/lottery
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN npm config set registry https://registry.npm.taobao.org && npm i
|
||||
|
||||
ENV DOWNLOAD_HOST=https://download.fastgit.org \
|
||||
RELEASE_TAG=v3.4 \
|
||||
NODEV=18.5.0 \
|
||||
PKG_CACHE_PATH=/root/.pkg-cache \
|
||||
PKG_IGNORE_TAG=true
|
||||
|
||||
RUN mkdir -p "${PKG_CACHE_PATH}" && \
|
||||
curl -L "$DOWNLOAD_HOST/vercel/pkg-fetch/releases/download/$RELEASE_TAG/node-v$NODEV-linux-arm64" -o \
|
||||
"${PKG_CACHE_PATH}/fetched-v$NODEV-linux-arm64" && \
|
||||
curl -L "$DOWNLOAD_HOST/vercel/pkg-fetch/releases/download/$RELEASE_TAG/node-v$NODEV-linuxstatic-arm64" -o \
|
||||
"${PKG_CACHE_PATH}/fetched-v$NODEV-linuxstatic-arm64"
|
||||
|
||||
CMD ["bash", "-c", "npx pkg -t node$NODEV-linuxstatic-arm64 -o dist/lottery-auto-script-node$NODEV-linuxstatic-arm64 . && \
|
||||
npx pkg -t node$NODEV-linux-arm64 -o dist/lottery-auto-script-node$NODEV-linux-arm64 ."]
|
||||
@@ -6,9 +6,8 @@
|
||||
- [本地运行](#本地运行)
|
||||
- [可执行文件](#可执行文件)
|
||||
- [以源码方式运行](#以源码方式运行)
|
||||
- [Windows](#windows)
|
||||
- [Linux](#linux)
|
||||
- [Docker](#docker)
|
||||
- [青龙面板](#青龙面板)
|
||||
- [防重复转发(可选)](#防重复转发可选)
|
||||
- [检测中奖](#检测中奖)
|
||||
- [检测未读信息, 已读未读信息](#检测未读信息-已读未读信息)
|
||||
@@ -18,16 +17,21 @@
|
||||
|
||||
[Github仓库链接](https://github.com/shanmiteko/LotteryAutoScript)
|
||||
|
||||
[](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/pkg.yml)<br>
|
||||
[](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/docker.yml)<br>
|
||||
[](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/pkg.yml)
|
||||
|
||||
[](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/docker.yml)
|
||||
|
||||
[](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/npmp.yml)
|
||||
|
||||
[](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/mirror.yml)
|
||||
|
||||
已实现功能:
|
||||
|
||||
- 监控用户转发
|
||||
- 监控话题页面
|
||||
- 监控专栏合集
|
||||
- 自动点赞、评论、乱序转发、@好友、带话题、可选随机动态
|
||||
- 直播预约抽奖
|
||||
- 检测是否中奖
|
||||
- 已读@
|
||||
- 已读私信
|
||||
@@ -59,7 +63,7 @@ Chrome浏览器:
|
||||
|
||||
(此步骤是为了方便后续采用JS获取Cookies,获取完毕后应再次勾选)
|
||||
|
||||

|
||||

|
||||
|
||||
3. 在Console中复制以下代码回车
|
||||
|
||||
@@ -104,139 +108,40 @@ Chrome浏览器:
|
||||
3. 在`env.js`中填入`COOKIE`和推送参数
|
||||
4. 在`my_config.js`中自定义设置
|
||||
5. 在当前目录下**打开终端**运行可执行文件`lottery`(勿直接点击`lottery`)
|
||||
|
||||
```sh
|
||||
# unix-like
|
||||
## 进入脚本所在目录
|
||||
## 授予执行权限
|
||||
$ chmod u+x lottery
|
||||
## 启动脚本
|
||||
$ ./lottery start
|
||||
## 检测中奖
|
||||
$ ./lottery check
|
||||
## 清理关注动态
|
||||
$ ./lottery clear
|
||||
## 下载最新版本
|
||||
$ ./lottery clear
|
||||
|
||||
# windows
|
||||
## 不需要chmod
|
||||
## 把`./`换成`.\`或去掉
|
||||
## 已自带*.bat可直接点击
|
||||
```
|
||||
- windows 可直接点击对应的`*.bat`文件
|
||||
- unix-like
|
||||
```sh
|
||||
## 进入脚本所在目录
|
||||
## 授予执行权限
|
||||
$ chmod u+x lottery
|
||||
## 启动脚本
|
||||
$ ./lottery start
|
||||
## 检测中奖
|
||||
$ ./lottery check
|
||||
## 清理关注动态
|
||||
$ ./lottery clear
|
||||
## 下载最新版本
|
||||
$ ./lottery update
|
||||
```
|
||||
|
||||
7. 运行截图
|
||||

|
||||

|
||||
|
||||
#### 以源码方式运行
|
||||
|
||||
<details>
|
||||
[点击跳转](doc/run_use_sc.md)
|
||||
|
||||
<summary>点击显示详细说明</summary>
|
||||
|
||||
##### Windows
|
||||
|
||||
step1: 下载代码到本地
|
||||
|
||||
[点此下载](https://github.com/shanmiteko/LotteryAutoScript/archive/refs/heads/main.zip)或如图示下载↓
|
||||
|
||||

|
||||
|
||||
下载的压缩包解压后修改env.example.js文件,详见step3
|
||||
|
||||
step2: 下载并安装Node.js
|
||||
|
||||
[点此进入nodejs下载页面](http://nodejs.cn/download)
|
||||
|
||||

|
||||
|
||||
step3:修改env.example.js文件及创建运行文件(打开扩展名显示)
|
||||
|
||||
1.step1下载的压缩包解压后将其中的`env.example.js`文件重命名为`env.js`
|
||||
|
||||
2.右键`env.js`文件选择编辑或用记事本打开
|
||||
|
||||
3.填入相关参数
|
||||
|
||||
4.`my_config.example.js`同样操作
|
||||
|
||||
5.运行
|
||||
|
||||
注: `npm i`意味安装依赖, 只需运行一次, 为防止依赖有变化遂每次都执行
|
||||
|
||||
命令一: 启动抽奖
|
||||
|
||||
```bash
|
||||
npm i && npm run start
|
||||
```
|
||||
|
||||
命令二: 检查中奖
|
||||
|
||||
```bash
|
||||
npm i && npm run check
|
||||
```
|
||||
|
||||
命令三: 清理动态
|
||||
|
||||
```bash
|
||||
npm i && npm run clear
|
||||
```
|
||||
|
||||
`script`目录下有启动脚本, 点击即可运行
|
||||
|
||||
注: **本地运行时可在设置中增大扫描页数**
|
||||
|
||||
> ~~[windows系统定时运行](./doc/win_schedule.md)~~
|
||||
|
||||
脚本已内置定时运行功能
|
||||
|
||||
##### Linux
|
||||
|
||||
[linux系统配置与定时运行](./doc/linux_schedule.md)
|
||||
|
||||
</details>
|
||||
----------------------------------------
|
||||
|
||||
### Docker
|
||||
|
||||
1.初始化
|
||||
[点击跳转](doc/run_use_docker.md)
|
||||
|
||||
```bash
|
||||
curl -fsSL https://cdn.staticaly.com/gh/shanmiteko/LotteryAutoScript/main/script/docker/init.sh | sudo sh
|
||||
```
|
||||
----------------------------------------
|
||||
|
||||
进入`lottery`文件夹
|
||||
### 青龙面板
|
||||
|
||||
```bash
|
||||
cd lottery
|
||||
```
|
||||
|
||||
编辑`env.js`与`my_config.js`文件
|
||||
|
||||
- env.js 设置必要环境变量
|
||||
- my_config.js 你的设置
|
||||
|
||||
2.执行相应的脚本
|
||||
```
|
||||
$ tree
|
||||
.
|
||||
├── check.sh
|
||||
├── clear.sh
|
||||
├── debug.sh 进入临时容器查看内容
|
||||
├── env.js
|
||||
├── my_config.js
|
||||
├── new_env.js
|
||||
├── new_my_config.js
|
||||
├── remove_all.sh 移除对应docker镜像和所有相关容器
|
||||
└── start.sh
|
||||
```
|
||||
|
||||
[](https://asciinema.org/a/453237)
|
||||
|
||||
3.更新
|
||||
|
||||
进入lottery上一级目录
|
||||
|
||||
使用与初始化相同的命令
|
||||
[点击跳转](doc/run_use_ql.md)
|
||||
|
||||
----------------------------------------
|
||||
|
||||
@@ -266,31 +171,31 @@ $ tree
|
||||
|
||||
以下是支持的推送方式
|
||||
|
||||
| Name | 归属 | 说明 |
|
||||
| :---------------: | :--------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `SCKEY` | 微信server酱推送(于2021/4月下线) | server酱的微信通知[官方文档](http://sc.ftqq.com/3.version) |
|
||||
| `SENDKEY` | 微信server酱(Turbo版)推送 | [获取SENDKEY](https://sct.ftqq.com/sendkey) [选择消息通道](https://sct.ftqq.com/forward) |
|
||||
| `BARK_PUSH` | [BARK推送](https://apps.apple.com/us/app/bark-customed-notifications/id1403753865) | IOS用户下载BARK这个APP,填写内容是app提供的`设备码`,例如:<https://api.day.app/123> ,那么此处的设备码就是`123`,再不懂看 [这个图](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/bark.jpg)(注:支持自建填完整链接即可) |
|
||||
| `BARK_SOUND` | [BARK推送](https://apps.apple.com/us/app/bark-customed-notifications/id1403753865) | bark推送声音设置,例如`choo`,具体值请在`bark`-`推送铃声`-`查看所有铃声` |
|
||||
| `TG_BOT_TOKEN` | telegram推送 | tg推送(需设备可连接外网),`TG_BOT_TOKEN`和`TG_USER_ID`两者必需,填写自己申请[@BotFather](https://t.me/BotFather)的Token,如`10xxx4:AAFcqxxxxgER5uw` , [具体教程](doc/TG_PUSH.md) |
|
||||
| `TG_USER_ID` | telegram推送 | tg推送(需设备可连接外网),`TG_BOT_TOKEN`和`TG_USER_ID`两者必需,填写[@getuseridbot](https://t.me/getuseridbot)中获取到的纯数字ID, [具体教程](doc/TG_PUSH.md) |
|
||||
| `TG_PROXY_HOST` | Telegram 代理的 IP | 代理类型为 http。例子:http代理 <http://127.0.0.1:1080> 则填写 127.0.0.1 |
|
||||
| `TG_PROXY_PORT` | Telegram 代理的端口 | 例子:http代理 <http://127.0.0.1:1080> 则填写 1080 |
|
||||
| `DD_BOT_TOKEN` | 钉钉推送 | 钉钉推送(`DD_BOT_TOKEN`和`DD_BOT_SECRET`两者必需)[官方文档](https://ding-doc.dingtalk.com/doc#/serverapi2/qf2nxq) ,只需`https://oapi.dingtalk.com/robot/send?access_token=XXX` 等于`=`符号后面的XXX即可 |
|
||||
| `DD_BOT_SECRET` | 钉钉推送 | (`DD_BOT_TOKEN`和`DD_BOT_SECRET`两者必需) ,密钥,机器人安全设置页面,加签一栏下面显示的SEC开头的`SECXXXXXXXXXX`等字符 , 注:钉钉机器人安全设置只需勾选`加签`即可,其他选项不要勾选,再不懂看 [这个图](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/DD_bot.png) |
|
||||
| `IGOT_PUSH_KEY` | iGot推送 | iGot聚合推送,支持多方式推送,确保消息可达。 [参考文档](https://wahao.github.io/Bark-MP-helper ) |
|
||||
| `QQ_SKEY` | 酷推(Cool Push)推送 | 推送所需的Skey,登录后获取Skey [参考文档](https://cp.xuthus.cc/) |
|
||||
| `QQ_MODE` | 酷推(Cool Push)推送 | 推送方式(send或group或者wx,默认send) [参考文档](https://cp.xuthus.cc/) |
|
||||
| `QYWX_KEY` | 企业微信推送 | 密钥,企业微信推送 webhook 后面的 key [详见官方说明文档](https://work.weixin.qq.com/api/doc/90000/90136/91770) |
|
||||
| `PUSH_PLUS_TOKEN` | pushplus推送 | 微信扫码登录后一对一推送或一对多推送下面的token(您的Token) [官方网站](http://pushplus.hxtrip.com/) |
|
||||
| `PUSH_PLUS_USER` | pushplus推送 | 一对多推送的“群组编码”(一对多推送下面->您的群组(如无则新建)->群组编码)注:(1、需订阅者扫描二维码 2、如果您是创建群组所属人,也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送),只填`PUSH_PLUS_TOKEN`默认为一对一推送 |
|
||||
| `QMSG_KEY` | [Qmsg酱](https://qmsg.zendee.cn)私聊推送 | [Qmsg注册](https://qmsg.zendee.cn/login.html) |
|
||||
| `QMSG_QQ` | 私聊消息推送接口,指定需要接收消息的QQ | 指定的QQ号必须在你的[管理台](https://qmsg.zendee.cn/me.html)已添加 |
|
||||
| `SMTP_HOST` | 电子邮件 | smtp服务器的主机名 如: `smtp.qq.com` |
|
||||
| `SMTP_PORT` | 电子邮件 | smtp服务器的端口 如: `465` |
|
||||
| `SMTP_USER` | 电子邮件 | 发送方的电子邮件 如: `xxxxxxxxx@qq.com` |
|
||||
| `SMTP_PASS` | 电子邮件 | smtp服务对应的授权码 |
|
||||
| `SMTP_TO_USER` | 电子邮件 | 接收方电子邮件 |
|
||||
| Name | 归属 | 说明 |
|
||||
| :---------------: | :--------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `SCKEY` | 微信server酱推送(于2021/4月下线) | server酱的微信通知[官方文档](http://sc.ftqq.com/3.version) |
|
||||
| `SENDKEY` | 微信server酱(Turbo版)推送 | [获取SENDKEY](https://sct.ftqq.com/sendkey) [选择消息通道](https://sct.ftqq.com/forward) |
|
||||
| `BARK_PUSH` | [BARK推送](https://apps.apple.com/us/app/bark-customed-notifications/id1403753865) | IOS用户下载BARK这个APP,填写内容是app提供的`设备码`,例如:<https://api.day.app/123> ,那么此处的设备码就是`123`,再不懂看 [这个图](https://raw.githubusercontents.com/shanmiteko/LotteryAutoScript/main/doc/pic/bark.jpg)(注:支持自建填完整链接即可) |
|
||||
| `BARK_SOUND` | [BARK推送](https://apps.apple.com/us/app/bark-customed-notifications/id1403753865) | bark推送声音设置,例如`choo`,具体值请在`bark`-`推送铃声`-`查看所有铃声` |
|
||||
| `TG_BOT_TOKEN` | telegram推送 | tg推送(需设备可连接外网),`TG_BOT_TOKEN`和`TG_USER_ID`两者必需,填写自己申请[@BotFather](https://t.me/BotFather)的Token,如`10xxx4:AAFcqxxxxgER5uw` , [具体教程](doc/TG_PUSH.md) |
|
||||
| `TG_USER_ID` | telegram推送 | tg推送(需设备可连接外网),`TG_BOT_TOKEN`和`TG_USER_ID`两者必需,填写[@getuseridbot](https://t.me/getuseridbot)中获取到的纯数字ID, [具体教程](doc/TG_PUSH.md) |
|
||||
| `TG_PROXY_HOST` | Telegram 代理的 IP | 代理类型为 http。例子:http代理 <http://127.0.0.1:1080> 则填写 127.0.0.1 |
|
||||
| `TG_PROXY_PORT` | Telegram 代理的端口 | 例子:http代理 <http://127.0.0.1:1080> 则填写 1080 |
|
||||
| `DD_BOT_TOKEN` | 钉钉推送 | 钉钉推送(`DD_BOT_TOKEN`和`DD_BOT_SECRET`两者必需)[官方文档](https://ding-doc.dingtalk.com/doc#/serverapi2/qf2nxq) ,只需`https://oapi.dingtalk.com/robot/send?access_token=XXX` 等于`=`符号后面的XXX即可 |
|
||||
| `DD_BOT_SECRET` | 钉钉推送 | (`DD_BOT_TOKEN`和`DD_BOT_SECRET`两者必需) ,密钥,机器人安全设置页面,加签一栏下面显示的SEC开头的`SECXXXXXXXXXX`等字符 , 注:钉钉机器人安全设置只需勾选`加签`即可,其他选项不要勾选,再不懂看 [这个图](https://raw.githubusercontents.com/shanmiteko/LotteryAutoScript/main/doc/pic/DD_bot.png) |
|
||||
| `IGOT_PUSH_KEY` | iGot推送 | iGot聚合推送,支持多方式推送,确保消息可达。 [参考文档](https://wahao.github.io/Bark-MP-helper ) |
|
||||
| `QQ_SKEY` | 酷推(Cool Push)推送 | 推送所需的Skey,登录后获取Skey [参考文档](https://cp.xuthus.cc/) |
|
||||
| `QQ_MODE` | 酷推(Cool Push)推送 | 推送方式(send或group或者wx,默认send) [参考文档](https://cp.xuthus.cc/) |
|
||||
| `QYWX_KEY` | 企业微信推送 | 密钥,企业微信推送 webhook 后面的 key [详见官方说明文档](https://work.weixin.qq.com/api/doc/90000/90136/91770) |
|
||||
| `PUSH_PLUS_TOKEN` | pushplus推送 | 微信扫码登录后一对一推送或一对多推送下面的token(您的Token) [官方网站](http://pushplus.hxtrip.com/) |
|
||||
| `PUSH_PLUS_USER` | pushplus推送 | 一对多推送的“群组编码”(一对多推送下面->您的群组(如无则新建)->群组编码)注:(1、需订阅者扫描二维码 2、如果您是创建群组所属人,也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送),只填`PUSH_PLUS_TOKEN`默认为一对一推送 |
|
||||
| `QMSG_KEY` | [Qmsg酱](https://qmsg.zendee.cn)私聊推送 | [Qmsg注册](https://qmsg.zendee.cn/login.html) |
|
||||
| `QMSG_QQ` | 私聊消息推送接口,指定需要接收消息的QQ | 指定的QQ号必须在你的[管理台](https://qmsg.zendee.cn/me.html)已添加 |
|
||||
| `SMTP_HOST` | 电子邮件 | smtp服务器的主机名 如: `smtp.qq.com` |
|
||||
| `SMTP_PORT` | 电子邮件 | smtp服务器的端口 如: `465` |
|
||||
| `SMTP_USER` | 电子邮件 | 发送方的电子邮件 如: `xxxxxxxxx@qq.com` |
|
||||
| `SMTP_PASS` | 电子邮件 | smtp服务对应的授权码 |
|
||||
| `SMTP_TO_USER` | 电子邮件 | 接收方电子邮件 |
|
||||
|
||||
----------------------------------------
|
||||
|
||||
@@ -300,9 +205,11 @@ $ tree
|
||||
|
||||
详见[my_config.example.js](./my_config.example.js)文件内部注释
|
||||
|
||||
----------------------------------------
|
||||
|
||||
## Awesome
|
||||
相关项目
|
||||
|
||||
- [LotteryAutoScript_Station](https://github.com/spiritLHL/LotteryAutoScript_Station) - [@spiritLHL](https://github.com/spiritLHL)
|
||||
- [sync_lottery](https://github.com/spiritLHL/sync_lottery) - [@spiritLHL](https://github.com/spiritLHL)
|
||||
- [BDSF](https://github.com/spiritLHL/BDSF) - [@spiritLHL](https://github.com/spiritLHL)
|
||||
- [LotteryAutoScript_Station](https://github.com/spiritLHLS/LotteryAutoScript_Station) - [@spiritLHL](https://github.com/spiritLHLS)
|
||||
- [sync_lottery](https://github.com/spiritLHLS/sync_lottery) - [@spiritLHL](https://github.com/spiritLHLS)
|
||||
- [BDSF](https://github.com/spiritLHLS/BDSF) - [@spiritLHL](https://github.com/spiritLHLS)
|
||||
|
||||
+3
-3
@@ -4,16 +4,16 @@
|
||||
|
||||
Ⅰ.首先在Telegram上搜索[BotFather](https://t.me/BotFather)机器人<br>
|
||||
|
||||

|
||||

|
||||
|
||||
Ⅱ.利用[BotFather](https://t.me/BotFather)创建一个属于自己的通知机器人,按照下图中的1、2、3步骤拿到token,格式形如```10xxx4:AAFcqxxxxgER5uw```。填入```TG_BOT_TOKEN```<br>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
**新创建的机器人需要跟它发一条消息来开启对话,否则可能会遇到secret填对了但是收不到消息的情况**<br>
|
||||
|
||||
Ⅲ.再次在Telegram上搜索[getuserIDbot](https://t.me/getuserIDbot)机器人,获取UserID。填入```TG_USER_ID```<br>
|
||||
|
||||

|
||||

|
||||
|
||||
至此,获取**TG_BOT_TOKEN**以及**TG_USER_ID**的教程结束
|
||||
|
||||
@@ -73,7 +73,7 @@ PATH=/sbin:/bin:/usr/sbin/:/usr/bin
|
||||
|
||||
看看有没有效果
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
7.如果本地的脚本需要更新
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.5 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 35 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 188 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.9 MiB |
@@ -0,0 +1,43 @@
|
||||
1.初始化
|
||||
|
||||
```bash
|
||||
curl -fsSL https://cdn.staticaly.com/gh/shanmiteko/LotteryAutoScript/main/script/docker/init.sh | sudo sh
|
||||
```
|
||||
|
||||
进入`lottery`文件夹
|
||||
|
||||
```bash
|
||||
cd lottery
|
||||
```
|
||||
|
||||
编辑`env.js`与`my_config.js`文件
|
||||
|
||||
- env.js 设置必要环境变量
|
||||
- my_config.js 你的设置
|
||||
|
||||
2.执行相应的脚本
|
||||
```
|
||||
$ tree
|
||||
.
|
||||
├── check.sh 检查中奖
|
||||
├── clear.sh 清理动态
|
||||
├── debug.sh 进入临时容器查看内容
|
||||
├── env.js
|
||||
├── my_config.js
|
||||
├── new_env.js
|
||||
├── new_my_config.js
|
||||
├── remove_all.sh 移除对应docker镜像和所有相关容器
|
||||
└── start.sh 启动抽奖
|
||||
```
|
||||
[](https://asciinema.org/a/453237)
|
||||
|
||||
完成配置后
|
||||
|
||||
```sh
|
||||
$ ./start.sh
|
||||
```
|
||||
3.更新
|
||||
|
||||
进入lottery上一级目录
|
||||
|
||||
使用与初始化相同的命令
|
||||
@@ -0,0 +1,17 @@
|
||||
1. 脚本初始化
|
||||
|
||||
复制脚本内容[qinglong](../script/qinglong/init.sh)
|
||||
|
||||

|
||||
|
||||
2. 新建任务
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
3. 填入cookie 修改设置
|
||||
|
||||

|
||||
|
||||
4. 脚本更新即再次运行初始化脚本
|
||||
@@ -0,0 +1,61 @@
|
||||
##### Windows
|
||||
|
||||
step1: 下载代码到本地
|
||||
|
||||
[点此下载](https://github.com/shanmiteko/LotteryAutoScript/archive/refs/heads/main.zip)或如图示下载↓
|
||||
|
||||

|
||||
|
||||
下载的压缩包解压后修改env.example.js文件,详见step3
|
||||
|
||||
step2: 下载并安装Node.js
|
||||
|
||||
[点此进入nodejs下载页面](http://nodejs.cn/download)
|
||||
|
||||

|
||||
|
||||
step3:修改env.example.js文件及创建运行文件(打开扩展名显示)
|
||||
|
||||
1.step1下载的压缩包解压后将其中的`env.example.js`文件重命名为`env.js`
|
||||
|
||||
2.右键`env.js`文件选择编辑或用记事本打开
|
||||
|
||||
3.填入相关参数
|
||||
|
||||
4.`my_config.example.js`同样操作
|
||||
|
||||
5.运行
|
||||
|
||||
注: `npm i`意味安装依赖, 只需运行一次, 为防止依赖有变化遂每次都执行
|
||||
|
||||
命令一: 启动抽奖
|
||||
|
||||
```bash
|
||||
npm i && npm run start
|
||||
```
|
||||
|
||||
命令二: 检查中奖
|
||||
|
||||
```bash
|
||||
npm i && npm run check
|
||||
```
|
||||
|
||||
命令三: 清理动态
|
||||
|
||||
```bash
|
||||
npm i && npm run clear
|
||||
```
|
||||
|
||||
`script`目录下有启动脚本, 点击即可运行
|
||||
|
||||
注: **本地运行时可在设置中增大扫描页数**
|
||||
|
||||
> [windows系统定时运行](./win_schedule.md)
|
||||
|
||||
脚本已内置定时运行功能
|
||||
|
||||
##### Linux
|
||||
|
||||
> [linux系统配置与定时运行](./linux_schedule.md)
|
||||
|
||||
脚本已内置定时运行功能
|
||||
+3
-3
@@ -16,13 +16,13 @@
|
||||
|
||||
7.在`操作`页面中点击`新建`,选择操作为`启动程序`,在设置里点击浏览找到`start.bat`文件并选择,在`起始于(可选)(T):`中的空白框里输入`start.bat`文件的目录地址,也就是`程序或脚本(P):`里`start.bat`的前面那一串目录地址,最后是以`\`结尾的 ,填好东西后按下面`确认`
|
||||
|
||||

|
||||

|
||||
|
||||
8.在`条件`页面中选择`网络`,设定启动条件为任何连接
|
||||
|
||||
9.在`设置`页面中选择如图示选项,或者不修改默认设置
|
||||
|
||||

|
||||

|
||||
|
||||
10.最后按`确定`
|
||||
|
||||
@@ -30,6 +30,6 @@
|
||||
|
||||
最后你可以在任务列表中选择已有的任务,右边的操作框中选择`运行`点击,启动计划的任务,如下图所示
|
||||
|
||||

|
||||

|
||||
|
||||
具体看任务是否正常执行,你可以看看自己的账号动态的最新转发,运行成功每几分钟自动转发抽奖动态
|
||||
|
||||
+9
-5
@@ -1,4 +1,4 @@
|
||||
const { log, delay, infiniteNumber } = require("./utils");
|
||||
const { log, delay, infiniteNumber, retryfn } = require("./utils");
|
||||
const bili = require("./net/bili");
|
||||
const { Searcher } = require("./core/searcher");
|
||||
const global_var = require('./data/global_var');
|
||||
@@ -46,7 +46,7 @@ async function clear() {
|
||||
for (const [index, uid] of uid_list.entries()) {
|
||||
log.info('清理关注', `(${index}) (${uid})`)
|
||||
/* 取消关注 */
|
||||
if (await bili.cancelAttention(uid)) {
|
||||
if (await retryfn(3, [false], () => bili.cancelAttention(uid))) {
|
||||
log.info('清理关注', '成功')
|
||||
} else {
|
||||
log.error('清理关注', '失败')
|
||||
@@ -65,7 +65,11 @@ async function clear() {
|
||||
|
||||
for (const page of infiniteNumber()) {
|
||||
log.info('清理动态', `开始读取第${page + 1}页`);
|
||||
const { allModifyDynamicResArray, offset } = await Searcher.checkAllDynamic(MY_UID, 1, search_wait, next_offset);
|
||||
const { allModifyDynamicResArray, offset } = (await retryfn(
|
||||
3,
|
||||
[null],
|
||||
() => Searcher.checkAllDynamic(MY_UID, 1, search_wait, next_offset)
|
||||
)) || { allModifyDynamicResArray: [], offset: '0' };
|
||||
next_offset = offset;
|
||||
for (const [index, dyinfo] of allModifyDynamicResArray.entries()) {
|
||||
log.info('清理动态', `第${page + 1}页中的第${index + 1}个动态`)
|
||||
@@ -82,7 +86,7 @@ async function clear() {
|
||||
if (dynamic_id
|
||||
&& clear_remove_dynamic
|
||||
&& !(new RegExp(dynamic_id).test(clear_white_list))) {
|
||||
success = await bili.rmDynamic(dynamic_id)
|
||||
success = await retryfn(3, [false], () => bili.rmDynamic(dynamic_id))
|
||||
}
|
||||
|
||||
/* 取消关注 */
|
||||
@@ -91,7 +95,7 @@ async function clear() {
|
||||
&& clear_remove_attention
|
||||
&& before_separate.indexOf(origin_uid) === -1
|
||||
&& uid_list.indexOf(origin_uid) > -1) {
|
||||
success = await bili.cancelAttention(origin_uid);
|
||||
success = await retryfn(3, [false], () => bili.cancelAttention(origin_uid))
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
|
||||
+76
-37
@@ -46,13 +46,17 @@ class Monitor extends Searcher {
|
||||
}
|
||||
/** 关注列表初始化 */
|
||||
this.attentionList = await bili.getAttentionList(global_var.get("myUID"));
|
||||
switch (await this.startLottery()) {
|
||||
const status = await this.startLottery();
|
||||
switch (status) {
|
||||
case 0:
|
||||
event_bus.emit('Turn_on_the_Monitor')
|
||||
break;
|
||||
case 1001:
|
||||
event_bus.emit('Turn_off_the_Monitor', '评论失败')
|
||||
break;
|
||||
case 1004:
|
||||
event_bus.emit('Turn_off_the_Monitor', '需要输入验证码')
|
||||
break
|
||||
case 2001:
|
||||
event_bus.emit('Turn_off_the_Monitor', '关注出错')
|
||||
break;
|
||||
@@ -86,7 +90,7 @@ class Monitor extends Searcher {
|
||||
event_bus.emit('Turn_off_the_Monitor', '获取关注数失败')
|
||||
break
|
||||
default:
|
||||
event_bus.emit('Turn_off_the_Monitor', '??? 未知错误')
|
||||
event_bus.emit('Turn_off_the_Monitor', `??? 未知错误: ${status}`)
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -106,8 +110,10 @@ class Monitor extends Searcher {
|
||||
status = 0,
|
||||
is_exception = 0,
|
||||
is_outof_maxfollow = 0,
|
||||
relayed_nums = 0;
|
||||
relayed_nums = 0,
|
||||
total_nums = 0;
|
||||
for (const [index, lottery] of shuffle(allLottery).entries()) {
|
||||
total_nums += 1;
|
||||
let is_shutdown = false;
|
||||
if (
|
||||
is_outof_maxfollow
|
||||
@@ -172,10 +178,13 @@ class Monitor extends Searcher {
|
||||
break;
|
||||
case 1002:
|
||||
case 1003:
|
||||
case 1004:
|
||||
case 1005:
|
||||
case 1006:
|
||||
case 1007:
|
||||
case 1008:
|
||||
case 1009:
|
||||
case 1010:
|
||||
case 1011:
|
||||
case 2002:
|
||||
case 2003:
|
||||
case 4001:
|
||||
@@ -193,6 +202,7 @@ class Monitor extends Searcher {
|
||||
is_outof_maxfollow = 2005
|
||||
break;
|
||||
case 1001:
|
||||
case 1004:
|
||||
case 2001:
|
||||
case 3001:
|
||||
case 5001:
|
||||
@@ -206,7 +216,7 @@ class Monitor extends Searcher {
|
||||
|
||||
await delay(wait * (Math.random() + 0.5));
|
||||
}
|
||||
log.info('抽奖', `本轮共转发${relayed_nums}条`);
|
||||
log.info('抽奖', `本轮共处理${total_nums}条,成功参与${relayed_nums}条`);
|
||||
return is_exception
|
||||
|| is_outof_maxfollow
|
||||
|| status
|
||||
@@ -246,7 +256,7 @@ class Monitor extends Searcher {
|
||||
/** 所有抽奖信息 */
|
||||
let alllotteryinfo = [];
|
||||
const
|
||||
{ check_if_duplicated, set_lottery_info_url, 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;
|
||||
|
||||
/**
|
||||
@@ -266,7 +276,7 @@ class Monitor extends Searcher {
|
||||
log.info('筛选动态', `去重后(${protoLotteryInfo.length})`);
|
||||
|
||||
/**并发查询dyid */
|
||||
if (check_if_duplicated === 1 || check_if_duplicated === 2) {
|
||||
if (check_if_duplicated >= 1) {
|
||||
await Promise.all(
|
||||
[...dyids_map.keys()]
|
||||
.map(it => d_storage
|
||||
@@ -303,7 +313,7 @@ class Monitor extends Searcher {
|
||||
await try_for_each(protoLotteryInfo, async function (lottery_info) {
|
||||
const {
|
||||
lottery_info_type, is_liked,
|
||||
uids, uname, dyid, create_time,
|
||||
uids, uname, dyid, reserve_id, reserve_lottery_text, create_time,
|
||||
ctrl, rid, des, type,
|
||||
hasOfficialLottery
|
||||
} = lottery_info;
|
||||
@@ -315,8 +325,8 @@ class Monitor extends Searcher {
|
||||
} else {
|
||||
/* 遇到转发过就退出 */
|
||||
if (
|
||||
((!check_if_duplicated || check_if_duplicated === 2) && is_liked)
|
||||
|| ((check_if_duplicated === 1 || check_if_duplicated === 2) && dyids_map.get(dyid))
|
||||
((!check_if_duplicated || check_if_duplicated >= 2) && is_liked)
|
||||
|| ((check_if_duplicated >= 1) && dyids_map.get(dyid))
|
||||
) {
|
||||
log.info("筛选动态", `已转发(https://t.bilibili.com/${dyid})`)
|
||||
return false
|
||||
@@ -342,7 +352,7 @@ class Monitor extends Searcher {
|
||||
needTopic = [...new Set(description.match(/(?<=[带加上](?:话题|tag).*)#.+?#|(?<=[带加上])#.+?#(?=话题|tag)/ig) || [])].join(' '),
|
||||
isRelayDynamic = type === 1,
|
||||
has_key_words = key_words.every(it => new RegExp(it).test(description)),
|
||||
isBlock = new RegExp(blockword.join('|')).test(description),
|
||||
isBlock = blockword.length && new RegExp(blockword.join('|')).test(description + reserve_lottery_text),
|
||||
isLottery =
|
||||
(is_imitator && lottery_info_type === 'uid' && model !== '00')
|
||||
|| (hasOfficialLottery && model[0] === '1')
|
||||
@@ -368,29 +378,6 @@ class Monitor extends Searcher {
|
||||
|
||||
log.debug("筛选动态", { real_uid, mIsFollowed, oriIsFollowed, realIsFollowed, needAt, needTopic, type, isRelayDynamic, key_words, has_key_words, blockword, isBlock, isLottery, isSendChat })
|
||||
|
||||
if (block_dynamic_type.includes(type)) {
|
||||
log.warn("筛选动态", `屏蔽动态类型 ${type}`)
|
||||
return false
|
||||
}
|
||||
|
||||
if (!has_key_words && description) {
|
||||
log.warn("筛选动态", `无关键词动态的描述: ${description}\n\n考虑是否修改设置key_words:\n${key_words.join('\n')}`)
|
||||
}
|
||||
|
||||
/**屏蔽词 */
|
||||
if (isBlock) {
|
||||
log.info("筛选动态", `包含屏蔽词(https://t.bilibili.com/${dyid})`)
|
||||
return false
|
||||
}
|
||||
|
||||
/**若勾选只转已关注 */
|
||||
if (only_followed
|
||||
&& (!mIsFollowed || !oriIsFollowed)
|
||||
) {
|
||||
log.info("筛选动态", `只转已关注(https://t.bilibili.com/${dyid})`)
|
||||
return false
|
||||
}
|
||||
|
||||
if (
|
||||
new_blacklist.some(id => keys.some(key => {
|
||||
if (key + '' === id) {
|
||||
@@ -404,6 +391,45 @@ class Monitor extends Searcher {
|
||||
return false
|
||||
}
|
||||
|
||||
if (block_dynamic_type.includes(type)) {
|
||||
log.warn("筛选动态", `屏蔽动态类型 ${type}`)
|
||||
return false
|
||||
}
|
||||
|
||||
/**屏蔽词 */
|
||||
if (isBlock) {
|
||||
log.info("筛选动态", `包含屏蔽词(https://t.bilibili.com/${dyid})`)
|
||||
return false
|
||||
}
|
||||
|
||||
if (reserve_id) {
|
||||
if (disable_reserve_lottery) {
|
||||
log.info("已关闭预约抽奖功能")
|
||||
} else {
|
||||
log.info("预约抽奖", "开始");
|
||||
log.info("预约抽奖", `奖品: ${reserve_lottery_text}`);
|
||||
if (hasEnv('NOT_GO_LOTTERY')) {
|
||||
log.info('NOT_GO_LOTTERY', 'ON');
|
||||
} else {
|
||||
await delay(reserve_lottery_wait);
|
||||
await bili.reserve_lottery(reserve_id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!has_key_words && description) {
|
||||
log.warn("筛选动态", `无关键词动态的描述: ${description}\n\n考虑是否修改设置key_words:\n${key_words.join('\n且满足: ')}`)
|
||||
return false
|
||||
}
|
||||
|
||||
/**若勾选只转已关注 */
|
||||
if (only_followed
|
||||
&& (!mIsFollowed || !oriIsFollowed)
|
||||
) {
|
||||
log.info("筛选动态", `只转已关注(https://t.bilibili.com/${dyid})`)
|
||||
return false
|
||||
}
|
||||
|
||||
if (isLottery) {
|
||||
const { uname_map = {} } = global_var.get("remoteconfig")
|
||||
let onelotteryinfo = {};
|
||||
@@ -505,6 +531,10 @@ class Monitor extends Searcher {
|
||||
* - 评论 已被对方拉入黑名单 1005
|
||||
* - 评论 黑名单用户无法互动 1006
|
||||
* - 评论 UP主已关闭评论区 1007
|
||||
* - 评论 内容包含敏感信息 1008
|
||||
* - 评论 重复评论 1009
|
||||
* - 评论 帐号未登录 1010
|
||||
* - 评论 关注UP主7天以上的人可发评论 1011
|
||||
* - 关注 未知错误 2001
|
||||
* - 关注 您已被对方拉入黑名单 2002
|
||||
* - 关注 黑名单用户无法关注 2003
|
||||
@@ -535,15 +565,24 @@ class Monitor extends Searcher {
|
||||
if (rid && chat_type) {
|
||||
|
||||
status = await retryfn(
|
||||
5,
|
||||
6,
|
||||
[1, 4],
|
||||
() => bili.sendChat(
|
||||
rid,
|
||||
is_repost_then_chat ? relay_chat : chat,
|
||||
is_repost_then_chat ? relay_chat.split('//')[0] : chat,
|
||||
chat_type
|
||||
)
|
||||
)
|
||||
|
||||
if (status === 8 ||
|
||||
status === 9) {
|
||||
status = await bili.sendChat(
|
||||
rid,
|
||||
"[doge][doge][doge][doge][doge]",
|
||||
chat_type
|
||||
)
|
||||
}
|
||||
|
||||
if (status) {
|
||||
log.warn("抽奖信息", `dyid: ${dyid}, rid: ${rid}, chat_type: ${chat_type}`)
|
||||
return 1000 + status
|
||||
@@ -570,7 +609,7 @@ class Monitor extends Searcher {
|
||||
}
|
||||
|
||||
/* 点赞 */
|
||||
if (!check_if_duplicated) {
|
||||
if (!check_if_duplicated || check_if_duplicated === 3) {
|
||||
status = await retryfn(
|
||||
5,
|
||||
[1, 2, 3],
|
||||
|
||||
+58
-10
@@ -18,6 +18,8 @@ const { log } = utils
|
||||
* @property {string} dynamic_id
|
||||
* @property {number} type
|
||||
* @property {string} description
|
||||
* @property {string} reserve_id
|
||||
* @property {string} reserve_lottery_text
|
||||
* @property {boolean} hasOfficialLottery
|
||||
* @property {Array<Object.<string,string|number>>} ctrl
|
||||
* @property {number} origin_create_time 10
|
||||
@@ -27,6 +29,8 @@ const { log } = utils
|
||||
* @property {string} origin_dynamic_id
|
||||
* @property {number} orig_type
|
||||
* @property {string} origin_description
|
||||
* @property {string} origin_reserve_id
|
||||
* @property {string} origin_reserve_lottery_text
|
||||
* @property {boolean} origin_hasOfficialLottery
|
||||
*
|
||||
* 整理后的抽奖信息
|
||||
@@ -38,6 +42,8 @@ const { log } = utils
|
||||
* @property {string} uname
|
||||
* @property {Array<{}>} ctrl
|
||||
* @property {string} dyid
|
||||
* @property {string} reserve_id
|
||||
* @property {string} reserve_lottery_text
|
||||
* @property {string} rid
|
||||
* @property {string} des
|
||||
* @property {number} type
|
||||
@@ -50,10 +56,12 @@ function parseDynamicCard(dynamic_detail_card) {
|
||||
const { strToJson } = utils;
|
||||
/**临时储存单个动态中的信息 */
|
||||
let obj = {};
|
||||
const { desc, card, extension, extend_json } = dynamic_detail_card
|
||||
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;
|
||||
/* 转发者的UID */
|
||||
obj.uid = desc.uid
|
||||
@@ -72,7 +80,22 @@ function parseDynamicCard(dynamic_detail_card) {
|
||||
/* 转发者的动态ID !!!!此为大数需使用字符串值,不然JSON.parse()会有丢失精度 */
|
||||
obj.dynamic_id = desc.dynamic_id_str;
|
||||
/* 定位@信息 */
|
||||
obj.ctrl = (extend_json && strToJson(extend_json).ctrl) || [];
|
||||
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;
|
||||
}
|
||||
}
|
||||
/* 是否有官方抽奖 */
|
||||
obj.hasOfficialLottery = extension && extension.lott && true;
|
||||
/* 转发者的描述 纯文字内容 图片动态描述 后两个分别是视频动态的描述和视频本身的描述*/
|
||||
@@ -83,6 +106,7 @@ function parseDynamicCard(dynamic_detail_card) {
|
||||
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;
|
||||
@@ -92,6 +116,21 @@ function parseDynamicCard(dynamic_detail_card) {
|
||||
obj.origin_rid_str = desc.origin.rid_str.length > 12 ? desc.origin.dynamic_id_str : desc.origin.rid_str;
|
||||
/* 被转发者的动态的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;
|
||||
}
|
||||
}
|
||||
/* 是否有官方抽奖 */
|
||||
obj.origin_hasOfficialLottery = origin_extension && origin_extension.lott;
|
||||
/* 被转发者的name */
|
||||
@@ -161,7 +200,7 @@ class Searcher {
|
||||
* @param {number} pages 读取页数
|
||||
* @param {number} time 时延
|
||||
* @param {string} [offset] 默认'0'
|
||||
* @returns {Promise<{allModifyDynamicResArray: UsefulDynamicInfo[], offset: string}>} 获取前 `pages*12` 个动态信息
|
||||
* @returns {Promise<{allModifyDynamicResArray: UsefulDynamicInfo[], offset: string} | null>} 获取前 `pages*12` 个动态信息
|
||||
*/
|
||||
static async checkAllDynamic(hostuid, pages, time = 0, offset = '0') {
|
||||
log.info('检查所有动态', `准备读取${pages}页动态`);
|
||||
@@ -190,7 +229,7 @@ class Searcher {
|
||||
mDRdata = modifyDynamicRes(OneDynamicInfo);
|
||||
|
||||
if (mDRdata === null) {
|
||||
break;
|
||||
return null
|
||||
}
|
||||
|
||||
const
|
||||
@@ -225,9 +264,12 @@ class Searcher {
|
||||
*/
|
||||
async getLotteryInfoByUID(UID) {
|
||||
log.info('获取动态', `开始获取用户${UID}的动态信息`);
|
||||
const { allModifyDynamicResArray } = await Searcher.checkAllDynamic(UID, uid_scan_page, search_wait);
|
||||
const AllDynamic = await Searcher.checkAllDynamic(UID, uid_scan_page, search_wait);
|
||||
|
||||
let { length } = allModifyDynamicResArray
|
||||
if (AllDynamic === null) return null
|
||||
|
||||
let { allModifyDynamicResArray } = AllDynamic,
|
||||
{ length } = allModifyDynamicResArray;
|
||||
|
||||
if (!length) return null;
|
||||
|
||||
@@ -246,7 +288,7 @@ class Searcher {
|
||||
{ origin_dynamic_id } = cur,
|
||||
is_liked = false;
|
||||
|
||||
if (!check_if_duplicated || check_if_duplicated === 2) {
|
||||
if (!check_if_duplicated || check_if_duplicated >= 2) {
|
||||
const card = await bili.getOneDynamicByDyid(origin_dynamic_id)
|
||||
log.info('获取动态', `查看源动态(${origin_dynamic_id})是否点赞 (${length--})`)
|
||||
if (card) {
|
||||
@@ -263,6 +305,8 @@ class Searcher {
|
||||
uname: cur.origin_uname,
|
||||
ctrl: [],
|
||||
dyid: cur.origin_dynamic_id,
|
||||
reserve_id: cur.origin_reserve_id,
|
||||
reserve_lottery_text: cur.origin_reserve_lottery_text,
|
||||
rid: cur.origin_rid_str,
|
||||
des: cur.origin_description,
|
||||
type: cur.orig_type,
|
||||
@@ -321,6 +365,8 @@ class Searcher {
|
||||
uname: o.uname,
|
||||
ctrl: o.ctrl,
|
||||
dyid: o.dynamic_id,
|
||||
reserve_id: o.reserve_id,
|
||||
reserve_lottery_text: o.reserve_lottery_text,
|
||||
rid: o.rid_str,
|
||||
des: o.description,
|
||||
type: o.type,
|
||||
@@ -377,9 +423,9 @@ class Searcher {
|
||||
, { is_liked } = parsed_card;
|
||||
|
||||
if (
|
||||
((!check_if_duplicated || check_if_duplicated === 2)
|
||||
((!check_if_duplicated || check_if_duplicated >= 2)
|
||||
&& is_liked)
|
||||
|| ((check_if_duplicated === 1 || check_if_duplicated === 2)
|
||||
|| ((check_if_duplicated >= 1)
|
||||
&& await d_storage.searchDyid(dyid))
|
||||
) {
|
||||
log.info('获取动态', `动态(${dyid})已转发过`)
|
||||
@@ -409,6 +455,8 @@ class Searcher {
|
||||
uname: o.uname,
|
||||
ctrl: o.ctrl,
|
||||
dyid: o.dynamic_id,
|
||||
reserve_id: o.reserve_id,
|
||||
reserve_lottery_text: o.reserve_lottery_text,
|
||||
rid: o.rid_str,
|
||||
des: o.description,
|
||||
type: o.type,
|
||||
@@ -451,7 +499,7 @@ class Searcher {
|
||||
let results = await pre
|
||||
, { dyid } = cur;
|
||||
|
||||
if (!check_if_duplicated || check_if_duplicated === 2) {
|
||||
if (!check_if_duplicated || check_if_duplicated >= 2) {
|
||||
log.info('获取动态', `查看动态(${dyid})是否点赞 (${length--})`)
|
||||
const card = await bili.getOneDynamicByDyid(dyid)
|
||||
|
||||
|
||||
+39
-8
@@ -6,16 +6,16 @@ const config = {
|
||||
*/
|
||||
UIDs: [],
|
||||
|
||||
/**
|
||||
* 监视的tag
|
||||
*/
|
||||
|
||||
TAGs: [],
|
||||
/**
|
||||
* 监视的专栏关键词
|
||||
*/
|
||||
Articles: [],
|
||||
|
||||
/**
|
||||
* 监视的tag
|
||||
*/
|
||||
TAGs: [],
|
||||
|
||||
/**
|
||||
* 从API接口中获取抽奖信息
|
||||
* @typedef {object} LotteryInfo
|
||||
@@ -26,6 +26,8 @@ const config = {
|
||||
* @property {string} uname
|
||||
* @property {Array<{}>} ctrl
|
||||
* @property {string} dyid
|
||||
* @property {string} reserve_id
|
||||
* @property {string} reserve_lottery_text
|
||||
* @property {string} rid
|
||||
* @property {string} des
|
||||
* @property {number} type
|
||||
@@ -38,6 +40,18 @@ const config = {
|
||||
*/
|
||||
APIs: [],
|
||||
|
||||
/**
|
||||
* 抽奖参与顺序组合
|
||||
* * 0 - UIDs
|
||||
* * 1 - TAGs
|
||||
* * 2 - Articles
|
||||
* * 3 - APIs
|
||||
* @example
|
||||
* [3,2,1,0]
|
||||
* [1,2,1,2,1]
|
||||
*/
|
||||
LotteryOrder: [2, 0, 1, 3],
|
||||
|
||||
/**
|
||||
* API发送数据类型 {LotteryInfo[]}
|
||||
* 上传抽奖信息的链接字符串
|
||||
@@ -69,12 +83,19 @@ const config = {
|
||||
*/
|
||||
chatmodel: '01',
|
||||
|
||||
/**
|
||||
* 不参与预约抽奖
|
||||
*/
|
||||
disable_reserve_lottery: false,
|
||||
|
||||
|
||||
/**
|
||||
* 检查是否重复转发
|
||||
* - 不检查 -1
|
||||
* - 通过是否点赞判断 0
|
||||
* - 通过是否点赞判断(自动点赞) 0
|
||||
* - 检索本地dyids文件 1
|
||||
* - 通过是否点赞判断+检索本地dyids文件 2
|
||||
* - 通过是否点赞判断(不自动点赞)+检索本地dyids文件 2
|
||||
* - 通过是否点赞判断(自动点赞)+检索本地dyids文件 3
|
||||
*/
|
||||
check_if_duplicated: 1,
|
||||
|
||||
@@ -149,7 +170,6 @@ const config = {
|
||||
lottery_loop_wait: 0,
|
||||
check_loop_wait: 0,
|
||||
clear_loop_wait: 0,
|
||||
update_loop_wait: 0,
|
||||
|
||||
/**
|
||||
* - 转发间隔时间
|
||||
@@ -200,6 +220,12 @@ const config = {
|
||||
*/
|
||||
random_dynamic_wait: 2000,
|
||||
|
||||
/**
|
||||
* - 预约抽奖间隔
|
||||
* - 单位毫秒
|
||||
*/
|
||||
reserve_lottery_wait: 6000,
|
||||
|
||||
/**
|
||||
* - up主粉丝数限制
|
||||
*/
|
||||
@@ -317,6 +343,11 @@ const config = {
|
||||
"~你预约的直播已开始"
|
||||
],
|
||||
|
||||
/**
|
||||
* 是否发送运行状态通知
|
||||
*/
|
||||
notice_running_state: false,
|
||||
|
||||
/**
|
||||
* - 获取私信页数
|
||||
*/
|
||||
|
||||
+18
-10
@@ -1,8 +1,6 @@
|
||||
const { getRemoteConfig, createDir, createFile } = require("../utils");
|
||||
const config = require("../data/config");
|
||||
|
||||
const key_map = new Map([['DedeUserID', 'myUID'], ['bili_jct', 'csrf']]);
|
||||
|
||||
let global_var = {
|
||||
inner: {},
|
||||
get(key) {
|
||||
@@ -19,9 +17,19 @@ let global_var = {
|
||||
*/
|
||||
async init(cookie, num) {
|
||||
if (cookie) {
|
||||
const
|
||||
key_map = new Map([
|
||||
['DedeUserID', 'myUID'],
|
||||
['bili_jct', 'csrf']]),
|
||||
LotteryOrderMap = new Map([
|
||||
[0, "UIDs"],
|
||||
[1, "TAGs"],
|
||||
[2, "Articles"],
|
||||
[3, "APIs"]]);
|
||||
|
||||
config.updata(num);
|
||||
|
||||
this.set('cookie', cookie);
|
||||
this.set('cookie', cookie + ';buvid3=AAAAAAAA-BBBB-CCCC-DDDD-DDDDDDDDDDDDDDDDDinfoc');
|
||||
|
||||
cookie.split(/\s*;\s*/).forEach(item => {
|
||||
const _item = item.split('=');
|
||||
@@ -29,13 +37,13 @@ let global_var = {
|
||||
this.set(key_map.get(_item[0]), _item[1]);
|
||||
});
|
||||
|
||||
const { UIDs = [], TAGs = [], Articles = [], APIs = [] } = config;
|
||||
this.set('Lottery', [
|
||||
...UIDs.map(it => ['UIDs', it]),
|
||||
...TAGs.map(it => ['TAGs', it]),
|
||||
...Articles.map(it => ['Articles', it]),
|
||||
...APIs.map(it => ['APIs', it])
|
||||
]);
|
||||
const { LotteryOrder } = config;
|
||||
this.set('Lottery',
|
||||
LotteryOrder
|
||||
.map(it => LotteryOrderMap.get(it))
|
||||
.filter(it => typeof it === "string")
|
||||
.flatMap(lottery_option => config[lottery_option]
|
||||
.map(it => [lottery_option, it])));
|
||||
this.set('remoteconfig', await getRemoteConfig());
|
||||
}
|
||||
await createDir('dyids');
|
||||
|
||||
@@ -30,11 +30,11 @@ async function randomDynamic(num) {
|
||||
await utils.try_for_each(
|
||||
utils.shuffle(dynamics).slice(0, num),
|
||||
async (dynamic) => {
|
||||
await utils.delay(random_dynamic_wait)
|
||||
await utils.delay(random_dynamic_wait);
|
||||
if (dynamic instanceof Array && dynamic.length === 2 && typeof dynamic[0] === "number") {
|
||||
return await bili.shareVideo(...dynamic)
|
||||
await bili.shareVideo(...dynamic)
|
||||
} else {
|
||||
return await bili.createDynamic(dynamic)
|
||||
await bili.createDynamic(dynamic)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
+1
-2
@@ -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 }
|
||||
+15
-4
@@ -5,13 +5,18 @@ const { Searcher } = require('./core/searcher');
|
||||
const { Monitor } = require('./core/monitor');
|
||||
const config = require('./data/config');
|
||||
const { randomDynamic } = require('./helper/randomDynamic');
|
||||
const { sendNotify } = require('./helper/notify');
|
||||
const { log } = utils;
|
||||
|
||||
async function createRandomDynamic(num) {
|
||||
if (config.create_dy) {
|
||||
log.info('随机动态', `准备创建${num}条随机动态`);
|
||||
const
|
||||
{ allModifyDynamicResArray } = await Searcher.checkAllDynamic(global_var.get("myUID"), 1),
|
||||
{ allModifyDynamicResArray } = (await utils.retryfn(
|
||||
3,
|
||||
[null],
|
||||
() => Searcher.checkAllDynamic(global_var.get("myUID"), 1)
|
||||
)) || { allModifyDynamicResArray: [] },
|
||||
{ type, orig_type } = allModifyDynamicResArray[0] || {};
|
||||
if (type === 1 && orig_type !== 8) {
|
||||
await randomDynamic(num)
|
||||
@@ -23,18 +28,21 @@ async function createRandomDynamic(num) {
|
||||
|
||||
/**
|
||||
* 抽奖主函数
|
||||
* @param {string} cookie
|
||||
* @param {string} num
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
function start() {
|
||||
function start(num) {
|
||||
return new Promise(resolve => {
|
||||
let times = utils.counter();
|
||||
if (config.notice_running_state) {
|
||||
sendNotify(`动态抽奖-帐号${num}开始抽奖`, "运行正常")
|
||||
}
|
||||
/* 注册事件 */
|
||||
event_bus.on('Turn_on_the_Monitor', async () => {
|
||||
const lotterys = global_var.get("Lottery");
|
||||
if (lotterys.length === 0) {
|
||||
log.info('抽奖', '抽奖信息为空');
|
||||
resolve();
|
||||
event_bus.emit('Turn_off_the_Monitor', '抽奖信息为空')
|
||||
return;
|
||||
}
|
||||
if (times.value() === lotterys.length) {
|
||||
@@ -48,6 +56,9 @@ function start() {
|
||||
await (new Monitor(lottery)).init();
|
||||
});
|
||||
event_bus.on('Turn_off_the_Monitor', async (msg) => {
|
||||
if (config.notice_running_state) {
|
||||
sendNotify(`动态抽奖-帐号${num}结束抽奖`, msg)
|
||||
}
|
||||
await createRandomDynamic(config.create_dy_num);
|
||||
log.info('结束抽奖', '原因: ' + msg);
|
||||
event_bus.flush();
|
||||
|
||||
+3
-1
@@ -1,5 +1,6 @@
|
||||
module.exports = Object.freeze({
|
||||
DYNAMIC_LIKE_THUMB: 'https://api.vc.bilibili.com/dynamic_like/v1/dynamic_like/thumb',
|
||||
DYNAMIC_MIX_RESERVE_ATTACH_CARD_BUTTON: 'https://api.vc.bilibili.com/dynamic_mix/v1/dynamic_mix/reserve_attach_card_button',
|
||||
DYNAMIC_REPOST_REPOST: 'https://api.vc.bilibili.com/dynamic_repost/v1/dynamic_repost/repost',
|
||||
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',
|
||||
@@ -7,9 +8,9 @@ module.exports = Object.freeze({
|
||||
DYNAMIC_SVR_GET_DYNAMIC_DETAIL: 'https://api.vc.bilibili.com/dynamic_svr/v1/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',
|
||||
FETCH_SESSION_MSGS: 'https://api.vc.bilibili.com/svr_sync/v1/svr_sync/fetch_session_msgs',
|
||||
FEED_GET_ATTENTION_LIST: 'https://api.vc.bilibili.com/feed/v1/feed/get_attention_list',
|
||||
FEED_SETUSERFOLLOW: 'https://api.vc.bilibili.com/feed/v1/feed/SetUserFollow',
|
||||
FETCH_SESSION_MSGS: 'https://api.vc.bilibili.com/svr_sync/v1/svr_sync/fetch_session_msgs',
|
||||
LOTTERY_SVR_LOTTERY_NOTICE: 'https://api.vc.bilibili.com/lottery_svr/v1/lottery_svr/lottery_notice',
|
||||
MSGFEED_AT: 'https://api.bilibili.com/x/msgfeed/at',
|
||||
MSGFEED_REPLAY: 'https://api.bilibili.com/x/msgfeed/reply',
|
||||
@@ -29,6 +30,7 @@ module.exports = Object.freeze({
|
||||
SPACE_MYINFO: 'https://api.bilibili.com/x/space/myinfo',
|
||||
TAG_INFO: 'https://api.bilibili.com/x/tag/info',
|
||||
TOP_RCMD: "https://api.bilibili.com/x/web-interface/index/top/rcmd",
|
||||
TOP_FEED_RCMD: "https://api.bilibili.com/x/web-interface/index/top/feed/rcmd",
|
||||
TOPIC_SVR_TOPIC_HISTORY: 'https://api.vc.bilibili.com/topic_svr/v1/topic_svr/topic_history',
|
||||
TOPIC_SVR_TOPIC_NEW: 'https://api.vc.bilibili.com/topic_svr/v1/topic_svr/topic_new',
|
||||
WEB_INTERFACE_CARD: 'https://api.bilibili.com/x/web-interface/card',
|
||||
|
||||
+92
-39
@@ -634,9 +634,9 @@ const bili_client = {
|
||||
(uid) => post({
|
||||
url: API.RELATION_BATCH_MODIFY,
|
||||
contents: {
|
||||
fid: uid,
|
||||
fids: uid,
|
||||
act: 1,
|
||||
re_src: 0,
|
||||
re_src: 1,
|
||||
csrf: GlobalVar.get("csrf")
|
||||
}
|
||||
})
|
||||
@@ -817,6 +817,34 @@ const bili_client = {
|
||||
return 1;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 预约抽奖
|
||||
* @param {number} reserve_id
|
||||
* @returns
|
||||
*/
|
||||
async reserve_lottery(reserve_id) {
|
||||
const
|
||||
responseText = await post({
|
||||
url: API.DYNAMIC_MIX_RESERVE_ATTACH_CARD_BUTTON,
|
||||
contents: {
|
||||
cur_btn_status: "1",
|
||||
reserve_id,
|
||||
csrf: GlobalVar.get("csrf")
|
||||
}
|
||||
}),
|
||||
res = strToJson(responseText);
|
||||
switch (res.code) {
|
||||
case 0:
|
||||
log.info('预约抽奖', '预约成功');
|
||||
return 0;
|
||||
case 7604003:
|
||||
log.warn('预约抽奖', '重复预约');
|
||||
return 0;
|
||||
default:
|
||||
log.error('预约抽奖', `未知错误\n${responseText}`);
|
||||
return 1;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @typedef Picture
|
||||
* @property {string} img_src
|
||||
@@ -830,7 +858,7 @@ const bili_client = {
|
||||
let
|
||||
contents = {
|
||||
csrf: GlobalVar.get("csrf"),
|
||||
extension: '{"emoji_type":1,"from":{"emoji_type":1},"flag_cfg":{}}'
|
||||
extension: '{"emoji_type":1,"from":{"emoji_type":1},"flag_cfg":{}}',
|
||||
},
|
||||
url = '';
|
||||
if (content instanceof Array) {
|
||||
@@ -845,6 +873,7 @@ const bili_client = {
|
||||
url = API.DYNAMIC_SVR_CREATE
|
||||
contents = {
|
||||
...contents,
|
||||
type: 4,
|
||||
content,
|
||||
}
|
||||
}
|
||||
@@ -860,53 +889,61 @@ const bili_client = {
|
||||
return true
|
||||
}
|
||||
},
|
||||
_getTopRcmd: new Line('获取推荐', [
|
||||
() => get({
|
||||
url: API.TOP_RCMD
|
||||
}),
|
||||
() => get({
|
||||
url: API.TOP_FEED_RCMD
|
||||
})
|
||||
], responseText => {
|
||||
const res = strToJson(responseText);
|
||||
if (res.code === 0) {
|
||||
return [false, res.data.item.map(it => {
|
||||
return [it.owner.mid, it.id];
|
||||
}), "成功"];
|
||||
} else {
|
||||
return [true, [], `获取推荐失败\n${responseText}`];
|
||||
}
|
||||
}),
|
||||
/**
|
||||
* 获取推荐
|
||||
* @returns {Promise<Array<[number, number]>>}
|
||||
*/
|
||||
async getTopRcmd() {
|
||||
const
|
||||
responseText = await get(
|
||||
{
|
||||
url: API.TOP_RCMD,
|
||||
}
|
||||
),
|
||||
res = strToJson(responseText);
|
||||
if (res.code === 0) {
|
||||
log.info('获取推荐', `成功`);
|
||||
return res.data.item.map(it => {
|
||||
return [it.owner.mid, it.id];
|
||||
});
|
||||
} else {
|
||||
log.error('获取推荐', `获取推荐失败\n${responseText}`);
|
||||
return [];
|
||||
}
|
||||
return this._getTopRcmd.run()
|
||||
},
|
||||
/**
|
||||
* 分享视频
|
||||
* @param {number} uid
|
||||
* @param {number} aid
|
||||
* @return {boolean} isError true
|
||||
* @return {Promise<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
|
||||
}
|
||||
},
|
||||
/**
|
||||
@@ -951,6 +988,10 @@ const bili_client = {
|
||||
* - 已被对方拉入黑名单 5
|
||||
* - 黑名单用户无法互动 6
|
||||
* - UP主已关闭评论区 7
|
||||
* - 评论内容包含敏感信息 8
|
||||
* - 重复评论 9
|
||||
* - 帐号未登录 10
|
||||
* - 关注UP主7天以上的人可发评论 11
|
||||
*/
|
||||
async sendChat(rid, msg, type) {
|
||||
const
|
||||
@@ -966,7 +1007,7 @@ const bili_client = {
|
||||
res = strToJson(responseText);
|
||||
switch (res.code) {
|
||||
case 0:
|
||||
log.info('自动评论', '评论成功');
|
||||
log.info('自动评论', `评论成功: ${msg}`);
|
||||
return 0;
|
||||
case -404:
|
||||
log.error('自动评论', '原动态已删除');
|
||||
@@ -986,6 +1027,18 @@ const bili_client = {
|
||||
case 12061:
|
||||
log.error('自动评论', 'UP主已关闭评论区');
|
||||
return 7;
|
||||
case 12016:
|
||||
log.error('自动评论', '评论内容包含敏感信息');
|
||||
return 8;
|
||||
case 12051:
|
||||
log.error('自动评论', '重复评论');
|
||||
return 9;
|
||||
case -101:
|
||||
log.error('自动评论', '帐号未登录');
|
||||
return 10;
|
||||
case 12078:
|
||||
log.error('自动评论', '关注UP主7天以上的人可发评论');
|
||||
return 11;
|
||||
default:
|
||||
log.error('自动评论', `未知错误\n${responseText}`);
|
||||
return 1;
|
||||
|
||||
+3
-3
@@ -64,6 +64,7 @@ const utils = {
|
||||
* @param {number} max_times
|
||||
* @param {Array<T>} unexpected
|
||||
* @param {() => Promise<T>} fn
|
||||
* @return {Promise<T | null>}
|
||||
*/
|
||||
async retryfn(max_times, unexpected, fn) {
|
||||
let ret = null;
|
||||
@@ -294,15 +295,14 @@ const utils = {
|
||||
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',
|
||||
accept: 'text/plain; charset=utf-8',
|
||||
referer: 'https://gitee.com/shanmite/lottery-notice/blob/master/notice.json',
|
||||
},
|
||||
success: res => {
|
||||
try {
|
||||
const body = JSON.parse(res.body);
|
||||
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({})
|
||||
}
|
||||
},
|
||||
|
||||
@@ -49,19 +49,19 @@ 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('抽奖', '开始运行');
|
||||
loop_wait = lottery_loop_wait;
|
||||
await start();
|
||||
await start(NUMBER);
|
||||
break;
|
||||
case 'check':
|
||||
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);
|
||||
|
||||
+40
-10
@@ -11,13 +11,6 @@ module.exports = Object.freeze({
|
||||
241675899
|
||||
],
|
||||
|
||||
/**
|
||||
* 监视的专栏关键词
|
||||
*/
|
||||
Articles: [
|
||||
'抽奖合集'
|
||||
],
|
||||
|
||||
/**
|
||||
* 监视的tag
|
||||
*/
|
||||
@@ -28,6 +21,13 @@ module.exports = Object.freeze({
|
||||
'抽奖',
|
||||
],
|
||||
|
||||
/**
|
||||
* 监视的专栏关键词
|
||||
*/
|
||||
Articles: [
|
||||
'抽奖合集'
|
||||
],
|
||||
|
||||
/**
|
||||
* 从API接口中获取抽奖信息
|
||||
* @typedef {object} LotteryInfo
|
||||
@@ -38,6 +38,8 @@ module.exports = Object.freeze({
|
||||
* @property {string} uname
|
||||
* @property {Array<{}>} ctrl
|
||||
* @property {string} dyid
|
||||
* @property {string} reserve_id
|
||||
* @property {string} reserve_lottery_text
|
||||
* @property {string} rid
|
||||
* @property {string} des
|
||||
* @property {number} type
|
||||
@@ -52,6 +54,18 @@ module.exports = Object.freeze({
|
||||
*/
|
||||
APIs: [],
|
||||
|
||||
/**
|
||||
* 抽奖参与顺序组合
|
||||
* * 0 - UIDs
|
||||
* * 1 - TAGs
|
||||
* * 2 - Articles
|
||||
* * 3 - APIs
|
||||
* @example
|
||||
* [3,2,1,0]
|
||||
* [1,2,1,2,1]
|
||||
*/
|
||||
LotteryOrder: [2, 0, 1, 3],
|
||||
|
||||
/**
|
||||
* API发送数据类型 {LotteryInfo[]}
|
||||
* 上传抽奖信息的链接字符串
|
||||
@@ -83,12 +97,18 @@ module.exports = Object.freeze({
|
||||
*/
|
||||
chatmodel: '01',
|
||||
|
||||
/**
|
||||
* 不参与预约抽奖
|
||||
*/
|
||||
disable_reserve_lottery: false,
|
||||
|
||||
/**
|
||||
* 检查是否重复转发
|
||||
* - 不检查 -1
|
||||
* - 通过是否点赞判断 0
|
||||
* - 通过是否点赞判断(自动点赞) 0
|
||||
* - 检索本地dyids文件 1
|
||||
* - 通过是否点赞判断+检索本地dyids文件 2
|
||||
* - 通过是否点赞判断(不自动点赞)+检索本地dyids文件 2
|
||||
* - 通过是否点赞判断(自动点赞)+检索本地dyids文件 3
|
||||
*/
|
||||
check_if_duplicated: 1,
|
||||
|
||||
@@ -163,7 +183,6 @@ module.exports = Object.freeze({
|
||||
lottery_loop_wait: 0,
|
||||
check_loop_wait: 0,
|
||||
clear_loop_wait: 0,
|
||||
update_loop_wait: 0,
|
||||
|
||||
/**
|
||||
* - 转发间隔时间
|
||||
@@ -214,6 +233,12 @@ module.exports = Object.freeze({
|
||||
*/
|
||||
random_dynamic_wait: 2000,
|
||||
|
||||
/**
|
||||
* - 预约抽奖间隔
|
||||
* - 单位毫秒
|
||||
*/
|
||||
reserve_lottery_wait: 6000,
|
||||
|
||||
/**
|
||||
* - up主粉丝数限制
|
||||
*/
|
||||
@@ -336,6 +361,11 @@ module.exports = Object.freeze({
|
||||
"~你预约的直播已开始"
|
||||
],
|
||||
|
||||
/**
|
||||
* 是否发送运行状态通知
|
||||
*/
|
||||
notice_running_state: false,
|
||||
|
||||
/**
|
||||
* - 获取私信页数
|
||||
*/
|
||||
|
||||
+3
-13
@@ -1,14 +1,15 @@
|
||||
{
|
||||
"name": "lottery-auto-script",
|
||||
"version": "2.5.0",
|
||||
"version": "2.6.3",
|
||||
"description": "自动参与B站动态抽奖",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"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",
|
||||
"build_all": "bash script/build/pkg.sh",
|
||||
"pkg": "bash script/build/pkg.sh",
|
||||
"changelog": "bash script/build/changelog.sh"
|
||||
},
|
||||
"files": [
|
||||
@@ -21,17 +22,6 @@
|
||||
"README.md"
|
||||
],
|
||||
"bin": "main.js",
|
||||
"pkg": {
|
||||
"targets": [
|
||||
"node12-win-x64",
|
||||
"node16-win-x64",
|
||||
"node16-linux-x64",
|
||||
"node16-macos-x64",
|
||||
"node16-linuxstatic-arm64",
|
||||
"node16-linuxstatic-armv7"
|
||||
],
|
||||
"outputPath": "dist"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/shanmiteko/AutoScript.git"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# version: <major.minor.patch>
|
||||
level=minor
|
||||
level=patch
|
||||
|
||||
npm version $level \
|
||||
--no-commit-hooks \
|
||||
@@ -33,7 +33,7 @@ echo "New Version: $NEW_VERSION"
|
||||
|
||||
GIT_LOG="$(git log --pretty=format:"* %h %s" | sed -e '/CHANGELOG/,$d' | sed ':a;N;s/\n/\\n/g;ta')"
|
||||
|
||||
sed -i "/# CHANGELOG/a\## 主要变化($NEW_VERSION)\n$GIT_LOG\n\n_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_\n" CHANGELOG.md
|
||||
sed -i "/# CHANGELOG/a\## 主要变化($NEW_VERSION)\n$GIT_LOG\n\n_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_\n" CHANGELOG.md
|
||||
|
||||
git add .
|
||||
git commit -m "docs: 更新CHANGELOG"
|
||||
|
||||
+25
-12
@@ -1,12 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
ROOT=$PWD
|
||||
README="README.md"
|
||||
TEMPLATE_CONFIG_FILE="my_config.example.js"
|
||||
TEMPLATE_ENV_FILE="env.example.js"
|
||||
CONFIG_FILE="my_config.js"
|
||||
ENV_FILE="env.js"
|
||||
TARGET_DIR="./dist"
|
||||
TARGET_DIR="dist"
|
||||
BIN_NAME="lottery"
|
||||
|
||||
create_win_bat() {
|
||||
@@ -17,28 +19,39 @@ if [ -d "$TARGET_DIR" ]; then
|
||||
rm -rf "$TARGET_DIR"
|
||||
fi
|
||||
|
||||
npx pkg .
|
||||
if [[ -z "$1" ]]; then
|
||||
$1=node18-linux-x64
|
||||
fi
|
||||
|
||||
mkdir -p $TARGET_DIR
|
||||
|
||||
if [[ "$1" == *"arm"* ]]; then
|
||||
podman build -f Dockerfile.pkg-arm64 -t pkg-arm64
|
||||
podman run -it --rm -v ${PWD}/dist:/root/lottery/dist pkg-arm64
|
||||
elif [[ "$1" == *"x64"* ]]; then
|
||||
OUTFILE="$TARGET_DIR/lottery-auto-script-$1"
|
||||
npx pkg -t "$1" -o $OUTFILE .
|
||||
fi
|
||||
|
||||
# Searching in the current directory
|
||||
for file in "$TARGET_DIR/"*; do
|
||||
TMPDIR="${file%.exe}"
|
||||
TMPDIR_NAME="${TMPDIR##*/}"
|
||||
REMANE_FILE="$TARGET_DIR/$BIN_NAME"
|
||||
mv $file $REMANE_FILE
|
||||
mkdir -p "$TMPDIR/"
|
||||
mv $REMANE_FILE "$TMPDIR/"
|
||||
cp $README "$TMPDIR/"
|
||||
cp $TEMPLATE_CONFIG_FILE "$TMPDIR/$CONFIG_FILE"
|
||||
cp $TEMPLATE_ENV_FILE "$TMPDIR/$ENV_FILE"
|
||||
mkdir -p "$TMPDIR.d/"
|
||||
mv $REMANE_FILE "$TMPDIR.d/"
|
||||
cp $README "$TMPDIR.d/"
|
||||
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")
|
||||
for item in "${BATS[@]}"; do
|
||||
create_win_bat "${item}" >"$TMPDIR/$item.bat"
|
||||
create_win_bat "${item}" >"$TMPDIR.d/$item.bat"
|
||||
done
|
||||
mv "$TMPDIR/$BIN_NAME" "$TMPDIR/$BIN_NAME.exe"
|
||||
mv "$TMPDIR.d/$BIN_NAME" "$TMPDIR.d/$BIN_NAME.exe"
|
||||
else
|
||||
ZIP_NAME=latest_version0
|
||||
cat >"$TMPDIR/update.sh" <<-EOF
|
||||
cat >"$TMPDIR.d/update.sh" <<-EOF
|
||||
#!/bin/bash
|
||||
./lottery update
|
||||
ZIP_NAME=$ZIP_NAME
|
||||
@@ -49,7 +62,7 @@ for file in "$TARGET_DIR/"*; do
|
||||
fi
|
||||
EOF
|
||||
fi
|
||||
cd $TMPDIR
|
||||
cd $TMPDIR.d
|
||||
zip -r "$TMPDIR_NAME.zip" .
|
||||
mv "$TMPDIR_NAME.zip" ../
|
||||
cd $ROOT
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
#!/bin/env bash
|
||||
set -e
|
||||
|
||||
NAME=LotteryAutoScript
|
||||
GIT_REPO=https://github.com/shanmiteko/${NAME}.git
|
||||
# GIT_REPO=https://ghproxy.com/https://github.com/shanmiteko/${NAME}.git
|
||||
|
||||
if [ -d "$NAME" ]; then
|
||||
cd $NAME
|
||||
git pull
|
||||
cd ..
|
||||
else
|
||||
git clone $GIT_REPO $NAME --depth=1
|
||||
fi
|
||||
|
||||
if [ -f "$NAME/my_config.js" ]; then
|
||||
else
|
||||
cp $NAME/my_config.example.js $NAME/my_config.js
|
||||
fi
|
||||
|
||||
if [ -f "$NAME/env.js" ]; then
|
||||
else
|
||||
cp $NAME/env.example.js $NAME/env.js
|
||||
fi
|
||||
|
||||
function create() {
|
||||
cat >"${NAME}_$1.sh" <<EOF
|
||||
#!/bin/env bash
|
||||
cd $NAME
|
||||
npm run $1
|
||||
EOF
|
||||
}
|
||||
|
||||
create start
|
||||
create check
|
||||
create clear
|
||||
|
||||
cd $NAME
|
||||
npm i
|
||||
@@ -0,0 +1,40 @@
|
||||
const assert = require('assert');
|
||||
const bili_client = require("../lib/net/bili");
|
||||
const util = require('./util');
|
||||
|
||||
(async () => {
|
||||
assert(await bili_client.getMyinfo());
|
||||
|
||||
await util.par_run([
|
||||
async () => {
|
||||
assert.equal((await bili_client.getTopRcmd()).length, 10)
|
||||
},
|
||||
async () => {
|
||||
assert.equal(await bili_client.sendChat(
|
||||
(await bili_client.getOneDynamicByDyid("692193323569381399")).desc.rid,
|
||||
"test",
|
||||
11),
|
||||
7
|
||||
)
|
||||
},
|
||||
async () => {
|
||||
assert.equal(await bili_client.sendChat(
|
||||
(await bili_client.getOneDynamicByDyid("11229466874154064")).desc.rid,
|
||||
"test",
|
||||
1),
|
||||
3
|
||||
)
|
||||
},
|
||||
async () => {
|
||||
assert.notEqual((await bili_client.searchArticlesByKeyword("专栏")).length, 0)
|
||||
},
|
||||
async () => {
|
||||
assert.notEqual(await bili_client.sendChat("703886913053917267", "t", 17), 1)
|
||||
},
|
||||
async () => {
|
||||
// assert(!await bili_client.createDynamic("123"))
|
||||
}
|
||||
])
|
||||
|
||||
console.log("api.test ... ok!");
|
||||
})()
|
||||
@@ -0,0 +1,12 @@
|
||||
const env = require("../lib/data/env");
|
||||
const global_var = require("../lib/data/global_var");
|
||||
const { log } = require('../lib/utils');
|
||||
const fs = require('fs');
|
||||
|
||||
log._level = 1
|
||||
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}`))
|
||||
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* @param {Array<()=>any>} fns
|
||||
*/
|
||||
function par_run(fns) {
|
||||
return Promise.all((fns.map(fn => fn())))
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
par_run
|
||||
}
|
||||
Reference in New Issue
Block a user