mirror of
https://github.com/shanmiteko/LotteryAutoScript.git
synced 2026-07-22 21:13:47 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3c269b2f96 | ||
|
|
3851f51621 | ||
|
|
d676a10e56 | ||
|
|
88d3e97595 | ||
|
|
88ad8ecfcc | ||
|
|
478d10d27e | ||
|
|
6fbcf6e0b7 | ||
|
|
8bf47698ad | ||
|
|
c0bc4878e3 | ||
|
|
e9b7965a76 | ||
|
|
0a54cd20db | ||
|
|
a2591f260a | ||
|
|
e6dc9d7abb | ||
|
|
179f4d0d41 | ||
|
|
5a625dbd12 | ||
|
|
65fd4b3112 | ||
|
|
14067ca923 | ||
|
|
33e55721f6 | ||
|
|
aa1aad7ddd | ||
|
|
0c0d112aaf | ||
|
|
b4ec45a48d | ||
|
|
1ce8e966e8 | ||
|
|
f252365809 | ||
|
|
30fee87485 | ||
|
|
214abd449f | ||
|
|
79b348d37e | ||
|
|
965734c2f2 | ||
|
|
3cc42c0fc5 | ||
|
|
b24c32a877 | ||
|
|
ef822df5bf | ||
|
|
9842107f52 | ||
|
|
89dea18ae3 | ||
|
|
a426eb48f5 | ||
|
|
c06f69457a | ||
|
|
155332751f | ||
|
|
a28ec20b12 |
@@ -0,0 +1,40 @@
|
||||
name: "Build and push Docker images"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "lib/**"
|
||||
- "main.js"
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "lib/**"
|
||||
- "main.js"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
path-context:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
platforms: linux/amd64
|
||||
push: true
|
||||
tags: shanmite/lottery_auto_docker:latest
|
||||
@@ -0,0 +1,25 @@
|
||||
name: "Publishing to NPM"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "lib/**"
|
||||
- "main.js"
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "lib/**"
|
||||
- "main.js"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: JS-DevTools/npm-publish@v1
|
||||
with:
|
||||
token: ${{ secrets.NPM_TOKEN }}
|
||||
@@ -0,0 +1,82 @@
|
||||
name: "Package Node.js project into an executable"
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "lib/**"
|
||||
- "main.js"
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "lib/**"
|
||||
- "main.js"
|
||||
workflow_dispatch:
|
||||
branches:
|
||||
- main
|
||||
jobs:
|
||||
pkg_x64:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: "Checkout codes"
|
||||
uses: actions/checkout@v2
|
||||
- name: "Use Node.js"
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: "16"
|
||||
- name: "Pkg this"
|
||||
run: |
|
||||
npm install
|
||||
npm run pkg_x64
|
||||
- name: "Upload to artifact(win)"
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: nlts-win-x64
|
||||
path: dist/nlts-win-x64.zip
|
||||
- name: "Upload to artifact(linux)"
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: nlts-linux-x64
|
||||
path: dist/nlts-linux-x64.zip
|
||||
- name: "Upload to artifact(macos)"
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: nlts-macos-x64
|
||||
path: dist/nlts-macos-x64.zip
|
||||
pkg_arm64:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: "Checkout codes"
|
||||
uses: actions/checkout@v2
|
||||
- name: "Use Node.js"
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: "16"
|
||||
- name: "Pkg this"
|
||||
run: |
|
||||
npm install
|
||||
npm run pkg_arm64
|
||||
- name: "Upload to artifact"
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: nlts-linux-arm64
|
||||
path: dist/
|
||||
pkg_armv7:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: "Checkout codes"
|
||||
uses: actions/checkout@v2
|
||||
- name: "Use Node.js"
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: "16"
|
||||
- name: "Pkg this"
|
||||
run: |
|
||||
npm install
|
||||
npm run pkg_armv7
|
||||
- name: "Upload to artifact"
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: nlts-linux-armv7
|
||||
path: dist/
|
||||
@@ -1,27 +0,0 @@
|
||||
name: 'Automatic sync'
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 0 * * *'
|
||||
workflow_dispatch:
|
||||
watch:
|
||||
types: started
|
||||
repository_dispatch:
|
||||
types: repo-sync
|
||||
jobs:
|
||||
repo-sync:
|
||||
env:
|
||||
PAT: ${{ github.event.client_payload.PAT || secrets.PAT }}
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event.repository.owner.id == github.event.sender.id
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: 开始自动同步
|
||||
uses: repo-sync/github-sync@v2
|
||||
if: env.PAT
|
||||
with:
|
||||
source_repo: "https://github.com/shanmite/LotteryAutoScript.git"
|
||||
source_branch: "main"
|
||||
destination_branch: "main"
|
||||
github_token: ${{ github.event.client_payload.PAT || secrets.PAT }}
|
||||
@@ -1,5 +1,4 @@
|
||||
# AutoScript
|
||||
|
||||
- [AutoScript](#autoscript)
|
||||
- [操作步骤](#操作步骤)
|
||||
- [获取COOKIE](#获取cookie)
|
||||
@@ -17,6 +16,10 @@
|
||||
|
||||
[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/npmp.yml)
|
||||
|
||||
已实现功能:
|
||||
- 监控用户转发
|
||||
- 监控话题页面
|
||||
@@ -24,6 +27,7 @@
|
||||
- 自动点赞、评论、乱序转发、@好友、带话题、可选随机动态
|
||||
- 检测是否中奖
|
||||
- 清理动态关注
|
||||
- 检查更新
|
||||
- 更多功能设置请参考配置文件
|
||||
|
||||
**声明**: 此脚本仅用于学习和测试,作者本人并不对其负责,请于运行测试完成后自行删除,请勿滥用!
|
||||
@@ -32,6 +36,8 @@
|
||||
|
||||
## 操作步骤
|
||||
|
||||
**使用前务必阅读此教程和配置文件内注释**
|
||||
|
||||
右上角<kbd>★ Star</kbd>
|
||||
|
||||
↓↓
|
||||
@@ -48,7 +54,7 @@ Chrome浏览器:
|
||||
|
||||
(此步骤是为了方便后续采用JS获取Cookies,获取完毕后应再次勾选)
|
||||
|
||||

|
||||

|
||||
|
||||
3. 在Console中复制以下代码回车
|
||||
|
||||
@@ -81,8 +87,6 @@ Chrome浏览器:
|
||||
~/nlts-linux-x64
|
||||
=> tree
|
||||
.
|
||||
├── dyids (自动生成的dyid存储)
|
||||
│ └── dyid.txt
|
||||
├── env.js (便捷设置环境变量和多账号参数)
|
||||
├── lottery (可执行文件)
|
||||
├── my_config.js (自定义设置文件) (!使用前必读)
|
||||
@@ -92,10 +96,13 @@ Chrome浏览器:
|
||||
3. 在`env.js`中填入`COOKIE`和推送参数
|
||||
4. 在`my_config.js`中自定义设置
|
||||
5. 在当前目录下**打开终端**运行可执行文件`lottery`(勿直接点击`lottery`)
|
||||
6. 键入`lottery start`启动抽奖|`lottery check`检测中奖|`lottery clear`清理动态
|
||||
> 或者新建文本文档写入`lottery start`然后更改扩展名为.bat点击运行
|
||||
- `lottery start` 启动抽奖
|
||||
- `lottery check` 检测中奖
|
||||
- `lottery clear` 清理动态
|
||||
|
||||
或者 新建文本文档写入`lottery start`然后更改扩展名为.bat点击运行(已自带start.bat可直接点击)
|
||||
7. 运行截图
|
||||

|
||||

|
||||
|
||||
#### 以源码方式运行
|
||||
|
||||
@@ -109,7 +116,7 @@ step1: 下载代码到本地
|
||||
|
||||
[点此下载](https://github.com/shanmiteko/LotteryAutoScript/archive/refs/heads/main.zip)或如图示下载↓
|
||||
|
||||

|
||||

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

|
||||

|
||||
|
||||
step3:修改env.example.js文件及创建运行文件(打开扩展名显示)
|
||||
|
||||
@@ -206,7 +213,12 @@ rm -rf lottery/
|
||||
----------------------------------------
|
||||
|
||||
## 防重复转发
|
||||
脚本将转发过的动态和被过滤的动态都写入`dyids/dyid*.txt`文件中
|
||||
~~存储在专栏草稿~~
|
||||
|
||||
~~脚本将转发过的动态和被过滤的动态都写入`dyids/dyid*.txt`文件中~~
|
||||
|
||||
是否点赞
|
||||
|
||||
|
||||
----------------------------------------
|
||||
|
||||
@@ -229,14 +241,14 @@ rm -rf lottery/
|
||||
| :---------------: | :--------------------------------------------------------------------------------: | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `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`,再不懂看 [这个图](doc/pic/bark.jpg)(注:支持自建填完整链接即可) |
|
||||
| `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`等字符 , 注:钉钉机器人安全设置只需勾选`加签`即可,其他选项不要勾选,再不懂看 [这个图](doc/pic/DD_bot.png) |
|
||||
| `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/) |
|
||||
@@ -254,4 +266,4 @@ rm -rf lottery/
|
||||
## 设置说明
|
||||
详见[env.example.js](./env.example.js)文件内部注释
|
||||
|
||||
详见[my_config.example.js](./my_config.example.js)文件内部注释
|
||||
详见[my_config.example.js](./my_config.example.js)文件内部注释
|
||||
|
||||
+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**的教程结束
|
||||
|
||||
+14
-15
@@ -10,15 +10,14 @@
|
||||
2.下载脚本到本地
|
||||
|
||||
```sh
|
||||
git clone https://github.com/shanmite/LotteryAutoScript.git
|
||||
git clone https://github.com/shanmiteko/LotteryAutoScript.git
|
||||
```
|
||||
|
||||

|
||||
|
||||
**注意**: github访问下载速度可能很慢, 如果卡住了可以通过Github镜像网站下载
|
||||
|
||||
```sh
|
||||
git clone https://github.com.cnpmjs.org/shanmite/LotteryAutoScript.git
|
||||
git clone https://github.com.cnpmjs.org/shanmiteko/LotteryAutoScript.git
|
||||
```
|
||||
|
||||
|
||||
@@ -26,6 +25,7 @@ git clone https://github.com.cnpmjs.org/shanmite/LotteryAutoScript.git
|
||||
|
||||
```sh
|
||||
mv env.example.js env.js
|
||||
mv my_config.example.js my_config.js
|
||||
```
|
||||
|
||||
|
||||
@@ -38,11 +38,10 @@ vim env.js
|
||||
# 此处可查阅Vim的使用手册
|
||||
```
|
||||
|
||||

|
||||
详见[env.example.js](https://github.com/shanmiteko/LotteryAutoScript/blob/main/env.example.js)文件内部注释
|
||||
|
||||
说明: `"CLEAR"`项设置为`true`, 才可以开启自动清理动态功能
|
||||
|
||||
`"PAT"`和`"GITHUB_REPOSITORY"`不填也行
|
||||
[my_config.example.js](https://github.com/shanmiteko/LotteryAutoScript/blob/main/my_config.example.js)同理
|
||||
|
||||
|
||||
~~5.设置定时工作~~
|
||||
@@ -54,14 +53,14 @@ vim env.js
|
||||
```sh
|
||||
crontab -e
|
||||
```
|
||||
cd 后的路径修改为你的脚本路径
|
||||
```sh
|
||||
SHELL=/bin/bash
|
||||
PATH=/sbin:/bin:/usr/sbin/:/usr/bin
|
||||
|
||||

|
||||
|
||||
`SHELL` 和 `PATH`照着填
|
||||
|
||||
`MAILTO`不填也行
|
||||
|
||||
注意`HOME`后面跟脚本所在的目录, 这样才能到那个目录下去执行命令
|
||||
1 */3 * * * cd /root/LotteryAutoScript && npm i && npm run check
|
||||
1 */3 * * * cd /root/LotteryAutoScript && npm i && npm run start
|
||||
```
|
||||
|
||||
|
||||
6.手动运行一波
|
||||
@@ -74,7 +73,7 @@ crontab -e
|
||||
|
||||
看看有没有效果
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
7.如果本地的脚本需要更新
|
||||
@@ -83,4 +82,4 @@ crontab -e
|
||||
|
||||
```sh
|
||||
git pull
|
||||
```
|
||||
```
|
||||
|
||||
+3
-3
@@ -16,13 +16,13 @@
|
||||
|
||||
7.在`操作`页面中点击`新建`,选择操作为`启动程序`,在设置里点击浏览找到`start.bat`文件并选择,在`起始于(可选)(T):`中的空白框里输入`start.bat`文件的目录地址,也就是`程序或脚本(P):`里`start.bat`的前面那一串目录地址,最后是以`\`结尾的 ,填好东西后按下面`确认`
|
||||
|
||||

|
||||

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

|
||||

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

|
||||

|
||||
|
||||
具体看任务是否正常执行,你可以看看自己的账号动态的最新转发,运行成功每几分钟自动转发抽奖动态
|
||||
|
||||
+63
-82
@@ -1,89 +1,70 @@
|
||||
/**
|
||||
* ## 账号相关
|
||||
* - `COOKIE` 是必填项
|
||||
* - `NUMBER` 表示是第几个账号
|
||||
* - `CLEAR` 是否启用清理功能
|
||||
* - `ENABLE_MULTIPLE_ACCOUNT` 是否启用多账号
|
||||
* - `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**
|
||||
*/
|
||||
const account_parm = {
|
||||
COOKIE: "",
|
||||
NUMBER: 1,
|
||||
CLEAR: true,
|
||||
ENABLE_MULTIPLE_ACCOUNT: false,
|
||||
MULTIPLE_ACCOUNT_PARM: "",
|
||||
LOTTERY_LOG_LEVEL: 3,
|
||||
NOT_GO_LOTTERY: ""
|
||||
}
|
||||
|
||||
/**
|
||||
* 为防止环境变量过长, 请将多账号填在此处
|
||||
* @example
|
||||
* ```js
|
||||
* {
|
||||
* COOKIE: "",
|
||||
* NUMBER: 2,
|
||||
* CLEAR: true,
|
||||
* WAIT: 60 * 1000,
|
||||
* },
|
||||
* ```
|
||||
* 请按照以上格式将参数依次填写在下方
|
||||
*/
|
||||
const multiple_account_parm = [
|
||||
{
|
||||
module.exports = Object.freeze({
|
||||
/**
|
||||
* ## 账号相关
|
||||
* - `COOKIE` 是必填项
|
||||
* - `NUMBER` 表示是第几个账号
|
||||
* - `CLEAR` 是否启用清理功能
|
||||
* - `ENABLE_MULTIPLE_ACCOUNT` 是否启用多账号
|
||||
* - `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: {
|
||||
COOKIE: "",
|
||||
NUMBER: 1,
|
||||
CLEAR: true,
|
||||
WAIT: 60 * 1000,
|
||||
|
||||
ENABLE_MULTIPLE_ACCOUNT: false,
|
||||
|
||||
MULTIPLE_ACCOUNT_PARM: "",
|
||||
LOTTERY_LOG_LEVEL: 3,
|
||||
NOT_GO_LOTTERY: ""
|
||||
},
|
||||
]
|
||||
|
||||
/**
|
||||
* 推送相关参数
|
||||
*/
|
||||
const push_parm = {
|
||||
SCKEY: "",
|
||||
SENDKEY: "",
|
||||
QQ_SKEY: "",
|
||||
QQ_MODE: "",
|
||||
BARK_PUSH: "",
|
||||
BARK_SOUND: "",
|
||||
TG_BOT_TOKEN: "",
|
||||
TG_USER_ID: "",
|
||||
TG_PROXY_HOST: "",
|
||||
TG_PROXY_PORT: "",
|
||||
DD_BOT_TOKEN: "",
|
||||
DD_BOT_SECRET: "",
|
||||
QYWX_KEY: "",
|
||||
IGOT_PUSH_KEY: "",
|
||||
PUSH_PLUS_TOKEN: "",
|
||||
PUSH_PLUS_USER: "",
|
||||
SMTP_HOST: "",
|
||||
SMTP_PORT: "",
|
||||
SMTP_USER: "",
|
||||
SMTP_PASS: "",
|
||||
SMTP_TO_USER: ""
|
||||
}
|
||||
/**
|
||||
* 为防止环境变量过长, 请将多账号填在此处
|
||||
* 以大括号内容为模板依次复制(包含大括号),逗号分割
|
||||
*/
|
||||
multiple_account_parm: [
|
||||
{
|
||||
COOKIE: "",
|
||||
NUMBER: 1,
|
||||
CLEAR: true,
|
||||
WAIT: 60 * 1000
|
||||
}
|
||||
],
|
||||
|
||||
/**
|
||||
* 初始化环境变量
|
||||
*/
|
||||
function initEnv() {
|
||||
process.env = {
|
||||
...process.env,
|
||||
...account_parm,
|
||||
...push_parm
|
||||
/**
|
||||
* 推送相关参数
|
||||
*/
|
||||
push_parm: {
|
||||
SCKEY: "",
|
||||
SENDKEY: "",
|
||||
QQ_SKEY: "",
|
||||
QQ_MODE: "",
|
||||
BARK_PUSH: "",
|
||||
BARK_SOUND: "",
|
||||
TG_BOT_TOKEN: "",
|
||||
TG_USER_ID: "",
|
||||
TG_PROXY_HOST: "",
|
||||
TG_PROXY_PORT: "",
|
||||
DD_BOT_TOKEN: "",
|
||||
DD_BOT_SECRET: "",
|
||||
QYWX_KEY: "",
|
||||
IGOT_PUSH_KEY: "",
|
||||
PUSH_PLUS_TOKEN: "",
|
||||
PUSH_PLUS_USER: "",
|
||||
SMTP_HOST: "",
|
||||
SMTP_PORT: "",
|
||||
SMTP_USER: "",
|
||||
SMTP_PASS: "",
|
||||
SMTP_TO_USER: ""
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module.exports = { initEnv, multiple_account_parm };
|
||||
})
|
||||
+1
-1
@@ -69,7 +69,7 @@ async function isMe() {
|
||||
log.info('可能中奖了', desp);
|
||||
await sendNotify('可能中奖了', desp);
|
||||
} else {
|
||||
log.info('中奖检测', "未中奖");
|
||||
log.info('中奖检测', "暂未中奖");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
+69
-42
@@ -5,7 +5,6 @@ const event_bus = require('../helper/event_bus');
|
||||
const { Searcher } = require('./searcher');
|
||||
const global_var = require("../data/global_var");
|
||||
const config = require("../data/config");
|
||||
const d_storage = require('../helper/d_storage');
|
||||
const { log, hasEnv } = utils;
|
||||
|
||||
/**
|
||||
@@ -55,10 +54,11 @@ class Monitor extends Searcher {
|
||||
event_bus.emit('Turn_on_the_Monitor')
|
||||
break
|
||||
case 22:
|
||||
log.warn('账号异常', `UID(${global_var.get('myUID')})异常号只会对部分UP出现关注异常`)
|
||||
if (!config.is_exception) {
|
||||
config.is_exception = true;
|
||||
await sendNotify('[动态抽奖]账号异常通知', `UID: ${global_var.get('myUID')}\n\n已自动跳过异常关注(异常号只会对部分UP出现关注异常)\n\n可在设置中令is_exception为true关闭此推送`)
|
||||
await sendNotify('[动态抽奖]账号异常通知', `UID: ${global_var.get('myUID')}\n\n异常号只会对部分UP出现关注异常\n\n可在设置中令is_exception为true关闭此推送`)
|
||||
}
|
||||
config.is_exception = true;
|
||||
event_bus.emit('Turn_on_the_Monitor')
|
||||
break
|
||||
case 31:
|
||||
@@ -81,13 +81,16 @@ class Monitor extends Searcher {
|
||||
*/
|
||||
async startLottery() {
|
||||
const allLottery = await this.filterLotteryInfo()
|
||||
, len = allLottery.length;
|
||||
, len = allLottery.length
|
||||
, { dy_contents, create_dy, create_dy_mode, wait } = config;
|
||||
|
||||
log.info('筛选动态', `筛选完毕(${len})`);
|
||||
|
||||
if (len) {
|
||||
for (const Lottery of utils.shuffle(allLottery)) {
|
||||
let is_exception = false;
|
||||
for (const [index, Lottery] of utils.shuffle(allLottery).entries()) {
|
||||
let status = 0;
|
||||
|
||||
if (Lottery.isOfficialLottery) {
|
||||
let { ts } = await bili.getLotteryNotice(Lottery.dyid);
|
||||
const ts_10 = Date.now() / 1000;
|
||||
@@ -96,12 +99,10 @@ class Monitor extends Searcher {
|
||||
}
|
||||
if (ts < ts_10) {
|
||||
log.info('过滤', '已过开奖时间')
|
||||
d_storage.updateDyid(Lottery.dyid)
|
||||
continue
|
||||
}
|
||||
if (ts > ts_10 + config.maxday * 86400) {
|
||||
log.info('过滤', '超过指定开奖时间')
|
||||
d_storage.updateDyid(Lottery.dyid)
|
||||
continue
|
||||
}
|
||||
} else if (Lottery.uid[0]) {
|
||||
@@ -111,19 +112,39 @@ class Monitor extends Searcher {
|
||||
}
|
||||
if (followerNum < config.minfollower) {
|
||||
log.info('过滤', `粉丝数(${followerNum})小于指定数量`)
|
||||
d_storage.updateDyid(Lottery.dyid)
|
||||
continue
|
||||
}
|
||||
}
|
||||
status = await this.go(Lottery)
|
||||
if (status % 2 !== 0) {
|
||||
return status
|
||||
|
||||
if (create_dy
|
||||
&& create_dy_mode instanceof Array
|
||||
&& index > 0
|
||||
&& index % create_dy_mode[0] === 0) {
|
||||
for (let i = 0; i < create_dy_mode[1]; i++) {
|
||||
await bili.createDynamic(utils.getRandomOne(dy_contents));
|
||||
await utils.delay(2000);
|
||||
}
|
||||
}
|
||||
d_storage.updateDyid(Lottery.dyid);
|
||||
await utils.delay(config.wait * (Math.random() + 0.5));
|
||||
|
||||
status = await this.go(Lottery)
|
||||
switch (status) {
|
||||
case 0:
|
||||
break;
|
||||
case 22:
|
||||
is_exception = true
|
||||
break;
|
||||
default:
|
||||
return status
|
||||
}
|
||||
|
||||
await utils.delay(wait * (Math.random() + 0.5));
|
||||
}
|
||||
log.info('抽奖', '开始转发下一组动态');
|
||||
return 0
|
||||
if (is_exception) {
|
||||
return 22
|
||||
} else {
|
||||
return 0
|
||||
}
|
||||
} else {
|
||||
log.info('抽奖', '无未转发抽奖');
|
||||
return 0
|
||||
@@ -158,6 +179,7 @@ class Monitor extends Searcher {
|
||||
/** 所有抽奖信息 */
|
||||
let alllotteryinfo = [];
|
||||
const { key_words, model, chatmodel, is_imitator, only_followed, at_users, blockword, blacklist } = config;
|
||||
|
||||
/**Map<String, Boolean> */
|
||||
let dyids_map = new Map();
|
||||
|
||||
@@ -170,41 +192,32 @@ class Monitor extends Searcher {
|
||||
return true
|
||||
});
|
||||
|
||||
/**并发查询dyid */
|
||||
await Promise.all(
|
||||
[...dyids_map.keys()]
|
||||
.map(it => d_storage
|
||||
.searchDyid(it)
|
||||
.then(hasIt => dyids_map.set(it, hasIt))
|
||||
)
|
||||
)
|
||||
|
||||
/* 检查动态是否满足要求 */
|
||||
await utils.try_for_each(protoLotteryInfo, async function ({
|
||||
lottery_info_type, uids,
|
||||
uname, dyid,
|
||||
lottery_info_type, is_liked,
|
||||
uids, uname, dyid,
|
||||
ctrl, rid, des, type,
|
||||
hasOfficialLottery
|
||||
}) {
|
||||
/* 遇到转发过就退出 */
|
||||
if (dyids_map.get(dyid)) return false;
|
||||
if (is_liked) return false;
|
||||
|
||||
const
|
||||
/**判断是转发源动态还是现动态 */
|
||||
uid = lottery_info_type === 'uid' ? uids[1] : uids[0]
|
||||
, isFollowed = (new RegExp(uid)).test(attentionList)
|
||||
, description = typeof des === 'string' ? des : ''
|
||||
, needAt = /(?:@|艾特)[^@|(艾特)]*?好友/.test(description)
|
||||
, needTopic = [...(new Set(description.match(/(?<=[带加上](?:话题|tag).*)#.+?#/ig) || []))].join(' ')
|
||||
, isRelayDynamic = type === 1
|
||||
, isTwoLevelDynamic = /\/\/@/.test(description)
|
||||
, has_key_words = key_words.every(it => new RegExp(it).test(description))
|
||||
, isBlock = new RegExp(blockword.join('|')).test(description)
|
||||
, isLottery =
|
||||
uid = lottery_info_type === 'uid' ? uids[1] : uids[0],
|
||||
isFollowed = (new RegExp(uid)).test(attentionList),
|
||||
description = typeof des === 'string' ? des : '',
|
||||
needAt = /(?:@|艾特)[^@|(艾特)]*?好友/.test(description),
|
||||
needTopic = [...new Set(description.match(/(?<=[带加上](?:话题|tag).*)#.+?#|(?<=[带加上])#.+?#(?=话题|tag)/ig) || [])].join(' '),
|
||||
isRelayDynamic = type === 1,
|
||||
isTwoLevelDynamic = /\/\/@/.test(description),
|
||||
has_key_words = key_words.every(it => new RegExp(it).test(description)),
|
||||
isBlock = new RegExp(blockword.join('|')).test(description),
|
||||
isLottery =
|
||||
(is_imitator && lottery_info_type === 'uid' && model !== '00')
|
||||
|| (hasOfficialLottery && model[0] === '1')
|
||||
|| (!hasOfficialLottery && model[1] === '1' && !isTwoLevelDynamic && has_key_words)
|
||||
, isSendChat =
|
||||
|| (!hasOfficialLottery && model[1] === '1' && !isTwoLevelDynamic && has_key_words),
|
||||
isSendChat =
|
||||
(is_imitator && lottery_info_type === 'uid' && chatmodel !== '00')
|
||||
|| (hasOfficialLottery && chatmodel[0] === '1')
|
||||
|| (!hasOfficialLottery && chatmodel[1] === '1');
|
||||
@@ -327,11 +340,13 @@ class Monitor extends Searcher {
|
||||
for (let times = 0; times < max_retry_times; times++) {
|
||||
status = await bili.sendChat(rid, utils.getRandomOne(config.chat), chat_type)
|
||||
if (status === -1) {
|
||||
log.warn('抽奖信息', `uid: ${uid},dyid: ${dyid}`)
|
||||
return 0
|
||||
}
|
||||
if (!status) {
|
||||
break
|
||||
}
|
||||
log.error('抽奖信息', `uid: ${uid},dyid: ${dyid}`)
|
||||
log.info('自动评论', `将在 ${times + 1} 分钟后再次发送评论(${times + 1}/${max_retry_times})`)
|
||||
await utils.delay(60 * 1000 * (times + 1))
|
||||
}
|
||||
@@ -342,15 +357,27 @@ class Monitor extends Searcher {
|
||||
const [u1, u2] = uid
|
||||
if (u1) {
|
||||
let status = await bili.autoAttention(u1)
|
||||
if (status) return 20 + status;
|
||||
if (status) {
|
||||
log.error('抽奖信息', `uid: ${uid},dyid: ${dyid}`)
|
||||
return 20 + status
|
||||
};
|
||||
status = await bili.movePartition(u1, this.tagid)
|
||||
if (status) return 20 + status;
|
||||
if (status) {
|
||||
log.error('抽奖信息', `uid: ${uid},dyid: ${dyid}`)
|
||||
return 20 + status
|
||||
};
|
||||
if (u2) {
|
||||
utils.delay(5000)
|
||||
status = await bili.autoAttention(u2)
|
||||
if (status) return 20 + status;
|
||||
if (status) {
|
||||
log.error('抽奖信息', `uid: ${uid},dyid: ${dyid}`)
|
||||
return 20 + status
|
||||
};
|
||||
status = await bili.movePartition(u2, this.tagid)
|
||||
if (status) return 20 + status;
|
||||
if (status) {
|
||||
log.error('抽奖信息', `uid: ${uid},dyid: ${dyid}`)
|
||||
return 20 + status
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+85
-47
@@ -1,7 +1,6 @@
|
||||
const utils = require('../utils');
|
||||
const bili = require('../net/bili');
|
||||
const config = require("../data/config");
|
||||
const d_storage = require('../helper/d_storage');
|
||||
|
||||
const { log } = utils
|
||||
|
||||
@@ -11,6 +10,7 @@ const { log } = utils
|
||||
* @typedef {object} UsefulDynamicInfo
|
||||
* @property {number} uid
|
||||
* @property {string} uname
|
||||
* @property {boolean} is_liked
|
||||
* @property {number} createtime 10
|
||||
* @property {string} rid_str
|
||||
* @property {string} dynamic_id
|
||||
@@ -35,13 +35,16 @@ function parseDynamicCard(dynamic_detail_card) {
|
||||
/**临时储存单个动态中的信息 */
|
||||
let obj = {};
|
||||
const { desc, card, extension, extend_json } = dynamic_detail_card
|
||||
, { info } = desc.user_profile
|
||||
, { is_liked, user_profile } = desc
|
||||
, { info } = user_profile
|
||||
, cardToJson = strToJson(card)
|
||||
, { item } = cardToJson;
|
||||
/* 转发者的UID */
|
||||
obj.uid = info.uid;
|
||||
obj.uid = info.uid
|
||||
/* 转发者的name */
|
||||
obj.uname = info.uname;
|
||||
obj.uname = info.uname
|
||||
/* 动态是否点过赞 */
|
||||
obj.is_liked = is_liked > 0
|
||||
/* 动态的ts10 */
|
||||
obj.createtime = desc.timestamp
|
||||
/* 动态类型 */
|
||||
@@ -86,8 +89,8 @@ function parseDynamicCard(dynamic_detail_card) {
|
||||
*/
|
||||
function modifyDynamicRes(res) {
|
||||
const
|
||||
{ data = {}, code } = utils.strToJson(res),
|
||||
{ cards = [], has_more, offset } = data;
|
||||
{ data, code } = utils.strToJson(res),
|
||||
{ cards = [], has_more, offset } = data || {};
|
||||
|
||||
if (code !== 0) {
|
||||
log.error('处理动态数据', '获取动态数据出错,可能是访问太频繁 \n' + res);
|
||||
@@ -132,6 +135,7 @@ class Searcher {
|
||||
* 整理后的抽奖信息
|
||||
* @typedef {object} LotteryInfo
|
||||
* @property {string} lottery_info_type
|
||||
* @property {boolean} is_liked
|
||||
* @property {number[]} uids `[uid,ouid]`
|
||||
* @property {string} uname
|
||||
* @property {Array<{}>} ctrl
|
||||
@@ -213,21 +217,50 @@ class Searcher {
|
||||
log.info('获取动态', `开始获取用户${UID}的动态信息`);
|
||||
const { allModifyDynamicResArray } = await Searcher.checkAllDynamic(UID, config.uid_scan_page, config.search_wait);
|
||||
|
||||
if (!allModifyDynamicResArray.length) return null;
|
||||
let { length } = allModifyDynamicResArray
|
||||
|
||||
if (!length) return null;
|
||||
|
||||
const fomatdata = await allModifyDynamicResArray
|
||||
.filter(d => {
|
||||
if (d.type === 1) {
|
||||
return true
|
||||
} else {
|
||||
length--
|
||||
return false
|
||||
}
|
||||
})
|
||||
.reduce(async (pre, cur) => {
|
||||
const results = await pre
|
||||
, { origin_dynamic_id } = cur;
|
||||
|
||||
log.info('获取动态', `查看源动态(${origin_dynamic_id})的细节 (${length--})`)
|
||||
|
||||
const card = await bili.getOneDynamicByDyid(origin_dynamic_id)
|
||||
|
||||
if (card) {
|
||||
await utils.delay(2000)
|
||||
|
||||
const { is_liked } = parseDynamicCard(card)
|
||||
|
||||
return [...results, {
|
||||
lottery_info_type: 'uid',
|
||||
is_liked,
|
||||
uids: [cur.uid, cur.origin_uid],
|
||||
uname: cur.origin_uname,
|
||||
ctrl: [],
|
||||
dyid: cur.origin_dynamic_id,
|
||||
rid: cur.origin_rid_str,
|
||||
des: cur.origin_description,
|
||||
type: cur.orig_type,
|
||||
hasOfficialLottery: cur.origin_hasOfficialLottery
|
||||
}]
|
||||
}
|
||||
|
||||
return results
|
||||
|
||||
}, Promise.resolve([]))
|
||||
|
||||
const fomatdata = allModifyDynamicResArray.map(o => {
|
||||
return {
|
||||
lottery_info_type: 'uid',
|
||||
uids: [o.uid, o.origin_uid],
|
||||
uname: o.origin_uname,
|
||||
ctrl: [],
|
||||
dyid: o.origin_dynamic_id,
|
||||
rid: o.origin_rid_str,
|
||||
des: o.origin_description,
|
||||
type: o.orig_type,
|
||||
hasOfficialLottery: o.origin_hasOfficialLottery
|
||||
}
|
||||
}).filter(a => a.type != 0)
|
||||
log.info('获取动态', `成功获取用户${UID}的动态信息`);
|
||||
|
||||
return fomatdata;
|
||||
@@ -271,6 +304,7 @@ class Searcher {
|
||||
const fomatdata = mDRdata.map(o => {
|
||||
return {
|
||||
lottery_info_type: 'tag',
|
||||
is_liked: o.is_liked,
|
||||
uids: [o.uid, o.origin_uid],
|
||||
uname: o.uname,
|
||||
ctrl: o.ctrl,
|
||||
@@ -294,7 +328,9 @@ class Searcher {
|
||||
log.info('获取动态', `开始获取含关键词${key_words}的专栏信息`);
|
||||
const cvs = (await bili.searchArticlesByKeyword(key_words)).slice(0, config.article_scan_page);
|
||||
|
||||
/**存储所有专栏中的dyid */
|
||||
let dyinfos = [];
|
||||
/**遍历专栏s */
|
||||
for (const cv of cvs) {
|
||||
const
|
||||
content = await bili.getOneArticleByCv(cv),
|
||||
@@ -304,46 +340,48 @@ class Searcher {
|
||||
weight = dyids_set.length / 2;
|
||||
|
||||
let { length } = dyids_set,
|
||||
_weight = 0;
|
||||
/**初始权重 */
|
||||
_weight = 0,
|
||||
/**单个专栏中的dyid */
|
||||
_dyinfos = [];
|
||||
log.info('获取动态', `提取专栏(${cv})中提及的dyid(${length})`)
|
||||
for (const dyid of dyids_set) {
|
||||
const isRelayed = await d_storage.searchDyid(dyid);
|
||||
if (isRelayed) {
|
||||
_weight += 1;
|
||||
}
|
||||
if (_weight >= weight) {
|
||||
log.warn('获取动态', `1/2动态曾经转过,该专栏或已查看,故中止`)
|
||||
dyinfos = []
|
||||
break
|
||||
}
|
||||
if (dyid.length === utils.dyid_length) {
|
||||
if (!isRelayed) {
|
||||
log.info('获取动态', `查看动态(${dyid})的细节 (${length--})`)
|
||||
const res = await bili.getOneDynamicByDyid(dyid)
|
||||
, { code, data = {} } = utils.strToJson(res)
|
||||
, { card } = data;
|
||||
|
||||
if (code !== 0) {
|
||||
log.error('获取动态', '获取动态数据出错,可能是访问太频繁 \n' + res)
|
||||
/**遍历某专栏中的dyids */
|
||||
for (const dyid of dyids_set) {
|
||||
if (dyid.length === utils.dyid_length) {
|
||||
log.info('获取动态', `查看专栏中所提及动态(${dyid})的细节 (${length--})`)
|
||||
|
||||
const card = await bili.getOneDynamicByDyid(dyid)
|
||||
|
||||
if (card) {
|
||||
await utils.delay(2000)
|
||||
|
||||
const parsed_card = parseDynamicCard(card)
|
||||
, { is_liked } = parsed_card;
|
||||
|
||||
if (is_liked) {
|
||||
log.info('获取动态', `动态(${dyid})已转发过`)
|
||||
_weight += 1;
|
||||
}
|
||||
|
||||
if (_weight >= weight && !config.not_check_article) {
|
||||
log.warn('获取动态', `1/2动态曾经转过,该专栏或已查看,故中止`)
|
||||
_dyinfos = []
|
||||
break
|
||||
}
|
||||
|
||||
await utils.delay(2000)
|
||||
|
||||
if (card) {
|
||||
dyinfos.push(parseDynamicCard(card));
|
||||
}
|
||||
} else {
|
||||
log.info('获取动态', `动态(${dyid})已转发过 (${length--})`)
|
||||
_dyinfos.push(parsed_card);
|
||||
}
|
||||
} else {
|
||||
log.warn('获取动态', `动态(${dyid})无效 (${length--})`)
|
||||
}
|
||||
}
|
||||
dyinfos.push(..._dyinfos)
|
||||
}
|
||||
const fomatdata = dyinfos.map(o => {
|
||||
return {
|
||||
lottery_info_type: 'article',
|
||||
is_liked: o.is_liked,
|
||||
uids: [o.uid, o.origin_uid],
|
||||
uname: o.uname,
|
||||
ctrl: o.ctrl,
|
||||
@@ -361,4 +399,4 @@ class Searcher {
|
||||
}
|
||||
|
||||
|
||||
module.exports = { Searcher };
|
||||
module.exports = { Searcher };
|
||||
|
||||
+15
-6
@@ -1,19 +1,28 @@
|
||||
const { config_file } = require('../utils');
|
||||
const my_config = require(config_file);
|
||||
|
||||
const config = {
|
||||
...my_config["default_config"],
|
||||
/**
|
||||
* 原始设置
|
||||
* @returns {Object}
|
||||
*/
|
||||
raw_config() {
|
||||
delete require.cache[config_file];
|
||||
return require(config_file)
|
||||
},
|
||||
/**
|
||||
* @param {string} n
|
||||
*/
|
||||
updata(n) {
|
||||
const new_config = my_config[`config_${n}`];
|
||||
const new_config = this.raw_config()[`config_${n}`];
|
||||
if (new_config) {
|
||||
Object.entries(new_config)
|
||||
.forEach(([k, v]) => this[k] = v)
|
||||
this.setObject(new_config)
|
||||
}
|
||||
},
|
||||
init () {
|
||||
init() {
|
||||
this.setObject(this.raw_config()["default_config"])
|
||||
},
|
||||
setObject(o) {
|
||||
Object.entries(o).forEach(([k, v]) => this[k] = v)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
const { env_file } = require("../utils");
|
||||
|
||||
const env = {
|
||||
/**
|
||||
* 原始环境
|
||||
* @returns {Object}
|
||||
*/
|
||||
raw_env() {
|
||||
delete require.cache[env_file];
|
||||
return require(env_file)
|
||||
},
|
||||
init() {
|
||||
const raw_env = this.raw_env()
|
||||
this.setEnv({
|
||||
...raw_env["account_parm"],
|
||||
...raw_env["push_parm"]
|
||||
})
|
||||
},
|
||||
/**
|
||||
* @returns {Object[]}
|
||||
*/
|
||||
get_multiple_account() {
|
||||
return this.raw_env()["multiple_account_parm"]
|
||||
},
|
||||
setEnv(o) {
|
||||
process.env = {
|
||||
...process.env,
|
||||
...o
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module.exports = env;
|
||||
@@ -37,8 +37,6 @@ let global_var = {
|
||||
]);
|
||||
this.set('remoteconfig', await getRemoteConfig());
|
||||
}
|
||||
await createDir('dyids');
|
||||
await createFile(n < 2 ? 'dyid.txt' : `dyid${n}.txt`, '', 'a')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
const { log, readDyidFile, writeDyidFile, dyid_length } = require("../utils");
|
||||
|
||||
const d_storage = {
|
||||
/**
|
||||
* 搜索dyid
|
||||
* @param {string} dyid
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
searchDyid: (dyid) => {
|
||||
return new Promise((resolve) => {
|
||||
const Rdyid = new RegExp(dyid);
|
||||
const rs = readDyidFile(Number(process.env.NUMBER));
|
||||
let status = false;
|
||||
rs.on('data', chunk => {
|
||||
if (Rdyid.test(chunk)) {
|
||||
status = true
|
||||
}
|
||||
})
|
||||
rs.on('end', () => {
|
||||
resolve(status)
|
||||
})
|
||||
rs.on('error', err => {
|
||||
log.error('搜索dyid', err)
|
||||
resolve(status)
|
||||
})
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 更新dyid
|
||||
* @param {string} dyid
|
||||
*/
|
||||
updateDyid: (dyid) => {
|
||||
log.info('更新dyid', `写入${dyid}`);
|
||||
if (dyid.length !== dyid_length) {
|
||||
log.error('更新dyid', `dyid(${dyid})长度不为18 若出现此问题请即时通知开发者`)
|
||||
}
|
||||
return new Promise((resolve) => {
|
||||
const ws = writeDyidFile(Number(process.env.NUMBER));
|
||||
ws.write(dyid + ',', () => {
|
||||
ws.destroy();
|
||||
resolve()
|
||||
})
|
||||
ws.on('error', err => {
|
||||
log.error('更新dyid', err)
|
||||
resolve()
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module.exports = d_storage;
|
||||
+42
-42
@@ -202,10 +202,10 @@ function serverNotify(text, desp) {
|
||||
try {
|
||||
const data = JSON.parse(res.body);
|
||||
if (data.errno === 0) {
|
||||
log.info('发送通知', 'server酱发送通知消息成功\n')
|
||||
log.info('发送通知', 'server酱发送通知消息成功')
|
||||
} else if (data.errno === 1024) {
|
||||
// 一分钟内发送相同的内容会触发
|
||||
log.error('发送通知', `server酱发送通知消息异常: ${data.errmsg}\n`)
|
||||
log.error('发送通知', `server酱发送通知消息异常: ${data.errmsg}`)
|
||||
} else {
|
||||
log.error('发送通知', `server酱发送通知消息异常\n${JSON.stringify(data)}`)
|
||||
}
|
||||
@@ -216,12 +216,12 @@ function serverNotify(text, desp) {
|
||||
}
|
||||
},
|
||||
failure: err => {
|
||||
log.error('发送通知', 'server酱 发送通知调用API失败!!\n')
|
||||
log.error('发送通知', 'server酱 发送通知调用API失败!!')
|
||||
throw new Error(err);
|
||||
}
|
||||
})
|
||||
} else {
|
||||
log.warn('发送通知', '您未提供server酱的SCKEY,取消微信推送消息通知\n');
|
||||
log.debug('发送通知', '您未提供server酱的SCKEY,取消微信推送消息通知');
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
@@ -247,7 +247,7 @@ function serverNotifyTurbo(text, desp) {
|
||||
try {
|
||||
const data = JSON.parse(res.body);
|
||||
if (data.code === 0) {
|
||||
log.info('发送通知', 'server酱(Turbo版)发送通知消息成功\n')
|
||||
log.info('发送通知', 'server酱(Turbo版)发送通知消息成功')
|
||||
} else {
|
||||
log.error('发送通知', `server酱(Turbo版)发送通知消息异常\n${JSON.stringify(data)}`)
|
||||
}
|
||||
@@ -258,12 +258,12 @@ function serverNotifyTurbo(text, desp) {
|
||||
}
|
||||
},
|
||||
failure: err => {
|
||||
log.error('发送通知', 'server酱(Turbo版) 发送通知调用API失败!!\n')
|
||||
log.error('发送通知', 'server酱(Turbo版) 发送通知调用API失败!!')
|
||||
throw new Error(err);
|
||||
}
|
||||
})
|
||||
} else {
|
||||
log.warn('发送通知', '您未提供server酱(Turbo版)的SCKEY,取消微信推送消息通知\n');
|
||||
log.debug('发送通知', '您未提供server酱(Turbo版)的SCKEY,取消微信推送消息通知');
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
@@ -301,9 +301,9 @@ function coolPush(text, desp) {
|
||||
try {
|
||||
const data = JSON.parse(res.body);
|
||||
if (data.code === 200) {
|
||||
log.info('发送通知', `酷推发送${pushMode(QQ_MODE)}通知消息成功\n`)
|
||||
log.info('发送通知', `酷推发送${pushMode(QQ_MODE)}通知消息成功`)
|
||||
} else if (data.code === 400) {
|
||||
log.error('发送通知', `QQ酷推(Cool Push)发送${pushMode(QQ_MODE)}推送失败:${data}\n`)
|
||||
log.error('发送通知', `QQ酷推(Cool Push)发送${pushMode(QQ_MODE)}推送失败:${data}`)
|
||||
} else {
|
||||
log.error('发送通知', `酷推推送异常: ${data.msg}`);
|
||||
}
|
||||
@@ -314,12 +314,12 @@ function coolPush(text, desp) {
|
||||
}
|
||||
},
|
||||
failure: err => {
|
||||
log.error('发送通知', `酷推 发送${pushMode(QQ_MODE)}通知调用API失败!!\n`)
|
||||
log.error('发送通知', `酷推 发送${pushMode(QQ_MODE)}通知调用API失败!!`)
|
||||
throw new Error(err);
|
||||
}
|
||||
})
|
||||
} else {
|
||||
log.warn('发送通知', '您未提供酷推的SKEY,取消QQ推送消息通知\n');
|
||||
log.debug('发送通知', '您未提供酷推的SKEY,取消QQ推送消息通知');
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
@@ -345,9 +345,9 @@ function barkNotify(text, desp, params = {}) {
|
||||
try {
|
||||
const data = JSON.parse(res.body);
|
||||
if (data.code === 200) {
|
||||
log.info('发送通知', 'Bark APP发送通知消息成功\n')
|
||||
log.info('发送通知', 'Bark APP发送通知消息成功')
|
||||
} else {
|
||||
log.error('发送通知', `${data.message}\n`);
|
||||
log.error('发送通知', `${data.message}`);
|
||||
}
|
||||
} catch (error) {
|
||||
log.error('发送通知', error);
|
||||
@@ -356,13 +356,13 @@ function barkNotify(text, desp, params = {}) {
|
||||
}
|
||||
},
|
||||
failure: err => {
|
||||
log.error('发送通知', 'Bark APP发送通知调用API失败!!\n');
|
||||
log.error('发送通知', 'Bark APP发送通知调用API失败!!');
|
||||
resolve();
|
||||
throw new Error(err)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
log.warn('发送通知', '您未提供Bark的APP推送BARK_PUSH,取消Bark推送消息通知\n');
|
||||
log.debug('发送通知', '您未提供Bark的APP推送BARK_PUSH,取消Bark推送消息通知');
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
@@ -391,11 +391,11 @@ function tgBotNotify(text, desp) {
|
||||
try {
|
||||
const data = JSON.parse(res.body);
|
||||
if (data.ok) {
|
||||
log.info('发送通知', 'Telegram发送通知消息完成。\n')
|
||||
log.info('发送通知', 'Telegram发送通知消息完成。')
|
||||
} else if (data.error_code === 400) {
|
||||
log.error('发送通知', '请主动给bot发送一条消息并检查接收用户ID是否正确。\n')
|
||||
log.error('发送通知', '请主动给bot发送一条消息并检查接收用户ID是否正确。')
|
||||
} else if (data.error_code === 401) {
|
||||
log.error('发送通知', 'Telegram bot token 填写错误。\n')
|
||||
log.error('发送通知', 'Telegram bot token 填写错误。')
|
||||
}
|
||||
} catch (error) {
|
||||
log.error('发送通知', error);
|
||||
@@ -404,7 +404,7 @@ function tgBotNotify(text, desp) {
|
||||
}
|
||||
},
|
||||
failure: err => {
|
||||
log.error('发送通知', 'telegram发送通知消息失败!!\n')
|
||||
log.error('发送通知', 'telegram发送通知消息失败!!')
|
||||
resolve()
|
||||
throw new Error(err)
|
||||
}
|
||||
@@ -417,7 +417,7 @@ function tgBotNotify(text, desp) {
|
||||
}
|
||||
send(options)
|
||||
} else {
|
||||
log.warn('发送通知', '您未提供telegram机器人推送所需的TG_BOT_TOKEN和TG_USER_ID,取消telegram推送消息通知\n');
|
||||
log.debug('发送通知', '您未提供telegram机器人推送所需的TG_BOT_TOKEN和TG_USER_ID,取消telegram推送消息通知');
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
@@ -430,7 +430,7 @@ function ddBotNotify(text, desp) {
|
||||
const dateNow = Date.now();
|
||||
const hmac = crypto.createHmac('sha256', DD_BOT_SECRET);
|
||||
hmac.update(`${dateNow}\n${DD_BOT_SECRET}`);
|
||||
const result = encodeURIComponent(hmac.digest('Util64'));
|
||||
const result = encodeURIComponent(hmac.digest().toString('base64'));
|
||||
send({
|
||||
method: 'POST',
|
||||
url: `https://oapi.dingtalk.com/robot/send`,
|
||||
@@ -456,9 +456,9 @@ function ddBotNotify(text, desp) {
|
||||
try {
|
||||
const data = JSON.parse(res.body);
|
||||
if (data.errcode === 0) {
|
||||
log.info('发送通知', '钉钉发送通知消息完成。\n')
|
||||
log.info('发送通知', '钉钉发送通知消息完成。')
|
||||
} else {
|
||||
log.error('发送通知', `${data.errmsg}\n`)
|
||||
log.error('发送通知', `${data.errmsg}`)
|
||||
}
|
||||
} catch (e) {
|
||||
log.error('发送通知', e);
|
||||
@@ -467,7 +467,7 @@ function ddBotNotify(text, desp) {
|
||||
}
|
||||
},
|
||||
failure: err => {
|
||||
log.error('发送通知', '钉钉发送通知消息失败!!\n')
|
||||
log.error('发送通知', '钉钉发送通知消息失败!!')
|
||||
throw new Error(err);
|
||||
}
|
||||
})
|
||||
@@ -495,9 +495,9 @@ function ddBotNotify(text, desp) {
|
||||
try {
|
||||
const data = JSON.parse(res.body);
|
||||
if (data.errcode === 0) {
|
||||
log.info('发送通知', '钉钉发送通知消息完成。\n')
|
||||
log.info('发送通知', '钉钉发送通知消息完成。')
|
||||
} else {
|
||||
log.error('发送通知', `${data.errmsg}\n`)
|
||||
log.error('发送通知', `${data.errmsg}`)
|
||||
}
|
||||
} catch (e) {
|
||||
log.error('发送通知', e);
|
||||
@@ -506,13 +506,13 @@ function ddBotNotify(text, desp) {
|
||||
}
|
||||
},
|
||||
failure: err => {
|
||||
log.error('发送通知', '钉钉发送通知消息失败!!\n');
|
||||
log.error('发送通知', '钉钉发送通知消息失败!!');
|
||||
resolve();
|
||||
throw new Error(err)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
log.warn('发送通知', '您未提供钉钉机器人推送所需的DD_BOT_TOKEN或者DD_BOT_SECRET,取消钉钉推送消息通知\n');
|
||||
log.debug('发送通知', '您未提供钉钉机器人推送所需的DD_BOT_TOKEN或者DD_BOT_SECRET,取消钉钉推送消息通知');
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
@@ -541,9 +541,9 @@ function qywxBotNotify(text, desp) {
|
||||
try {
|
||||
const data = JSON.parse(res.body);
|
||||
if (data.errcode === 0) {
|
||||
log.info('发送通知', '企业微信发送通知消息完成。\n');
|
||||
log.info('发送通知', '企业微信发送通知消息完成。');
|
||||
} else {
|
||||
log.error('发送通知', `${data.errmsg}\n`);
|
||||
log.error('发送通知', `${data.errmsg}`);
|
||||
}
|
||||
} catch (e) {
|
||||
log.error('发送通知', e);
|
||||
@@ -552,13 +552,13 @@ function qywxBotNotify(text, desp) {
|
||||
}
|
||||
},
|
||||
failure: err => {
|
||||
log.error('发送通知', '企业微信发送通知消息失败!!\n');
|
||||
log.error('发送通知', '企业微信发送通知消息失败!!');
|
||||
resolve();
|
||||
throw new Error(err)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
log.warn('发送通知', '您未提供企业微信机器人推送所需的QYWX_KEY,取消企业微信推送消息通知\n');
|
||||
log.debug('发送通知', '您未提供企业微信机器人推送所需的QYWX_KEY,取消企业微信推送消息通知');
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
@@ -570,7 +570,7 @@ function iGotNotify(text, desp, params = {}) {
|
||||
// 校验传入的IGOT_PUSH_KEY是否有效
|
||||
const IGOT_PUSH_KEY_REGX = new RegExp("^[a-zA-Z0-9]{24}$")
|
||||
if (!IGOT_PUSH_KEY_REGX.test(IGOT_PUSH_KEY)) {
|
||||
log.error('发送通知', '您所提供的IGOT_PUSH_KEY无效\n')
|
||||
log.error('发送通知', '您所提供的IGOT_PUSH_KEY无效')
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
@@ -593,9 +593,9 @@ function iGotNotify(text, desp, params = {}) {
|
||||
try {
|
||||
const data = JSON.parse(res.body);
|
||||
if (data.ret === 0) {
|
||||
log.info('发送通知', 'iGot发送通知消息成功\n')
|
||||
log.info('发送通知', 'iGot发送通知消息成功')
|
||||
} else {
|
||||
log.error('发送通知', `iGot发送通知消息失败:${data.errMsg}\n`)
|
||||
log.error('发送通知', `iGot发送通知消息失败:${data.errMsg}`)
|
||||
}
|
||||
} catch (e) {
|
||||
log.error('发送通知', e);
|
||||
@@ -604,13 +604,13 @@ function iGotNotify(text, desp, params = {}) {
|
||||
}
|
||||
},
|
||||
failure: err => {
|
||||
log.error('发送通知', 'iGot 发送通知调用API失败!!\n')
|
||||
log.error('发送通知', 'iGot 发送通知调用API失败!!')
|
||||
resolve();
|
||||
throw new Error(err)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
log.warn('发送通知', '您未提供iGot的推送IGOT_PUSH_KEY,取消iGot推送消息通知\n');
|
||||
log.debug('发送通知', '您未提供iGot的推送IGOT_PUSH_KEY,取消iGot推送消息通知');
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
@@ -639,9 +639,9 @@ function pushPlusNotify(text, desp) {
|
||||
try {
|
||||
const data = JSON.parse(res.body);
|
||||
if (data.code === 200) {
|
||||
log.info('发送通知', `push+发送${PUSH_PLUS_USER ? '一对多' : '一对一'}通知消息完成。\n`)
|
||||
log.info('发送通知', `push+发送${PUSH_PLUS_USER ? '一对多' : '一对一'}通知消息完成。`)
|
||||
} else {
|
||||
log.error('发送通知', `push+发送${PUSH_PLUS_USER ? '一对多' : '一对一'}通知消息失败:${data.msg}\n`)
|
||||
log.error('发送通知', `push+发送${PUSH_PLUS_USER ? '一对多' : '一对一'}通知消息失败:${data.msg}`)
|
||||
}
|
||||
} catch (e) {
|
||||
log.error('发送通知', e);
|
||||
@@ -650,13 +650,13 @@ function pushPlusNotify(text, desp) {
|
||||
}
|
||||
},
|
||||
failure: err => {
|
||||
log.error('发送通知', `push+发送${PUSH_PLUS_USER ? '一对多' : '一对一'}通知消息失败!!\n`)
|
||||
log.error('发送通知', `push+发送${PUSH_PLUS_USER ? '一对多' : '一对一'}通知消息失败!!`)
|
||||
resolve();
|
||||
throw new Error(err)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
log.warn('发送通知', '您未提供push+推送所需的PUSH_PLUS_TOKEN,取消push+推送消息通知\n');
|
||||
log.debug('发送通知', '您未提供push+推送所需的PUSH_PLUS_TOKEN,取消push+推送消息通知');
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
@@ -684,7 +684,7 @@ async function email(text, desp) {
|
||||
}
|
||||
log.info('发送通知', 'email发送成功');
|
||||
} else {
|
||||
log.warn('发送通知', '您未提供email推送所需的所有参数故取消email推送消息通知\n');
|
||||
log.debug('发送通知', '您未提供email推送所需的所有参数故取消email推送消息通知');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -1,10 +1,11 @@
|
||||
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')
|
||||
const { sendNotify } = require('./helper/notify')
|
||||
const { sendNotify } = require('./helper/notify');
|
||||
|
||||
/**
|
||||
* 检查cookie是否有效
|
||||
@@ -23,4 +24,4 @@ async function checkCookie(num) {
|
||||
}
|
||||
|
||||
|
||||
module.exports = { start, isMe, clear, checkCookie }
|
||||
module.exports = { start, isMe, clear, update, checkCookie }
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
module.exports = Object.freeze({
|
||||
DYNAMIC_LIKE_THUMB: 'https://api.vc.bilibili.com/dynamic_like/v1/dynamic_like/thumb',
|
||||
DYNAMIC_REPOST_REPOST: 'https://api.vc.bilibili.com/dynamic_repost/v1/dynamic_repost/repost',
|
||||
DYNAMIC_SVR_CREATE_DRAW: 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/create_draw',
|
||||
@@ -29,4 +29,4 @@ module.exports = {
|
||||
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',
|
||||
WEB_INTERFACE_SEARCH_TYPE: 'https://api.bilibili.com/x/web-interface/search/type',
|
||||
}
|
||||
})
|
||||
+42
-12
@@ -161,8 +161,8 @@ const bili_client = {
|
||||
const sessions = res.data.session_list || [];
|
||||
const has_more = res.data.has_more;
|
||||
const data = sessions.map(session => {
|
||||
const { session_ts, last_msg = {}, unread_count, talker_id } = session;
|
||||
const { content = '', timestamp = 0, sender_uid = 0, msg_seqno } = last_msg;
|
||||
const { session_ts, last_msg, unread_count, talker_id } = session;
|
||||
const { content = '', timestamp = 0, sender_uid = 0, msg_seqno } = last_msg || {};
|
||||
return { session_ts, content, timestamp, sender_uid, unread_count, talker_id, msg_seqno }
|
||||
})
|
||||
return { has_more, data }
|
||||
@@ -185,7 +185,7 @@ const bili_client = {
|
||||
}).then(responseText => {
|
||||
let res = strToJson(responseText);
|
||||
if (res.code === 0) {
|
||||
const { unfollow_unread, follow_unread } = res.data;
|
||||
const { unfollow_unread = 0, follow_unread = 0 } = res.data;
|
||||
log.info('获取未读私信', `成功 已关注未读数: ${follow_unread}, 未关注未读数 ${unfollow_unread}`);
|
||||
return { unfollow_unread, follow_unread }
|
||||
} else {
|
||||
@@ -247,7 +247,7 @@ const bili_client = {
|
||||
/**
|
||||
* 获取一个动态的细节
|
||||
* @param {string} dynamic_id
|
||||
* @return {Promise<string>}
|
||||
* @return {Promise<JSON>} 失败返回undefined
|
||||
*/
|
||||
getOneDynamicByDyid(dynamic_id) {
|
||||
return get({
|
||||
@@ -255,6 +255,21 @@ const bili_client = {
|
||||
query: {
|
||||
dynamic_id
|
||||
}
|
||||
}).then(responseText => {
|
||||
const { code, data } = strToJson(responseText)
|
||||
, { card } = data || {};
|
||||
|
||||
if (code !== 0) {
|
||||
log.error('获取一个动态的细节', `获取动态(${dynamic_id})数据出错:\n${responseText}`)
|
||||
return
|
||||
}
|
||||
|
||||
if (!card) {
|
||||
log.warn('获取一个动态的细节', `动态(${dynamic_id})不存在`)
|
||||
return
|
||||
}
|
||||
|
||||
return card
|
||||
})
|
||||
},
|
||||
/**
|
||||
@@ -349,8 +364,15 @@ const bili_client = {
|
||||
}).then(responseText => {
|
||||
const res = JSON.parse(responseText);
|
||||
if (res.code === 0) {
|
||||
log.info('搜索专栏', '成功 关键词: ' + keyword)
|
||||
return res.data.result.map(it => it.id)
|
||||
let cv_arr = []
|
||||
try {
|
||||
log.info('搜索专栏', '成功 关键词: ' + keyword)
|
||||
cv_arr = res.data.result.map(it => it.id)
|
||||
} catch (error) {
|
||||
log.error('搜索专栏', '失败 原因:\n' + responseText)
|
||||
cv_arr = []
|
||||
}
|
||||
return cv_arr
|
||||
} else {
|
||||
log.error('搜索专栏', '失败 原因:\n' + responseText)
|
||||
return []
|
||||
@@ -476,23 +498,23 @@ const bili_client = {
|
||||
contents: {
|
||||
fid: uid,
|
||||
act: 1,
|
||||
re_src: 11,
|
||||
re_src: 0,
|
||||
csrf: GlobalVar.get("csrf")
|
||||
}
|
||||
}).then(responseText => {
|
||||
let _responseText = ''
|
||||
/* 重复关注code also equal 0 */
|
||||
const res = strToJson(responseText)
|
||||
_responseText += responseText
|
||||
if (res.code === 0) {
|
||||
log.info('自动关注', '关注+1');
|
||||
return 0
|
||||
} else if (res.code === 22002) {
|
||||
log.error('自动关注', '您已被对方拉入黑名单');
|
||||
return 1
|
||||
} else if (res.code === 22015) {
|
||||
log.error('自动关注', '您的账号异常无法关注');
|
||||
return 2
|
||||
} else {
|
||||
log.warn('自动关注', `失败 尝试切换线路\n${responseText}`);
|
||||
_responseText += responseText
|
||||
return post({
|
||||
url: API.FEED_SETUSERFOLLOW,
|
||||
contents: {
|
||||
@@ -506,12 +528,13 @@ const bili_client = {
|
||||
return 0
|
||||
} else {
|
||||
log.warn('自动关注', `失败 尝试切换另一条线路\n${responseText}`);
|
||||
_responseText += responseText
|
||||
return post({
|
||||
url: API.RELATION_BATCH_MODIFY,
|
||||
contents: {
|
||||
fid: uid,
|
||||
act: 1,
|
||||
re_src: 11,
|
||||
re_src: 0,
|
||||
csrf: GlobalVar.get("csrf")
|
||||
}
|
||||
}).then(responseText => {
|
||||
@@ -520,6 +543,10 @@ const bili_client = {
|
||||
return 0
|
||||
} else {
|
||||
log.error('自动关注', `失败\n${responseText}`);
|
||||
_responseText += responseText
|
||||
if (_responseText.includes(22015)) {
|
||||
return 2
|
||||
}
|
||||
return 1
|
||||
}
|
||||
})
|
||||
@@ -569,7 +596,7 @@ const bili_client = {
|
||||
contents: {
|
||||
fid: uid,
|
||||
act: 2,
|
||||
re_src: 11,
|
||||
re_src: 0,
|
||||
csrf: GlobalVar.get("csrf")
|
||||
}
|
||||
}).then(responseText => {
|
||||
@@ -751,6 +778,9 @@ const bili_client = {
|
||||
} else if (res.code === 12015) {
|
||||
show && log.error('自动评论', '需要输入验证码');
|
||||
return 1
|
||||
} else if (res.code === 12035) {
|
||||
show && log.error('自动评论', `已被对方拉入黑名单`);
|
||||
return -1
|
||||
} else if (res.code === 12053) {
|
||||
show && log.error('自动评论', '黑名单用户无法互动');
|
||||
return -1
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
const { send } = require('./net/http')
|
||||
const { strToJson, download } = require('./utils')
|
||||
const { version, checkVersion, log } = require('./utils')
|
||||
|
||||
/**
|
||||
* 获取下载链接
|
||||
* @param {string} owner
|
||||
* @param {string} repo
|
||||
* @returns {Promise<{ download_url: string, text: string }>}
|
||||
*/
|
||||
function getLatestReleaseDownloadUrl(owner, repo) {
|
||||
return new Promise((resolve, reject) => {
|
||||
send({
|
||||
url: `https://api.github.com/repos/${owner}/${repo}/releases/latest`,
|
||||
headers: {
|
||||
"accept": 'application/vnd.github.v3+json'
|
||||
},
|
||||
config: {
|
||||
retry: false
|
||||
},
|
||||
success: ({ body }) => {
|
||||
const { tag_name, assets, body: text } = strToJson(body)
|
||||
if (tag_name) {
|
||||
if (checkVersion(version) < checkVersion(tag_name)) {
|
||||
const platform = new Map([
|
||||
['win32', 'win'],
|
||||
['linux', 'linux'],
|
||||
['darwin', 'macos']
|
||||
]).get(process.platform)
|
||||
const arch = new Map([
|
||||
['x64', 'x64'],
|
||||
['arm', 'armv7'],
|
||||
['arm64', 'arm64']
|
||||
]).get(process.arch)
|
||||
if (platform && arch) {
|
||||
try {
|
||||
const download_url = assets
|
||||
.filter(({ name }) => name.includes(platform) && name.includes(arch))
|
||||
.map(({ browser_download_url }) => browser_download_url)[0]
|
||||
if (!download_url) {
|
||||
reject(`未找到能在此平台(${process.platform})-(${process.arch})上运行的版本`)
|
||||
}
|
||||
resolve({ download_url, text })
|
||||
} catch (err) {
|
||||
reject(err)
|
||||
}
|
||||
} else {
|
||||
reject(`未找到能在此平台(${process.platform})-(${process.arch})上运行的版本`)
|
||||
}
|
||||
} else {
|
||||
reject('当前已是最新版本')
|
||||
}
|
||||
} else {
|
||||
reject(body)
|
||||
}
|
||||
},
|
||||
failure: error => {
|
||||
reject(error)
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 半自动更新
|
||||
*/
|
||||
async function update() {
|
||||
try {
|
||||
const { download_url, text } = await getLatestReleaseDownloadUrl('shanmiteko', 'LotteryAutoScript')
|
||||
|
||||
let proxy_url = new URL(download_url)
|
||||
proxy_url.host = 'download.fastgit.org'
|
||||
|
||||
await download(proxy_url.href, 'latest_version.zip')
|
||||
|
||||
log.info('自动下载', '成功下载到当前目录')
|
||||
log.info('更新说明', '\n' + text + '\n')
|
||||
} catch (error) {
|
||||
log.error('更新脚本', error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module.exports = { update }
|
||||
+54
-51
@@ -2,19 +2,29 @@ const chalk = require('chalk');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { send } = require("./net/http");
|
||||
const { version } = require('../package.json');
|
||||
|
||||
/**
|
||||
* 基础工具
|
||||
*/
|
||||
const utils = {
|
||||
version,
|
||||
/**环境变量设置文件 */
|
||||
env_file: path.join(process.cwd(), "env.js"),
|
||||
/**配置文件 */
|
||||
config_file: path.join(process.cwd(), "my_config.js"),
|
||||
/**dyid存储文件 */
|
||||
dyids_dir: path.join(process.cwd(), "dyids"),
|
||||
/**dyid长度 */
|
||||
dyid_length: 18,
|
||||
/**
|
||||
* 将版本号转为数字
|
||||
* @example
|
||||
* 1.2.3 => 1.0203
|
||||
* @param {string} version
|
||||
* @returns {Number}
|
||||
*/
|
||||
checkVersion(version) {
|
||||
return (version.match(/\d.*/)[0]).split('.').reduce((a, v, i) => a + (0.01 ** i) * Number(v), 0)
|
||||
},
|
||||
/**
|
||||
* 安全的将JSON字符串转为对象
|
||||
* 超出精度的数转为字符串
|
||||
@@ -154,7 +164,7 @@ const utils = {
|
||||
},
|
||||
/**日志 */
|
||||
log: {
|
||||
level: 0,
|
||||
level: 3,
|
||||
/**
|
||||
* 初始化默认level为3
|
||||
*/
|
||||
@@ -172,22 +182,59 @@ const utils = {
|
||||
debug(context, msg) {
|
||||
if (this.level > 3) {
|
||||
if (msg instanceof Object) msg = JSON.stringify(msg, null, 4);
|
||||
this.proPrint([chalk.hex('#64B3FF')(`[${Date()}]`), chalk.grey("[Debug]"), chalk.hex('#FFA500')(`[${context}]`), chalk.hex('#0070BB')(`[\n${msg}\n]`)])
|
||||
this.proPrint([chalk.hex('#64B3FF')(`[${new Date(Date.now() + 288e5).toISOString()}]`), chalk.grey("[Debug]"), chalk.hex('#FFA500')(`[${context}]`), chalk.hex('#0070BB')(`[\n${msg}\n]`)])
|
||||
}
|
||||
},
|
||||
info(context, msg) {
|
||||
if (this.level > 2)
|
||||
this.proPrint([chalk.hex('#64B3FF')(`[${Date()}]`), chalk.grey("[Info]"), chalk.hex('#FFA500')(`[${context}]`), chalk.hex('#48BB31')(`[${msg}]`)])
|
||||
this.proPrint([chalk.hex('#64B3FF')(`[${new Date(Date.now() + 288e5).toISOString()}]`), chalk.grey("[Info]"), chalk.hex('#FFA500')(`[${context}]`), chalk.hex('#48BB31')(`[${msg}]`)])
|
||||
},
|
||||
warn(context, msg) {
|
||||
if (this.level > 1)
|
||||
this.proPrint([chalk.hex('#64B3FF')(`[${Date()}]`), chalk.grey("[Warn]"), chalk.hex('#FFA500')(`[${context}]`), chalk.hex('#BBBB23')(`[${msg}]`)])
|
||||
this.proPrint([chalk.hex('#64B3FF')(`[${new Date(Date.now() + 288e5).toISOString()}]`), chalk.grey("[Warn]"), chalk.hex('#FFA500')(`[${context}]`), chalk.hex('#BBBB23')(`[\n${msg}\n]`)])
|
||||
},
|
||||
error(context, msg) {
|
||||
if (this.level > 0)
|
||||
this.proPrint([chalk.hex('#64B3FF')(`[${Date()}]`), chalk.grey("[Error]"), chalk.hex('#FFA500')(`[${context}]`), chalk.hex('#FF0006')(`[${msg}]`)])
|
||||
this.proPrint([chalk.hex('#64B3FF')(`[${new Date(Date.now() + 288e5).toISOString()}]`), chalk.grey("[Error]"), chalk.hex('#FFA500')(`[${context}]`), chalk.hex('#FF0006')(`[\n${msg}\n]`)])
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 下载文件
|
||||
* @param {string} url
|
||||
* @param {string} file_name
|
||||
* @returns {Promise<void | string>}
|
||||
*/
|
||||
download(url, file_name) {
|
||||
return new Promise((resolve, reject) => {
|
||||
send({
|
||||
url,
|
||||
stream: true,
|
||||
config: {
|
||||
redirect: true,
|
||||
retry: false
|
||||
},
|
||||
success: ({ resStream }) => {
|
||||
let recv_length = 0;
|
||||
const wtbs = fs.createWriteStream(file_name);
|
||||
resStream.on('data', chuck => {
|
||||
recv_length += chuck.length
|
||||
utils.log.proPrint(`已收到:${recv_length} Bytes`)
|
||||
})
|
||||
resStream.pipe(wtbs)
|
||||
wtbs.on('finish', () => {
|
||||
utils.log.proPrint('下载完成')
|
||||
resolve()
|
||||
}).on('error', error => {
|
||||
wtbs.destroy()
|
||||
resolve(error)
|
||||
})
|
||||
},
|
||||
failure: error => {
|
||||
reject(error)
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 获取远程设置
|
||||
* @returns {Promise<JSON>}
|
||||
@@ -245,50 +292,6 @@ const utils = {
|
||||
resolve()
|
||||
})
|
||||
});
|
||||
},
|
||||
/**
|
||||
* CreateFile
|
||||
* @param {string} filepath 相对于dyids的文件路径
|
||||
* @param {string} [defaultValue] 写入默认值
|
||||
* @param {string} flag
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
createFile(filepath, defaultValue, flag) {
|
||||
const fpath = path.join(utils.dyids_dir, filepath);
|
||||
const buffer = Buffer.from(defaultValue);
|
||||
return new Promise((resolve, rejects) => {
|
||||
fs.open(fpath, flag, (err, fd) => {
|
||||
if (err) {
|
||||
rejects(err)
|
||||
} else {
|
||||
fs.write(fd, buffer, 0, buffer.length, 0, err => {
|
||||
if (err) {
|
||||
rejects(err)
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 读取dyid文件
|
||||
* @param {number} num
|
||||
* @returns {fs.ReadStream}
|
||||
*/
|
||||
readDyidFile(num) {
|
||||
const fpath = num < 2 ? path.join(utils.dyids_dir, 'dyid.txt') : path.join(utils.dyids_dir, `dyid${num}.txt`);
|
||||
return fs.createReadStream(fpath, { encoding: 'utf8', highWaterMark: (utils.dyid_length + 1) * 1000 })
|
||||
},
|
||||
/**
|
||||
* 追加dyid
|
||||
* @param {number} num
|
||||
* @returns {fs.WriteStream}
|
||||
*/
|
||||
writeDyidFile(num) {
|
||||
const fpath = num < 2 ? path.join(utils.dyids_dir, 'dyid.txt') : path.join(utils.dyids_dir, `dyid${num}.txt`);
|
||||
return fs.createWriteStream(fpath, { flags: 'a' })
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const { env_file, config_file, log, hasEnv, delay, hasFileOrDir } = require("./lib/utils");
|
||||
const { version: ve, env_file, config_file, log, hasEnv, delay, hasFileOrDir } = require("./lib/utils");
|
||||
|
||||
const metainfo = [
|
||||
` _ _ _ _____ _ _ `,
|
||||
@@ -10,7 +10,7 @@ const metainfo = [
|
||||
` __/ | | | `,
|
||||
` |___/ |_| `,
|
||||
` `,
|
||||
` Verison: v2.0.5`,
|
||||
` Verison: v${ve}`,
|
||||
` Written By shanmite`,
|
||||
]
|
||||
/**多账号存储 */
|
||||
@@ -49,14 +49,14 @@ async function main() {
|
||||
await global_var.init(COOKIE, Number(NUMBER));
|
||||
|
||||
/**引入基础功能 */
|
||||
const { start, isMe, clear, checkCookie } = require("./lib/index");
|
||||
const { start, isMe, clear, update, 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\thelp 帮助信息";
|
||||
const { lottery_loop_wait, check_loop_wait, clear_loop_wait } = require("./lib/data/config");
|
||||
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");
|
||||
switch (mode) {
|
||||
case 'start':
|
||||
log.info('抽奖', '开始运行');
|
||||
@@ -75,6 +75,11 @@ 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:
|
||||
@@ -90,15 +95,21 @@ async function main() {
|
||||
}
|
||||
}
|
||||
|
||||
(async function () {
|
||||
log.proPrint(metainfo, '\n')
|
||||
|
||||
/**
|
||||
* 初始化环境
|
||||
* @returns {boolean} 出错true
|
||||
*/
|
||||
function initEnv() {
|
||||
if (hasFileOrDir(env_file)) {
|
||||
const { initEnv, multiple_account_parm } = require(env_file);
|
||||
const
|
||||
env = require("./lib/data/env"),
|
||||
multiple_account_parm = env.get_multiple_account();
|
||||
|
||||
if (multiple_account_parm) {
|
||||
multiple_account = multiple_account_parm;
|
||||
}
|
||||
initEnv();
|
||||
|
||||
env.init();
|
||||
log.init();
|
||||
log.info('环境变量初始化', '成功加载env.js文件');
|
||||
} else if (hasEnv('COOKIE') || hasEnv('MULTIPLE_ACCOUNT_PARM')) {
|
||||
@@ -107,29 +118,47 @@ async function main() {
|
||||
} else {
|
||||
log.init();
|
||||
log.error('环境变量初始化', '未在当前目录下找到env.js文件或者在环境变量中设置所需参数');
|
||||
return
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化设置
|
||||
* @returns {boolean} 出错true
|
||||
*/
|
||||
function initConfig() {
|
||||
if (hasFileOrDir(config_file)) {
|
||||
require("./lib/data/config");
|
||||
const config = require("./lib/data/config");
|
||||
config.init();
|
||||
log.info('配置文件初始化', '成功加载my_config.js文件');
|
||||
} else {
|
||||
log.error('配置文件初始化', '未在当前目录下找到my_config.js文件');
|
||||
return
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
(async function () {
|
||||
log.proPrint(metainfo, '\n')
|
||||
|
||||
if (initEnv() || initConfig()) return;
|
||||
|
||||
/**OPTIONS */
|
||||
process.env.lottery_mode = process.argv[2]
|
||||
|
||||
const err_msg = await main();
|
||||
if (err_msg) {
|
||||
log.error('错误', '\n' + err_msg + '\n');
|
||||
log.error('错误', err_msg);
|
||||
log.warn('结束运行', '5秒后自动退出');
|
||||
await delay(5 * 1000);
|
||||
} else {
|
||||
while (loop_wait) {
|
||||
log.info('程序休眠', `${loop_wait / 1000}秒后再次启动`)
|
||||
await delay(loop_wait)
|
||||
if (initEnv() || initConfig()) return;
|
||||
await main()
|
||||
}
|
||||
log.info('结束运行', '未在config.js中设置休眠时间')
|
||||
|
||||
+16
-6
@@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
module.exports = Object.freeze({
|
||||
/**
|
||||
* 默认设置(公用)
|
||||
*/
|
||||
@@ -7,7 +7,6 @@ module.exports = {
|
||||
* 监视更转的用户uid
|
||||
*/
|
||||
UIDs: [
|
||||
31252386,
|
||||
689277291,
|
||||
241675899
|
||||
],
|
||||
@@ -74,6 +73,12 @@ module.exports = {
|
||||
*/
|
||||
article_scan_page: 3,
|
||||
|
||||
/**
|
||||
* - 不检查专栏是否看过,若选择检查可以提高检测效率
|
||||
* - 默认false(检查)
|
||||
*/
|
||||
not_check_article: false,
|
||||
|
||||
/**
|
||||
* - 开奖时间距离现在的最大天数
|
||||
* - 默认不限制
|
||||
@@ -87,6 +92,7 @@ module.exports = {
|
||||
lottery_loop_wait: 0,
|
||||
check_loop_wait: 0,
|
||||
clear_loop_wait: 0,
|
||||
update_loop_wait: 0,
|
||||
|
||||
/**
|
||||
* - 转发间隔时间
|
||||
@@ -117,15 +123,19 @@ module.exports = {
|
||||
create_dy: false,
|
||||
|
||||
/**
|
||||
* - 发送随机动态的数量
|
||||
* - 结束运行时发送随机动态的数量
|
||||
*/
|
||||
create_dy_num: 1,
|
||||
|
||||
/**
|
||||
* - 每转发x条抽奖动态就发送x条随机动态
|
||||
* - @example [6,1] 每转发6条抽奖动态就发送1条随机动态
|
||||
*/
|
||||
create_dy_mode: [0, 0],
|
||||
|
||||
/**
|
||||
* - 随机动态内容
|
||||
* - 类型 `content[]`
|
||||
*/
|
||||
/**
|
||||
* @typedef Picture
|
||||
* @property {string} img_src 站内源
|
||||
* @property {number} img_width
|
||||
@@ -248,4 +258,4 @@ module.exports = {
|
||||
config_1: {},
|
||||
config_2: {},
|
||||
config_3: {}
|
||||
}
|
||||
})
|
||||
|
||||
+16
-7
@@ -1,17 +1,26 @@
|
||||
{
|
||||
"name": "lottery-in-bili",
|
||||
"version": "3.0.0",
|
||||
"description": "自动抽奖",
|
||||
"name": "lottery-auto-script",
|
||||
"version": "2.2.1",
|
||||
"description": "自动参与B站动态抽奖",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"start": "node main.js start",
|
||||
"clear": "node main.js clear",
|
||||
"check": "node main.js check",
|
||||
"pkg_x86": "npx pkg . && PowerShell .\\script\\pkg\\pkg.ps1",
|
||||
"pkg_clean_dist": "PowerShell -Command \"& {Remove-Item -Path .\\dist\\ -Recurse}\"",
|
||||
"pkg_arm64": "npx pkg -t linux-arm64 -o dist/lottery main.js && cp my_config.example.js my_config.js && cp env.example.js dist/env.js",
|
||||
"pkg_armv7": "npx pkg -t linux-armv7 -o dist/lottery main.js && cp my_config.example.js my_config.js && cp env.example.js dist/env.js"
|
||||
"update": "node main.js update",
|
||||
"pkg_x64": "PowerShell .\\script\\pkg\\pkg.ps1",
|
||||
"pkg_arm64": "npx pkg -t node16-linux-arm64 -o dist/lottery main.js && cp my_config.example.js dist/my_config.js && cp env.example.js dist/env.js",
|
||||
"pkg_armv7": "npx pkg -t node16-linuxstatic-armv7 -o dist/lottery main.js && cp my_config.example.js dist/my_config.js && cp env.example.js dist/env.js"
|
||||
},
|
||||
"files": [
|
||||
"lib",
|
||||
"main.js",
|
||||
"package.js",
|
||||
"my_config.example.js",
|
||||
"env.example.js",
|
||||
"LICENSE",
|
||||
"README.md"
|
||||
],
|
||||
"bin": "main.js",
|
||||
"pkg": {
|
||||
"targets": [
|
||||
|
||||
@@ -3,8 +3,6 @@ set -e
|
||||
|
||||
# 脚本根目录
|
||||
SCRIPT_FOLDER=lottery
|
||||
# dyid存放目录
|
||||
DYID_FOLDER=dyids
|
||||
# 设置环境变量文件
|
||||
ENV_FILE=env.js
|
||||
# 自定义设置文件
|
||||
@@ -26,14 +24,6 @@ fi
|
||||
|
||||
cd $SCRIPT_FOLDER/
|
||||
|
||||
# 新建dyid储存目录
|
||||
if [ ! -d "$DYID_FOLDER" ]; then
|
||||
echo "create $DYID_FOLDER/"
|
||||
mkdir $DYID_FOLDER
|
||||
else
|
||||
echo "$DYID_FOLDER/ exists"
|
||||
fi
|
||||
|
||||
# 新建环境变量设置文件
|
||||
if [ ! -f "$ENV_FILE" ]; then
|
||||
echo "create $ENV_FILE"
|
||||
@@ -58,7 +48,6 @@ echo -e "#!/bin/bash\n\
|
||||
docker run \
|
||||
-v $PWD/$ENV_FILE:/lottery/$ENV_FILE \
|
||||
-v $PWD/$CONFIG_FILE:/lottery/$CONFIG_FILE \
|
||||
-v $PWD/$DYID_FOLDER/:/lottery/$DYID_FOLDER/ \
|
||||
$DOCKER_REPO \
|
||||
start" \
|
||||
> start.sh
|
||||
@@ -69,7 +58,6 @@ echo -e "#!/bin/bash\n\
|
||||
docker run \
|
||||
-v $PWD/$ENV_FILE:/lottery/$ENV_FILE \
|
||||
-v $PWD/$CONFIG_FILE:/lottery/$CONFIG_FILE \
|
||||
-v $PWD/$DYID_FOLDER/:/lottery/$DYID_FOLDER/ \
|
||||
$DOCKER_REPO \
|
||||
check" \
|
||||
> check.sh
|
||||
@@ -80,7 +68,6 @@ echo -e "#!/bin/bash\n\
|
||||
docker run \
|
||||
-v $PWD/$ENV_FILE:/lottery/$ENV_FILE \
|
||||
-v $PWD/$CONFIG_FILE:/lottery/$CONFIG_FILE \
|
||||
-v $PWD/$DYID_FOLDER/:/lottery/$DYID_FOLDER/ \
|
||||
$DOCKER_REPO \
|
||||
clear" \
|
||||
> clear.sh
|
||||
|
||||
+13
-4
@@ -7,12 +7,20 @@ $ENV_FILE = "env.js"
|
||||
|
||||
$TARGET_DIR = ".\dist"
|
||||
|
||||
$NAME = 'lottery-auto-script'
|
||||
|
||||
$TRIARR = @(
|
||||
@("lottery-in-bili-win.exe", "lottery.exe", "nlts-win-x64"),
|
||||
@("lottery-in-bili-linux", "lottery", "nlts-linux-x64"),
|
||||
@("lottery-in-bili-macos", "lottery", "nlts-macos-x64")
|
||||
@("$NAME-win.exe", "lottery.exe", "nlts-win-x64"),
|
||||
@("$NAME-linux", "lottery", "nlts-linux-x64"),
|
||||
@("$NAME-macos", "lottery", "nlts-macos-x64")
|
||||
)
|
||||
|
||||
if((Test-Path $TARGET_DIR) -eq "True") {
|
||||
Remove-Item -Path $TARGET_DIR -Recurse
|
||||
}
|
||||
|
||||
npx pkg .
|
||||
|
||||
Copy-Item -Path $TEMPLATE_ENV_FILE -Destination $TARGET_DIR -Force
|
||||
Copy-Item -Path $TEMPLATE_CONFIG_FILE -Destination $TARGET_DIR -Force
|
||||
Copy-Item -Path $README -Destination $TARGET_DIR -Force
|
||||
@@ -38,9 +46,10 @@ foreach ($TRI in $TRIARR) {
|
||||
New-Item -Path $DIR -Name "start.bat" -ItemType File -Value "@echo off && lottery start && pause" -Force
|
||||
New-Item -Path $DIR -Name "check.bat" -ItemType File -Value "@echo off && lottery check && pause" -Force
|
||||
New-Item -Path $DIR -Name "clear.bat" -ItemType File -Value "@echo off && lottery clear && pause" -Force
|
||||
New-Item -Path $DIR -Name "update.bat" -ItemType File -Value "@echo off && lottery update && pause" -Force
|
||||
}
|
||||
|
||||
Compress-Archive -Path $DIR -DestinationPath "$($DIR)-$(Get-Date -Format "yyyyMMd")" -Force
|
||||
Compress-Archive -Path $DIR -DestinationPath $DIR -Force
|
||||
}
|
||||
|
||||
Remove-Item -Path $ENV_FILE
|
||||
|
||||
Reference in New Issue
Block a user