Compare commits

..
63 Commits
Author SHA1 Message Date
shanmite 2ff4ec812b docs: 更新CHANGELOG 2021-12-11 18:24:38 +08:00
shanmite 20c423fc09 fix: "公共黑名单"显示错误(#87) 2021-12-11 18:21:37 +08:00
shanmite 6851f29f75 fix: 描述中出现undefined(#88) 2021-12-11 18:18:43 +08:00
shanmite 77d198bec5 docs: 更新CHANGELOG 2021-12-10 15:21:26 +08:00
shanmite 0ba6acec31 feat: check_if_duplicated可同时使用多种方式 2021-12-10 15:16:17 +08:00
shanmite dd994263b9 fix: 只转已关注功能失效 2021-12-10 14:50:41 +08:00
shanmite 12847d7cfc docs: 更新CHANGELOG 2021-12-06 16:26:56 +08:00
shanmite 01562b6ee0 ci: verison升级时小版本号归0 2021-12-06 16:26:11 +08:00
shanmite 90ac347ff2 docs: 更新README 2021-12-06 16:14:59 +08:00
shanmite 3cf3939b49 feat: 新增设置check_if_duplicated
检查是否重复转发
- 不检查 -1
- 通过是否点赞判断 0
- 检索本地dyids文件 1
2021-12-06 16:12:41 +08:00
shanmite d0a8aa9169 feat: metainfo显示nodejs版本号 2021-12-05 20:12:47 +08:00
shanmite 10db52f9ae fix: 完善错误延时重试(#82)
- 成功 0
- 评论 未知错误 1001
- 评论 原动态已删除 1002
- 评论 评论区已关闭 1003
- 评论 需要输入验证码 1004
- 评论 已被对方拉入黑名单 1005
- 评论 黑名单用户无法互动 1006
- 评论 UP主已关闭评论区 1007
- 关注 未知错误 2001
- 关注 您已被对方拉入黑名单 2002
- 关注 黑名单用户无法关注 2003
- 关注 账号异常 2004
- 关注 关注已达上限 2005
- 分区 移动失败 3001
- 点赞 未知错误 4001
- 点赞 点赞异常 4002
- 点赞 点赞频繁 4003
- 转发 未知错误 5001
- 转发 该动态不能转发分享 5002
- 转发 请求数据发生错误,请刷新或稍后重试 5003
- 转发 操作太频繁了,请稍后重试 5004
2021-12-05 19:56:50 +08:00
shanmite f9ebbb30eb docs: 更新CHANGELOG 2021-12-03 19:16:39 +08:00
shanmite b36c555c13 ci: auto gen changelog 2021-12-03 19:15:34 +08:00
shanmite 7338e09caf feat: 更新notice_key_words
更新屏蔽通知词
"~你的账号在新设备或平台登录成功",
"~你预约的直播已开始"
2021-12-03 18:46:28 +08:00
shanmite 80a54e87f8 ci: *.exe latest_version0 2021-12-03 15:49:17 +08:00
shanmite 1a6291471a feat: 新增设置is_outof_maxfollow(#80)
关注已达上限时自动切换
2021-12-03 15:29:21 +08:00
shanmite 449c8d9272 docs: update README 2021-12-02 21:53:27 +08:00
shanmite 136379a3aa docs: 更新CHANGELOG 2021-12-02 19:47:00 +08:00
shanmite 313942adb7 ci: pkg.yml tag_name 2021-12-02 19:40:08 +08:00
shanmite 66efd62d56 feat: 新增设置use_public_blacklist 2021-12-02 19:29:26 +08:00
shanmite d7cf7422f4 feat: 增加粉丝数查询第三方接口 2021-12-02 19:18:51 +08:00
shanmite 094e019063 fix: 二级转发带有效抽奖 2021-12-02 19:07:43 +08:00
shanmite 8de74537f7 fix: description获取不到 2021-12-02 18:51:59 +08:00
shanmite 70c10f247b fix: 更改默认设置key_words blockword 2021-12-02 18:50:41 +08:00
shanmite 2f26a393ca feat: 源uid参与筛选判断
- 重构筛选处关于uid的逻辑
- debug日志详细化
2021-12-02 17:53:49 +08:00
shanmite a19739d2d8 docs: 更新CHANGELOG 2021-12-01 20:39:00 +08:00
shanmite 50e18e2772 feat: 下载更新时有多个版本 2021-12-01 20:30:18 +08:00
shanmite b9c73bda96 chore: change docker auto build 2021-12-01 20:08:38 +08:00
shanmite 608b1fb83e pref: 增加筛选时日志输出(#79) 2021-12-01 19:26:50 +08:00
shanmite 07ef8dfb2e chore: 移植并完善自动化构建脚本 2021-12-01 18:48:52 +08:00
shanmite 6b09e26cbf chore: update docker init.sh
see stackoverflow why-docker-run-creates-new-container-every-time
2021-11-30 16:19:16 +08:00
shanmite 7babd5780b docs: about docker 2021-11-29 20:28:52 +08:00
shanmite 8b57a85476 chore: pkg build 2021-11-29 16:09:39 +08:00
shanmite c85ea6bc77 docs: 更新CHANGELOG 2021-11-29 15:49:16 +08:00
shanmite eae72dbdd7 feat: minfollower填0可关闭本地粉丝数筛选 2021-11-28 21:33:15 +08:00
shanmite 111602f248 perf: 日志显示是否转发过 2021-11-28 20:04:45 +08:00
shanmite d366e252e9 fix: 转发动态时非限制性错误码(#72)
```json
{
  "code":2201116,
  "msg":"请求数据发生错误,请刷新或稍后重试",
  "message":"请求数据发生错误,请刷新或稍后重试",
  "data":{}
}
```
2021-11-27 15:14:25 +08:00
shanmite 40dcc5f879 docs: 更新CHANGELOG 2021-11-17 16:49:04 +08:00
shanmite 8c0d96afc6 refactor: 检测是否已经发送过随机动态(#71)
* 优化随机动态发送逻辑
* 修复随机动态的部分bug
2021-11-17 16:42:17 +08:00
shanmite 09b6db4f8b feat: 新增设置check_session_pages(#66)
获取私信页数
- check_session_pages
- 默认16
2021-11-17 15:36:54 +08:00
shanmite 24e16ed8bc fix: 多帐号使用默认设置初始化(#70) 2021-11-17 15:20:43 +08:00
shanmite fabe9f7d6e docs: 更新CHANGELOG 2021-11-09 19:13:32 +08:00
jkluio78andshanmite 1962d97bc1 fix: 过滤专栏时间失效(#67) 2021-11-09 19:04:07 +08:00
shanmite c43ab13790 docs: 更新CHANGELOG 2021-11-08 16:04:13 +08:00
shanmite 11625b3850 feat: 检索专栏时能够根据发布时间进行过滤(#65) 2021-11-08 15:40:10 +08:00
shanmite 8c7a6d13d6 fix: 多帐号设置未更新
未填写对应的config_n导致沿用之前的设置
2021-11-08 11:31:43 +08:00
shanmiteko c2bd7b15ee docs: 更新CHANGELOG 2021-11-06 15:44:42 +08:00
shanmiteko b4c7a83f57 docs: 更新README 2021-11-06 15:16:50 +08:00
shanmiteko 72b07a0f45 chore: 暂时去除打包到arm
see https://github.com/vercel/pkg-fetch/issues
2021-11-06 11:24:42 +08:00
shanmiteko 4accd2df2b fix: 根据点赞去重(#64) 2021-11-06 11:06:38 +08:00
shanmiteko d1c2c61626 fix: 无法打包pkg_armv7
未找到解决办法,暂时去除打包到armv7
see https://github.com/vercel/pkg/issues/310
2021-11-06 11:04:43 +08:00
shanmiteko 6b0971170e feat: 获取和储存整理好的动态信息(#64)
具体要求见config.example.js
2021-11-04 22:46:26 +08:00
shanmiteko a6410df3cf docs: 更新CHANGELOG 2021-10-31 10:38:12 +08:00
shanmiteko 25811f20a0 fix: 该动态不能转发分享(#60) 2021-10-31 10:11:29 +08:00
shanmiteko 778d8e5ef1 fix: 发布的动态内容未序列化(#47) 2021-10-21 12:33:13 +08:00
shanmiteko 156c31a3f5 docs: 更新CHANGELOG 2021-10-20 19:33:05 +08:00
shanmiteko 051a181210 feat: 私信检查所有未读消息 2021-10-20 19:21:52 +08:00
shanmiteko e8b9e05a65 fix: 推送空消息 2021-10-20 16:14:04 +08:00
shanmiteko e298970d3f docs: 更新CHANGELOG 2021-10-20 16:05:02 +08:00
shanmiteko 1eaa188374 feat: 检查动态创建时间(#57)(#58) 2021-10-20 16:00:45 +08:00
shanmiteko b36d24a4d8 feat(check): 简单整理(#56) 2021-10-18 16:19:51 +08:00
shanmiteko 3b73d6a2f5 fix(clear): 非转发动态无源用户(#54) 2021-10-18 15:49:45 +08:00
30 changed files with 1532 additions and 594 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
**/**
!lib/
!package*
!package.json
!main.js
+3 -1
View File
@@ -60,9 +60,11 @@ body:
attributes:
label: "运行日志"
description: |
控制台日志
控制台日志,请用md代码格式上传,日志内容过多时请上传文件
placeholder: |
```
请在此黏贴运行日志。
```
- id: system
type: input
+11 -23
View File
@@ -6,35 +6,23 @@ on:
- main
paths:
- "lib/**"
- "main.js"
pull_request:
branches:
- main
paths:
- "lib/**"
- "main.js"
- "*.js"
- "*.json"
workflow_dispatch:
jobs:
path-context:
docker:
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:
- name: Build and push
env:
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
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
+16 -57
View File
@@ -1,50 +1,17 @@
name: "Package Node.js project into an executable"
on:
push:
branches:
- main
paths:
- "lib/**"
- "main.js"
pull_request:
branches:
- main
paths:
- "lib/**"
- "main.js"
- "*.js"
- "*.json"
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/
- name: "Upload to artifact(linux)"
uses: actions/upload-artifact@v2
with:
name: nlts-linux-x64
path: dist/nlts-linux-x64/
- name: "Upload to artifact(macos)"
uses: actions/upload-artifact@v2
with:
name: nlts-macos-x64
path: dist/nlts-macos-x64/
pkg_arm64:
build_all:
runs-on: ubuntu-latest
steps:
- name: "Checkout codes"
@@ -55,28 +22,20 @@ jobs:
node-version: "16"
- name: "Pkg this"
run: |
sudo apt install zip unzip
npm install
npm run pkg_arm64
npm run build_all
- name: "Upload to artifact"
uses: actions/upload-artifact@v2
with:
name: nlts-linux-arm64
name: all_platform
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
- name: "Upload to release draft"
uses: xresloader/upload-to-github-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
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/
file: "dist/*.zip"
delete_file: "dist/*.zip"
tag_name: "v*.*.*"
overwrite: true
+3
View File
@@ -1,6 +1,9 @@
node_modules/
.vscode/
tests/
dyids/
dist/
*.log
package-lock.json
env.js
my_config.js
+314 -53
View File
@@ -1,8 +1,134 @@
## 主要变化(2.2.7)
## 问题修复
- 未移动分区(#50)
- 修改线路切换逻辑
<!-- markdownlint-disable MD036 MD024-->
# CHANGELOG
## 主要变化(2.4.2)
* 20c423f fix: "公共黑名单"显示错误(#87)
* 6851f29 fix: 描述中出现undefined(#88)
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
## 主要变化(2.4.1)
* 0ba6ace feat: check_if_duplicated可同时使用多种方式
* dd99426 fix: 只转已关注功能失效
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
## 主要变化(2.4.0)
* 01562b6 ci: verison升级时小版本号归0
* 90ac347 docs: 更新README
* 3cf3939 feat: 新增设置`check_if_duplicated`
* d0a8aa9 feat: metainfo显示nodejs版本号
* 10db52f fix: 完善错误延时重试(#82)
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
## 主要变化(2.3.9)
* b36c555 ci: auto gen changelog
* 7338e09 feat: 更新`notice_key_words`
* 80a54e8 ci: `*.exe` `latest_version0`
* 1a62914 feat: 新增设置`is_outof_maxfollow`(#80)
* 449c8d9 docs: update README
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
## 主要变化(2.3.8)
* 313942a ci: pkg.yml tag_name
* 66efd62 feat: 新增设置`use_public_blacklist`
* d7cf742 feat: 增加粉丝数查询第三方接口
* 094e019 fix: 二级转发带有效抽奖
* 8de7453 fix: description获取不到
* 70c10f2 fix: 更改默认设置`key_words` `blockword`
* 2f26a39 feat: 源uid参与筛选判断
## 较上一版本变化
* 变更可执行文件
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.3.7...v2.3.8
## 主要变化(2.3.7)
* 50e18e2 feat: 下载更新时有多个版本
* b9c73bd chore: change docker auto build
* 608b1fb pref: 增加筛选时日志输出(#79)
* 07ef8df chore: 移植并完善自动化构建脚本
* 6b09e26 chore: update docker init.sh
* 7babd57 docs: about docker
* 8b57a85 chore: pkg build
## 较上一版本变化
* 变更可执行文件
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.3.6...v2.3.7
## 主要变化(2.3.6)
* eae72db feat: minfollower填0可关闭本地粉丝数筛选
* 111602f perf: 日志显示是否转发过
* d366e25 fix: 转发动态时非限制性错误码(#72)
## 较上一版本变化
* 变更可执行文件
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.3.5...v2.3.6
## 主要变化(2.3.5)
* 8c0d96a refactor: 检测是否已经发送过随机动态(#71)
* 09b6db4 feat: 新增设置`check_session_pages`(#66)
## 较上一版本变化
* 变更可执行文件
* [my_config.js](my_config.example.js)增加
- `check_session_pages` - 检查私信页数
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.3.4...v2.3.5
## 主要变化(2.3.4)
* 1962d97 fix: 过滤专栏时间失效(#67)
## 较上一版本变化
只变更可执行文件
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.3.2...v2.3.4
## 主要变化(2.3.3)
* 11625b3 feat: 检索专栏时能够根据发布时间进行过滤(#65)
* 8c7a6d1 fix: 多帐号设置未更新
## 较上一版本变化
[my_config.js](my_config.example.js)增加
* `article_create_time` - 专栏创建时间距离现在的最大天数
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.3.2...v.2.3.3
## 主要变化(2.3.2)
* b4c7a83 docs: 更新README
* 72b07a0 chore: 暂时去除打包到arm
* 4accd2d fix: 根据点赞去重(#64)
* d1c2c61 fix: 无法打包pkg_armv7
* 6b09711 feat: 获取和储存整理好的动态信息(#64)
## 较上一版本变化
[my_config.js](my_config.js)增加
* `APIs` - 获取抽奖信息的链接字符串
* `set_lottery_info_url` - 上传抽奖信息的链接字符串
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.3.1...v2.3.2
## 主要变化(2.3.1)
## 问题修复
- 该动态不能转发分享(#60)
- 发布的动态内容未序列化(#47)
## 较上一版本变化
- `env.js`
- `my_config.js`
@@ -10,13 +136,87 @@
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.2.6...v2.2.7
**Full Changelog**: <https://github.com/shanmiteko/LotteryAutoScript/compare/v2.3.0...v2.3.1>
## 主要变化(2.3.0)
- 私信检查所有未读消息
## 较上一版本变化
- `env.js`
- `my_config.js`
**替换可执行文件**
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
**Full Changelog**: <https://github.com/shanmiteko/LotteryAutoScript/compare/v2.2.9...v2.3.0>
## 主要变化(2.2.9)
- 检查动态创建时间(#57)(#58)
- 简单整理(#56)
## 问题修复
- 非转发动态无源用户(#54)
## 较上一版本变化
- `env.js`
- `my_config.js`增加`max_create_time`
**替换可执行文件和更改配置文件(建议修改)**
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
**Full Changelog**: <https://github.com/shanmiteko/LotteryAutoScript/compare/v2.2.8...v2.2.9>
## 主要变化(2.2.8)
- 遇到过期的cookie跳过(#51)
## 问题修复
- UP关闭评论区(#52)
## 较上一版本变化
- `env.js`
- `my_config.js`
**替换可执行文件**
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
**Full Changelog**: <https://github.com/shanmiteko/LotteryAutoScript/compare/v2.2.7...v2.2.8>
## 主要变化(2.2.7)
## 问题修复
- 未移动分区(#50)
- 修改线路切换逻辑
## 较上一版本变化
- `env.js`
- `my_config.js`
**替换可执行文件**
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
**Full Changelog**: <https://github.com/shanmiteko/LotteryAutoScript/compare/v2.2.6...v2.2.7>
## 主要变化(2.2.6)
- LOG日志显示随机动态内容(#47)
- 增加设置过滤间隔
## 较上一版本变化
- `env.js`
- `my_config.js`增加`filter_wait`
@@ -24,13 +224,16 @@ _如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.2.5...v2.2.6
**Full Changelog**: <https://github.com/shanmiteko/LotteryAutoScript/compare/v2.2.5...v2.2.6>
## 主要变化(2.2.5)
## 问题修复
- 因黑名单而关注失败(#45)
## 较上一版本变化
- `env.js`
- `my_config.js`
@@ -39,38 +242,46 @@ _如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.2.4...v2.2.5
**Full Changelog**: <https://github.com/shanmiteko/LotteryAutoScript/compare/v2.2.4...v2.2.5>
## 主要变化(2.2.4)
- api线路切换具有记忆功能
- 增加更多时延自定义值(#44)
- 重构部分代码
- 内置默认设置
## 问题修复
- 清理动态时关注列表获取失败
## 较上一版本变化
- `env.js`
- `my_config.js`增加
- `get_session_wait` 读取下一页私信间隔
- `update_session_wait` 已读私信间隔
- `get_partition_wait` 读取下一页关注列表间隔
- `get_dynamic_detail_wait` 获取动态细节间隔
- `random_dynamic_wait` 随机动态间隔
- `random_dynamic_wait` 随机动态间隔
**替换可执行文件和更改配置文件(建议修改)**
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.2.3...v2.2.4
**Full Changelog**: <https://github.com/shanmiteko/LotteryAutoScript/compare/v2.2.3...v2.2.4>
## 主要变化(2.2.3)
- clear_dynamic_type类型可以多选(#42)
## 问题修复
- 番剧动态无user_profile(#41)
## 较上一版本变化
- `env.js`
- `my_config.js`修改`clear_dynamic_type`
@@ -79,12 +290,14 @@ _[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.2.2...v2.2.3
**Full Changelog**: <https://github.com/shanmiteko/LotteryAutoScript/compare/v2.2.2...v2.2.3>
## 主要变化(2.2.2)
- 随机转发热门视频(#40)
## 较上一版本变化
- `env.js`
- `my_config.js`增加`create_dy_mode` `create_dy_type`
@@ -93,13 +306,14 @@ _[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.2.1...v2.2.2
**Full Changelog**: <https://github.com/shanmiteko/LotteryAutoScript/compare/v2.2.1...v2.2.2>
## 主要变化(2.2.1)
- 动态不存在时出错(#39)
## 较上一版本变化
- `env.js`
- `my_config.js`
@@ -108,13 +322,15 @@ _[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.2.0...v2.2.1
**Full Changelog**: <https://github.com/shanmiteko/LotteryAutoScript/compare/v2.2.0...v2.2.1>
## 主要变化(2.2.0)
- 修改转发验重逻辑
- 可间隔插入随机动态(#33)
## 较上一版本变化
- `env.js`
- `my_config.js`增加create_dy_mode
@@ -123,10 +339,12 @@ _[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化(2.1.8)
- 设置支持热更新(#29)
## 较上一版本变化
- `env.js`文件格式更改
- `my_config.js`文件格式更改
@@ -135,10 +353,12 @@ _[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化(2.1.7)
- 设置支持热更新(#29)
## 较上一版本变化
- `env.js`文件格式更改
- `my_config.js`
@@ -147,10 +367,12 @@ _[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化(2.1.6)
- 新增设置not_check_article(#25)
## 较上一版本变化
- `env.js`
- `my_config.js`新增设置not_check_article
@@ -159,10 +381,12 @@ _[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化(2.1.5)
- 修复之前无法更新的问题
## 较上一版本变化
- `env.js`
- `my_config.js`
@@ -171,10 +395,12 @@ _[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化(2.1.4)
- 黑名单处理(#22)
## 较上一版本变化
- `env.js`
- `my_config.js`
@@ -183,10 +409,12 @@ _[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化(2.1.3)
- 错误码变更(#20)
- 错误码变更(#20)
## 较上一版本变化
- `env.js`
- `my_config.js`
@@ -195,12 +423,14 @@ _[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化(2.1.2)
- 支持arm平台运行
- 改变账号异常应对策略
- 修改dingtalk签名base64问题(#17)
## 较上一版本变化
- `env.js`
- `my_config.js`
@@ -209,10 +439,12 @@ _[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化(2.1.1)
- 获取未读私信接口变化
## 较上一版本变化
- `env.js`
- `my_config.js`
@@ -221,10 +453,12 @@ _[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化(2.1.0)
- 修复两处问题
## 较上一版本变化
- `env.js`
- `my_config.js`
@@ -233,10 +467,12 @@ _[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化(2.0.9)
- 账号异常自动切换线路(#14)
## 较上一版本变化
- `env.js`
- `my_config.js`
@@ -245,10 +481,12 @@ _[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化(2.0.8)
- 账号异常时未处理和发送通知
## 较上一版本变化
- `env.js`
- `my_config.js`
@@ -257,11 +495,13 @@ _[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化(2.0.7)
- 修复一处问题
- 日志时间UTC+8(#13)
## 较上一版本变化
- `env.js`
- `my_config.js`
@@ -270,11 +510,13 @@ _[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化
- 支持更新检查
- 增加设置`update_loop_wait`
## 较上一版本(v2.0.5)变化
- `env.js`
- `my_config.js`增加设置`update_loop_wait`
@@ -282,72 +524,91 @@ _[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
_如果之前版本小于2.0.5,请查看历次更新说明_
## 主要变化
- 不参与主站黑名单用户抽奖
- my_config.js注释修改
- 可从环境变量中读取COOKIE
- 其他不影响功能的调整
## 较上一版本(v2.0.4)变化
- `env.js`
- `my_config.js`
**仅需替换可执行文件**
## 新特性
中奖通知设置可设黑名单
## 较上一版本(v2.0.3)变化
`env.js`
`my_config.js`
**仅需替换可执行文件**
## 问题修复
- 评论失败未退出
- 切割tag不精准
## 较上一版本(v2.0.2)变化
`env.js`
`my_config.js`
**仅需替换可执行文件**
edit: 替换release
## 问题修复
#9
# 9
## 较上一版本(2.0.1)变化
`env.js`
`my_config.js`
**仅需替换可执行文件**
## 新增特性
增加两处自定义设置(`my_config.js`)
- `clear_quick_remove_attention`
- `notice_key_words`
## 问题修复
#7
# 7
## 较上一版本(2.0.0)变化
`env.js`
`my_config.js`需修改添加两处自定义设置
除了替换可执行文件,还要修改`my_config.js`文件
## 新增特性
打乱将转发的动态顺序,防止被人认出是抽奖号
## 问题修复
修复两处潜在bug
## 较上一版本(1.9.9)变化
`env.js`
`my_config.js`
只需替换可执行文件
## 优化体验
清理动态时日志更详细
以及其他细节处理
## 较上一版本(1.9.8)变化
`env.js`
`my_config.js`
只需替换可执行文件
@@ -355,44 +616,50 @@ edit: 替换release
edit: 1.9.9.1
edit: 1.9.9.2
## 修复Bug
两级解构时第一级为undefined(表现为异常退出)
## 较上一版本(1.9.7)变化
`env.js`更改注释内容
`my_config.js`
只需替换可执行文件
## 修复Bug
转发专栏内的抽奖时无法获取关注
## 较上一版本(1.9.6)变化
`env.js`
`my_config.js`
只需替换可执行文件
## 主要变化(1.9.6)
去除对unzipper的依赖
专栏转发率达一半以上时跳过
## 较上一版本变更
`env.js`
`my_config.js`
只需替换可执行文件
## 主要新增功能(1.9.5)
可从专栏里获取抽奖动态
## 较上一版本变更
`env.js`无变化
`my_config.js`去掉部分设置,新增部分设置
## 1.9.0
修复Bug后的稳定版(大概
- 21/7/21 附加bat脚本增加对小白的友好性
## 1.8
@@ -405,7 +672,6 @@ change 修复一处bug
change 重新上传zip
change 重新上传zip
## 1.6
perf: 重构代码
@@ -418,8 +684,6 @@ feat:
- 滤除的dyid也进行存储
fix: 修复部分bug
## 1.5
feat: 日志相关
@@ -427,7 +691,7 @@ feat: 日志相关
- 彩色输出
- 环境变量LOTTERY_LOG_LEVEL更改日志等级
feat: 设置相关
- lottery_loop_wait 抽奖循环
- lottery_loop_wait 抽奖循环
- check_loop_wait 检奖循环
- clear_loop_wait 清理循环
@@ -439,13 +703,10 @@ fix: 部分动态无法获取描述
feat: 新增loop_wait设置
可执行文件压缩包
# 命令行工具
可执行文件压缩包
可执行文件压缩包
可执行文件压缩包
+2 -5
View File
@@ -1,13 +1,10 @@
# Latest Nodejs + Alpine Linux
FROM node:lts-alpine
MAINTAINER [email protected]
LABEL version="1.0" description="自动参与B站动态抽奖"
LABEL author="shanmite" version="1.1" description="自动参与B站动态抽奖"
WORKDIR /lottery
COPY ["package.json", "package*.json", "./"]
COPY ["package.json", "./"]
RUN npm install
+68 -48
View File
@@ -1,4 +1,5 @@
# AutoScript
- [AutoScript](#autoscript)
- [操作步骤](#操作步骤)
- [获取COOKIE](#获取cookie)
@@ -8,11 +9,12 @@
- [Windows](#windows)
- [Linux](#linux)
- [Docker](#docker)
- [防重复转发](#防重复转发)
- [防重复转发(可选)](#防重复转发可选)
- [检测中奖](#检测中奖)
- [检测未读信息, 已读未读信息](#检测未读信息-已读未读信息)
- [中奖推送(可选)](#中奖推送可选)
- [设置说明](#设置说明)
- [Awesome](#awesome)
[Github仓库链接](https://github.com/shanmiteko/LotteryAutoScript)
@@ -21,6 +23,7 @@
[![Publishing to NPM](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/npmp.yml/badge.svg)](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/npmp.yml)
已实现功能:
- 监控用户转发
- 监控话题页面
- 监控专栏合集
@@ -71,7 +74,7 @@ Chrome浏览器:
.join('; ')
.split()
.forEach(it => copy(it) || console.log(it))
```
```
也可以采用**其他方式获取**所需的Cookie
@@ -84,7 +87,9 @@ Chrome浏览器:
### 本地运行
#### 可执行文件
1. [[下载](https://github.com/shanmiteko/LotteryAutoScript/releases)|[cnpmjs镜像下载](https://github.com.cnpmjs.org/shanmiteko/LotteryAutoScript/releases)|[Fastgit镜像下载](https://hub.fastgit.org/shanmiteko/LotteryAutoScript/releases)]压缩包并解压后
```
~/nlts-linux-x64
=> tree
@@ -94,10 +99,12 @@ Chrome浏览器:
├── my_config.js (自定义设置文件) (!使用前必读)
└── README.md (说明文件)
```
2. 用记事本或其他编辑器修改`env.js`和`my_config.js`文件(右键选择用记事本打开)
3. 在`env.js`中填入`COOKIE`和推送参数
4. 在`my_config.js`中自定义设置
5. 在当前目录下**打开终端**运行可执行文件`lottery`(勿直接点击`lottery`)
```sh
# unix-like
## 进入脚本所在目录
@@ -117,6 +124,7 @@ Chrome浏览器:
## 把`./`换成`.\`或去掉
## 已自带*.bat可直接点击
```
7. 运行截图
![lottery_start](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/lottery_start.png)
@@ -183,65 +191,69 @@ npm i && npm run clear
脚本已内置定时运行功能
##### Linux
[linux系统配置与定时运行](./doc/linux_schedule.md)
</details>
### Docker
1.初始化
```bash
$ curl -fsSL https://cdn.staticaly.com/gh/shanmiteko/LotteryAutoScript/main/script/docker/init.sh | sh
curl -fsSL https://cdn.staticaly.com/gh/shanmiteko/LotteryAutoScript/main/script/docker/init.sh | sudo sh
```
进入`lottery`文件夹
```bash
$ cd lottery
cd lottery
```
编辑`env.js`与`my_config.js`文件
- env.js 设置必要环境变量
- my_config.js 你的设置
执行相应的脚本
> start,check,clear
例如:
```bash
$ ./start.sh
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
```
2.更新
[![asciicast](https://asciinema.org/a/453237.svg)](https://asciinema.org/a/453237)
3.更新
进入lottery上一级目录
使用与初始化相同的命令
3.卸载
进入lottery上一级目录
```bash
$ docker image rm -f shanmite/lottery_auto_docker
$ rm -rf lottery/
```
----------------------------------------
## 防重复转发
~~存储在专栏草稿~~
## 防重复转发(可选)
~~脚本将转发过的动态和被过滤的动态都写入`dyids/dyid*.txt`文件中~~
是否点赞
- 脚本将转发过的动态和被过滤的动态都写入`dyids/dyid*.txt`文件中
- 是否点赞
----------------------------------------
## 检测中奖
### 检测未读信息, 已读未读信息
判断依据
- 通过`@`信息判断
- 通过私信判断
@@ -249,37 +261,45 @@ $ rm -rf lottery/
关键词有限 可能会有**漏掉**的或**误报**
### 中奖推送(可选)
> 填写在env.js内
以下是支持的推送方式
| 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`默认为一对一推送 |
| `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://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`默认为一对一推送 |
| `SMTP_HOST` | 电子邮件 | 非必须 | smtp服务器的主机名 如: `smtp.qq.com` |
| `SMTP_PORT` | 电子邮件 | 非必须 | smtp服务器的端口 如: `465` |
| `SMTP_USER` | 电子邮件 | 非必须 | 发送方的电子邮件 如: `xxxxxxxxx@qq.com` |
| `SMTP_PASS` | 电子邮件 | 非必须 | smtp服务对应的授权码 |
| `SMTP_TO_USER` | 电子邮件 | 非必须 | 接收方电子邮件 |
----------------------------------------
## 设置说明
详见[env.example.js](./env.example.js)文件内部注释
详见[my_config.example.js](./my_config.example.js)文件内部注释
## Awesome
相关项目
- [LotteryAutoScript_Station](https://github.com/spiritLHL/LotteryAutoScript_Station) - @spiritLHL
- [sync_lottery](https://github.com/spiritLHL/sync_lottery) - @spiritLHL
+22 -16
View File
@@ -10,7 +10,7 @@ const bili = require('./net/bili')
async function isMe() {
let desp = '';
const
{ notice_key_words, update_session_wait, get_session_wait } = config,
{ notice_key_words, update_session_wait, get_session_wait, check_session_pages } = config,
UnreadAtNum = await bili.getUnreadAtNum(),
UnreadSessionNum = await bili.getUnreadSessionNum(),
{ follow_unread, unfollow_unread } = UnreadSessionNum || { unfollow_unread: 0, follow_unread: 0 };
@@ -19,12 +19,14 @@ async function isMe() {
const MyAtInfo = await bili.getMyAtInfo();
MyAtInfo.forEach(async AtInfo => {
const { at_time, up_uname, business, source_content, url } = AtInfo
desp += `发生时间: ${new Date(at_time * 1000).toLocaleString()} \n\n`
desp += `用户: ${up_uname} \n\n`
desp += `${business}中@了你(${global_var.get("myUID")}) \n\n`
desp += `原内容为: ${source_content} \n\n`
desp += `[直达链接](${url}) \n\n`
desp += `\n\n`
desp += '## [at]检测结果\n\n'
desp += '----------------------------------------------------------------\n\n'
desp += `发生时间: ${new Date(at_time * 1000).toLocaleString()}\n\n`
desp += `用户: ${up_uname}\n\n`
desp += `${business}中@了你(${global_var.get("myUID")})\n\n`
desp += `原内容为: ${source_content}\n\n`
desp += `[直达链接](${url})\n\n`
desp += '----------------------------------------------------------------\n\n'
});
log.info('中奖检测', '--> OK');
}
@@ -32,23 +34,27 @@ async function isMe() {
const check = async (type) => {
let session_t = '';
let MySession = await bili.getSessionInfo(type)
log.info("准备检查私信", check_session_pages + "页")
for (const index of infiniteNumber()) {
for (const Session of MySession.data) {
const { content, sender_uid, session_ts, timestamp, unread_count, talker_id, msg_seqno } = Session;
const { sender_uid, session_ts, timestamp, unread_count, talker_id, msg_seqno } = Session;
session_t = session_ts;
if (unread_count) {
bili.updateSessionStatus(talker_id, type, msg_seqno);
await delay(update_session_wait);
const content = await bili.fetch_session_msgs(talker_id, unread_count);
if (judge(content, notice_key_words)) {
desp += `发生时间: ${new Date(timestamp * 1000).toLocaleString()} \n\n`
desp += `用户: ${sender_uid} \n\n`
desp += `私信你(${global_var.get("myUID")})说: ${content} \n\n`
desp += `[直达链接](https://message.bilibili.com/#/whisper/mid${sender_uid}) \n\n`
desp += `\n\n`
desp += '## 私信检测结果\n\n'
desp += '----------------------------------------------------------------\n\n'
desp += `发生时间: ${new Date(timestamp * 1000).toLocaleString()}\n\n`
desp += `用户: ${sender_uid}\n\n`
desp += `私信你(${global_var.get("myUID")})说:\n${content}\n\n`
desp += `[直达链接](https://message.bilibili.com/#/whisper/mid${sender_uid})\n\n`
desp += '----------------------------------------------------------------\n\n'
}
await bili.updateSessionStatus(talker_id, type, msg_seqno);
await delay(update_session_wait);
}
}
if (MySession.has_more && index < 16) {
if (MySession.has_more && index < check_session_pages) {
await delay(get_session_wait);
MySession = await bili.getSessionInfo(type, session_t)
} else {
+16 -10
View File
@@ -32,7 +32,7 @@ async function getFollowList() {
* 清理动态和关注
*/
async function clear() {
const { clear_white_list, clear_max_day, clear_quick_remove_attention, clear_remove_dynamic, clear_remove_attention, clear_remove_delay, clear_dynamic_type } = config;
const { search_wait, clear_white_list, clear_max_day, clear_quick_remove_attention, clear_remove_dynamic, clear_remove_attention, clear_remove_delay, clear_dynamic_type } = config;
let success = true;
const uid_list = await getFollowList();
if (!uid_list.length) {
@@ -65,19 +65,17 @@ async function clear() {
for (const page of infiniteNumber()) {
log.info('清理动态', `开始读取第${page + 1}`);
const { allModifyDynamicResArray, offset } = await Searcher.checkAllDynamic(MY_UID, 1, 5 * 1000, next_offset);
const { allModifyDynamicResArray, offset } = await Searcher.checkAllDynamic(MY_UID, 1, search_wait, next_offset);
next_offset = offset;
for (const [index, dyinfo] of allModifyDynamicResArray.entries()) {
log.info('清理动态', `${page + 1}页中的第${index + 1}个动态`)
const { type, dynamic_id, createtime } = dyinfo || {};
const { type, dynamic_id, create_time, origin_uid } = dyinfo || {};
if (typeof type !== 'undefined'
&& clear_dynamic_type instanceof Array
? clear_dynamic_type.includes(type)
: clear_dynamic_type === type
) {
const
{ origin_uid } = dyinfo,
days_ago = (Now - createtime) / 86400;
const days_ago = (Now - create_time) / 86400;
if (days_ago > clear_max_day) {
/* 移除动态 */
@@ -96,13 +94,21 @@ async function clear() {
success = await bili.cancelAttention(origin_uid);
}
if (!success) break;
if (!success) {
log.error("清理失败", "出现错误")
break
}
/* 延时 */
await delay(clear_remove_delay);
} else {
log.info('清理动态', `已设置跳过${clear_max_day}天 当前动态发布时间: ${~~days_ago}天前`)
log.info('清理动态', `储存用户(${origin_uid})防止误删`)
before_separate.push(origin_uid)
log.info('清理动态', `已设置跳过${clear_max_day}天 当前动态(${dynamic_id})发布时间: ${~~days_ago}天前`)
if (origin_uid) {
log.info('清理动态', `储存用户(${origin_uid})防止误删`)
before_separate.push(origin_uid)
} else {
log.info('清理动态', `非转发动态`)
}
}
} else {
log.info('清理动态', `此动态类型为${type} != 要清理的动态类型${clear_dynamic_type}`)
+271 -111
View File
@@ -1,4 +1,5 @@
const { log, hasEnv, shuffle, getRandomOne, delay, try_for_each } = require('../utils');
const { log, hasEnv, shuffle, getRandomOne, delay, try_for_each, retryfn } = require('../utils');
const { send } = require('../net/http');
const bili = require('../net/bili');
const { sendNotify } = require('../helper/notify');
const event_bus = require('../helper/event_bus');
@@ -6,6 +7,7 @@ const { randomDynamic } = require('../helper/randomDynamic')
const { Searcher } = require('./searcher');
const global_var = require("../data/global_var");
const config = require("../data/config");
const d_storage = require('../helper/d_storage');
/**
* 监视器
@@ -24,6 +26,7 @@ class Monitor extends Searcher {
['UIDs', this.getLotteryInfoByUID.bind(this)],
['TAGs', this.getLotteryInfoByTag.bind(this)],
['Articles', this.getLotteryInfoByArticle.bind(this)],
['APIs', this.getLotteryInfoByAPI.bind(this)]
]);
}
/**
@@ -47,13 +50,16 @@ class Monitor extends Searcher {
case 0:
event_bus.emit('Turn_on_the_Monitor')
break;
case 11:
case 1001:
event_bus.emit('Turn_off_the_Monitor', '评论失败')
break
case 21:
break;
case 2001:
event_bus.emit('Turn_off_the_Monitor', '关注出错')
break
case 22:
break;
case 3001:
event_bus.emit('Turn_off_the_Monitor', '分区移动出错')
break;
case 2004:
log.warn('账号异常', `UID(${global_var.get('myUID')})异常号只会对部分UP出现关注异常`)
if (!config.is_exception) {
await sendNotify('[动态抽奖]账号异常通知', `UID: ${global_var.get('myUID')}\n\n异常号只会对部分UP出现关注异常\n\n可在设置中令is_exception为true关闭此推送`)
@@ -61,17 +67,26 @@ class Monitor extends Searcher {
config.is_exception = true;
event_bus.emit('Turn_on_the_Monitor')
break
case 31:
case 2005:
log.warn('关注已达上限', `UID(${global_var.get('myUID')})关注已达上限,已临时进入只转已关注模式`)
if (!config.is_outof_maxfollow) {
await sendNotify('[动态抽奖]关注已达上限', `UID: ${global_var.get('myUID')}\n\n关注已达上限,已临时进入只转已关注模式\n\n可在设置中令is_outof_maxfollow为true关闭此推送`)
}
config.is_outof_maxfollow = true;
config.only_followed = true;
event_bus.emit('Turn_on_the_Monitor')
break
case 5001:
event_bus.emit('Turn_off_the_Monitor', '转发失败')
break
case 41:
case 6001:
event_bus.emit('Turn_off_the_Monitor', '获取开奖时间失败')
break
case 51:
case 7001:
event_bus.emit('Turn_off_the_Monitor', '获取关注数失败')
break
default:
event_bus.emit('Turn_off_the_Monitor', '未知错误')
event_bus.emit('Turn_off_the_Monitor', '??? 未知错误')
break;
}
}
@@ -87,35 +102,54 @@ class Monitor extends Searcher {
log.info('筛选动态', `筛选完毕(${len})`);
if (len) {
let is_exception = false;
for (const [index, Lottery] of shuffle(allLottery).entries()) {
let
is_exception = 0,
is_outof_maxfollow = 0;
for (const [index, lottery] of shuffle(allLottery).entries()) {
let status = 0;
if (Lottery.isOfficialLottery) {
let { ts } = await bili.getLotteryNotice(Lottery.dyid);
if (
is_outof_maxfollow
&& lottery.uid.length
&& (new RegExp(lottery.uid.join('|'))).test(this.attentionList)
) {
log.info('过滤', `已关注(${lottery.uid.join(',')})`)
continue
}
if (lottery.isOfficialLottery) {
let { ts } = await bili.getLotteryNotice(lottery.dyid);
const ts_10 = Date.now() / 1000;
if (ts < 0) {
return 41
return 6001
}
if (ts < ts_10) {
log.info('过滤', '已过开奖时间')
d_storage.updateDyid(lottery.dyid)
await delay(filter_wait)
continue
}
if (ts > ts_10 + config.maxday * 86400) {
log.info('过滤', '超过指定开奖时间')
d_storage.updateDyid(lottery.dyid)
await delay(filter_wait)
continue
}
} else if (Lottery.uid[0]) {
const followerNum = await bili.getUserInfo(Lottery.uid[0]);
if (followerNum < 0) {
return 51
}
if (followerNum < config.minfollower) {
log.info('过滤', `粉丝数(${followerNum})小于指定数量`)
await delay(filter_wait)
continue
} else if (lottery.uid[0]) {
const { minfollower } = config
if (minfollower > 0) {
const followerNum = await bili.getUserInfo(lottery.uid[0]);
if (followerNum < 0) {
return 7001
}
if (followerNum < minfollower) {
log.info('过滤', `粉丝数(${followerNum})小于指定数量`)
d_storage.updateDyid(lottery.dyid)
await delay(filter_wait)
continue
}
} else {
log.info('过滤', "不过滤粉丝数")
}
}
@@ -128,27 +162,45 @@ class Monitor extends Searcher {
randomDynamic(number)
}
status = await this.go(Lottery)
status = await this.go(lottery)
switch (status) {
case 0:
case 9:
case 19:
case 1002:
case 1003:
case 1004:
case 1005:
case 1006:
case 1007:
case 2002:
case 2003:
case 4001:
case 4002:
case 4003:
case 5002:
case 5003:
case 5004:
break;
case 22:
is_exception = true
case 2004:
is_exception = 2004
break;
default:
case 2005:
is_outof_maxfollow = 2005
break;
case 1001:
case 2001:
case 3001:
case 5001:
return status
}
d_storage.updateDyid(lottery.dyid)
await delay(wait * (Math.random() + 0.5));
}
log.info('抽奖', '开始转发下一组动态');
if (is_exception) {
return 22
} else {
return 0
}
return is_exception
|| is_outof_maxfollow
|| 0
} else {
log.info('抽奖', '无未转发抽奖');
return 0
@@ -171,6 +223,9 @@ class Monitor extends Searcher {
*/
async filterLotteryInfo() {
const { lottery_param, LotteryInfoMap, attentionList } = this;
/**
* @type {import("./searcher").LotteryInfo[]}
*/
let protoLotteryInfo = await LotteryInfoMap.get(lottery_param[0])(lottery_param[1]);
if (protoLotteryInfo === null)
@@ -178,13 +233,15 @@ class Monitor extends Searcher {
log.info('筛选动态', `开始筛选(${protoLotteryInfo.length})`);
log.debug('未进行筛选的动态信息', protoLotteryInfo);
/** 所有抽奖信息 */
let alllotteryinfo = [];
const { key_words, model, chatmodel, is_imitator, only_followed, at_users, blockword, blacklist } = config;
const
{ check_if_duplicated, set_lottery_info_url, key_words, model, chatmodel, max_create_time, is_imitator, only_followed, at_users, blockword, blacklist, use_public_blacklist } = config,
now_ts = Date.now() / 1000;
/**Map<String, Boolean> */
/**
* @type {Map<String, Boolean>}
*/
let dyids_map = new Map();
/**去重 */
@@ -196,48 +253,125 @@ class Monitor extends Searcher {
return true
});
log.info('筛选动态', `去重后(${protoLotteryInfo.length})`);
/**并发查询dyid */
if (check_if_duplicated === 1 || check_if_duplicated === 2) {
await Promise.all(
[...dyids_map.keys()]
.map(it => d_storage
.searchDyid(it)
.then(hasIt => dyids_map.set(it, hasIt))
)
)
log.info('筛选动态', `并发查询本地dyid完毕`);
}
if (lottery_param[0] !== "APIs" && set_lottery_info_url && protoLotteryInfo.length) {
log.info("上传抽奖信息", "开始")
await new Promise((resolve) => {
send({
url: set_lottery_info_url,
method: "POST",
headers: {
"content-type": "application/json"
},
contents: protoLotteryInfo,
success: ({ body }) => {
log.info("发送获取到的动态数据", body)
resolve()
},
failure: err => {
log.error("发送获取到的动态数据", err)
resolve()
}
})
})
}
/* 检查动态是否满足要求 */
await try_for_each(protoLotteryInfo, async function ({
lottery_info_type, is_liked,
uids, uname, dyid,
ctrl, rid, des, type,
hasOfficialLottery
}) {
await try_for_each(protoLotteryInfo, async function (lottery_info) {
const {
lottery_info_type, is_liked,
uids, uname, dyid, create_time,
ctrl, rid, des, type,
hasOfficialLottery
} = lottery_info;
log.debug('正在筛选的动态信息', lottery_info);
/* 遇到转发过就退出 */
if (is_liked) return false;
if (
((!check_if_duplicated || check_if_duplicated === 2)
&& is_liked)
|| ((check_if_duplicated === 1 || check_if_duplicated === 2)
&& dyids_map.get(dyid))
) {
log.info("筛选动态", `已转发(https://t.bilibili.com/${dyid})`)
return false
}
/* 超过指定时间退出 */
if (now_ts - create_time > max_create_time * 86400) {
log.info("筛选动态", `过时动态(https://t.bilibili.com/${dyid})`)
return false
}
const
/**判断是转发源动态还是现动态 */
uid = lottery_info_type === 'uid' ? uids[1] : uids[0],
isFollowed = (new RegExp(uid)).test(attentionList),
description = typeof des === 'string' ? des : '',
[m_uid, ori_uid] = uids,
mIsFollowed = !m_uid || (new RegExp(m_uid)).test(attentionList),
oriIsFollowed = !ori_uid || (new RegExp(ori_uid)).test(attentionList),
/**判断是转发源动态还是现动态 实际发奖人*/
[real_uid, realIsFollowed] = lottery_info_type === 'uid'
? [ori_uid, oriIsFollowed]
: [m_uid, mIsFollowed],
description = des.split(/\/\/@.*?:/)[0],
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),
|| (!hasOfficialLottery && model[1] === '1' && has_key_words),
isSendChat =
(is_imitator && lottery_info_type === 'uid' && chatmodel !== '00')
|| (hasOfficialLottery && chatmodel[0] === '1')
|| (!hasOfficialLottery && chatmodel[1] === '1');
log.debug("筛选动态", { real_uid, mIsFollowed, oriIsFollowed, realIsFollowed, needAt, needTopic, isRelayDynamic, key_words, has_key_words, blockword, isBlock, isLottery, isSendChat })
/**屏蔽词 */
if (isBlock) return false;
if (isBlock) {
log.info("筛选动态", `包含屏蔽词(https://t.bilibili.com/${dyid})`)
return false
}
/**若勾选只转已关注 */
if (only_followed && !isFollowed) return false;
if (only_followed
&& (!mIsFollowed || !oriIsFollowed)
) {
log.info("筛选动态", `只转已关注(https://t.bilibili.com/${dyid})`)
return false
}
/* 获取黑名单并去重合并 */
const { blacklist: remote_blacklist } = global_var.get("remoteconfig")
, new_blacklist = remote_blacklist
? [...new Set([...blacklist.split(','), ...remote_blacklist.split(',')])].join()
const
{ blacklist: remote_blacklist } = use_public_blacklist === false
? { blacklist: "" }
: global_var.get("remoteconfig"),
/* 获取黑名单并去重合并 */
new_blacklist = remote_blacklist
? [
...new Set([...blacklist.split(','),
...remote_blacklist.split(',')])
].join()
: blacklist;
if ((new RegExp(dyid + '|' + uid)).test(new_blacklist)) return false;
if ((new RegExp(dyid + '|' + m_uid + '|' + ori_uid)).test(new_blacklist)) {
log.info("筛选动态", `黑名单屏蔽(https://t.bilibili.com/${dyid})`)
return false
}
if (isLottery) {
@@ -248,8 +382,8 @@ class Monitor extends Searcher {
/**初始化待关注列表 */
onelotteryinfo.uid = []
if (!isFollowed) {
onelotteryinfo.uid.push(uid);
if (!realIsFollowed) {
onelotteryinfo.uid.push(real_uid);
}
onelotteryinfo.dyid = dyid;
@@ -284,7 +418,7 @@ class Monitor extends Searcher {
const addlength = RandomStr.length + 2 + uname.length + 1 + 1;
onelotteryinfo.relay_chat = RandomStr + `//@${uname}:` + des;
new_ctrl.push({
data: String(uid),
data: String(real_uid),
location: RandomStr.length + 2,
length: uname.length + 1,
type: 1
@@ -293,8 +427,9 @@ class Monitor extends Searcher {
item.location += addlength;
return item;
}).forEach(it => new_ctrl.push(it))
if (!(new RegExp(uids[1])).test(attentionList))
onelotteryinfo.uid.push(uids[1]);
if (!oriIsFollowed) {
onelotteryinfo.uid.push(ori_uid);
}
} else {
onelotteryinfo.relay_chat = RandomStr;
}
@@ -315,6 +450,8 @@ class Monitor extends Searcher {
if (isSendChat) onelotteryinfo.rid = rid;
alllotteryinfo.push(onelotteryinfo);
} else {
log.info("筛选动态", `非抽奖动态(https://t.bilibili.com/${dyid})`)
}
})
@@ -324,13 +461,27 @@ class Monitor extends Searcher {
* 关注转发评论
* @param {LotteryOptions} option
* @returns {Promise<number>}
* 0 - 成功
* 9 - 评论黑名单/评论区关闭/动态删除
* 11 - 评论错误
* 19 - 关注黑名单
* 21 - 关注错误
* 22 - 关注异常
* 31 - 转发失败
* - 成功 0
* - 评论 未知错误 1001
* - 评论 原动态已删除 1002
* - 评论 评论区已关闭 1003
* - 评论 需要输入验证码 1004
* - 评论 已被对方拉入黑名单 1005
* - 评论 黑名单用户无法互动 1006
* - 评论 UP主已关闭评论区 1007
* - 关注 未知错误 2001
* - 关注 您已被对方拉入黑名单 2002
* - 关注 黑名单用户无法关注 2003
* - 关注 账号异常 2004
* - 关注 关注已达上限 2005
* - 分区 移动失败 3001
* - 点赞 未知错误 4001
* - 点赞 点赞异常 4002
* - 点赞 点赞频繁 4003
* - 转发 未知错误 5001
* - 转发 该动态不能转发分享 5002
* - 转发 请求数据发生错误,请刷新或稍后重试 5003
* - 转发 操作太频繁了,请稍后重试 5004
*/
async go(option) {
log.debug('正在转发的动态信息', option);
@@ -339,63 +490,72 @@ class Monitor extends Searcher {
return 0
}
const { uid, dyid, chat_type, rid, relay_chat, ctrl } = option;
let status = 0
const
{ uid, dyid, chat_type, rid, relay_chat, ctrl } = option,
{ chat, check_if_duplicated } = config;
/* 评论 */
if (rid && chat_type) {
let status = 0
const
{ chat } = config,
retry = [...new Array(5).keys()],
max_retry_times = retry.length;
await try_for_each(retry, async (times) => {
status = await bili.sendChat(rid, getRandomOne(chat), chat_type)
switch (status) {
case 0:
return true
case -1:
log.warn('抽奖信息', `uid: ${uid},dyid: ${dyid}`)
return true
default:
log.error('抽奖信息', `uid: ${uid},dyid: ${dyid}`)
log.info('自动评论', `将在 ${times + 1} 分钟后再次发送评论(${times + 1}/${max_retry_times})`)
await delay(60 * 1000 * (times + 1))
return false
}
})
if (status) return 10 + status;
status = await retryfn(
5,
[1, 4],
() => bili.sendChat(rid, getRandomOne(chat), chat_type)
)
if (status) {
log.warn("抽奖信息", `dyid: ${dyid}, rid: ${rid}, chat_type: ${chat_type}`)
return 1000 + status
}
}
/* 关注 */
if (uid.length) {
let status = 0
await try_for_each(uid, async (u) => {
status = await bili.autoAttention(u)
switch (status) {
case 0:
if (await bili.movePartition(u, this.tagid)) {
log.error('抽奖信息', `uid: ${u},dyid: ${dyid}`)
}
return false
case -1:
case 2:
log.warn('抽奖信息', `uid: ${u},dyid: ${dyid}`)
return true
default:
log.error('抽奖信息', `uid: ${u},dyid: ${dyid}`)
return true
if (status) {
log.warn("抽奖信息", `dyid: ${dyid}, uid: ${u}`)
return true
} else if (await bili.movePartition(u, this.tagid)) {
log.warn("抽奖信息", `dyid: ${dyid}, uid: ${u} tagid: ${this.tagid}`)
/* 3000系错误 */
status = 1001
return true
} else {
return false
}
})
if (status) return 20 + status
if (status) return 2000 + status
}
/* 点赞 */
await bili.autolike(dyid)
if (!check_if_duplicated || check_if_duplicated === 2) {
status = await retryfn(
5,
[1, 2, 3],
() => bili.autolike(dyid)
)
if (status) {
log.warn("抽奖信息", `dyid: ${dyid}`)
return 4000 + status
}
}
/* 转发 */
if (await bili.autoRelay(global_var.get("myUID"), dyid, relay_chat, ctrl)) return 31;
status = await retryfn(
5,
[1, 3, 4],
() => bili.autoRelay(global_var.get("myUID"), dyid, relay_chat, ctrl)
)
return 0
if (status) {
log.warn("抽奖信息", `dyid: ${dyid}`)
return 5000 + status
}
return status
}
}
+143 -47
View File
@@ -1,6 +1,8 @@
const utils = require('../utils');
const bili = require('../net/bili');
const config = require("../data/config");
const { send } = require("../net/http");
const { check_if_duplicated, article_scan_page, article_create_time, not_check_article, get_dynamic_detail_wait, uid_scan_page, search_wait, tag_scan_page } = require("../data/config");
const d_storage = require("../helper/d_storage")
const { log } = utils
@@ -11,14 +13,14 @@ const { log } = utils
* @property {number} uid
* @property {string} uname
* @property {boolean} is_liked
* @property {number} createtime 10
* @property {number} create_time 10
* @property {string} rid_str
* @property {string} dynamic_id
* @property {number} type
* @property {string} description
* @property {boolean} hasOfficialLottery
* @property {Array<Object.<string,string|number>>} ctrl
*
* @property {number} origin_create_time 10
* @property {number} origin_uid
* @property {string} origin_uname
* @property {string} origin_rid_str
@@ -27,6 +29,20 @@ const { log } = utils
* @property {string} origin_description
* @property {boolean} origin_hasOfficialLottery
*
* 整理后的抽奖信息
* @typedef {object} LotteryInfo
* @property {string} lottery_info_type
* @property {number} create_time
* @property {boolean} is_liked
* @property {number[]} uids `[uid,ouid]`
* @property {string} uname
* @property {Array<{}>} ctrl
* @property {string} dyid
* @property {string} rid
* @property {string} des
* @property {number} type
* @property {boolean} hasOfficialLottery 是否官方
*
* @param {object} dynamic_detail_card
* @return {UsefulDynamicInfo}
*/
@@ -46,7 +62,7 @@ function parseDynamicCard(dynamic_detail_card) {
/* 动态是否点过赞 */
obj.is_liked = is_liked > 0
/* 动态的ts10 */
obj.createtime = desc.timestamp
obj.create_time = desc.timestamp
/* 动态类型 */
obj.type = desc.type
/* 用于发送评论 */
@@ -59,12 +75,17 @@ function parseDynamicCard(dynamic_detail_card) {
obj.ctrl = (extend_json && strToJson(extend_json).ctrl) || [];
/* 是否有官方抽奖 */
obj.hasOfficialLottery = extension && extension.lott && true;
/* 转发者的描述 后两个分别是视频动态的描述和视频本身的描述*/
obj.description = (item && (item.content || item.description || cardToJson.dynamic || cardToJson.desc)) || '';
/* 转发者的描述 纯文字内容 图片动态描述 后两个分别是视频动态的描述和视频本身的描述*/
obj.description =
(item && (item.content || '' + item.description || ''))
|| (cardToJson.dynamic || '' + cardToJson.desc || '')
|| '';
if (obj.type === 1) {
const { origin_extension, origin } = cardToJson
, originToJson = strToJson(origin)
, { user, item } = originToJson;
/* 源动态的ts10 */
obj.origin_create_time = desc.origin.timestamp;
/* 被转发者的UID */
obj.origin_uid = desc.origin.uid;
/* 被转发者的rid(用于发评论) */
@@ -76,7 +97,10 @@ function parseDynamicCard(dynamic_detail_card) {
/* 被转发者的name */
obj.origin_uname = (user && (user.name || user.uname)) || '';
/* 被转发者的描述 */
obj.origin_description = (item && (item.content || item.description || originToJson.dynamic || originToJson.desc)) || '';
obj.origin_description =
(item && (item.content || '' + item.description || ''))
|| (originToJson.dynamic || '' + originToJson.desc || '')
|| '';
}
return obj
@@ -131,20 +155,6 @@ function modifyDynamicRes(res) {
*/
class Searcher {
constructor() { }
/**
* 整理后的抽奖信息
* @typedef {object} LotteryInfo
* @property {string} lottery_info_type
* @property {boolean} is_liked
* @property {number[]} uids `[uid,ouid]`
* @property {string} uname
* @property {Array<{}>} ctrl
* @property {string} dyid
* @property {string} rid
* @property {string} des
* @property {number} type
* @property {boolean} hasOfficialLottery 是否官方
*/
/**
* 检查指定用户的所有的动态信息
* @param {number} hostuid 指定的用户UID
@@ -215,9 +225,7 @@ class Searcher {
*/
async getLotteryInfoByUID(UID) {
log.info('获取动态', `开始获取用户${UID}的动态信息`);
const
{ uid_scan_page, search_wait, get_dynamic_detail_wait } = config,
{ allModifyDynamicResArray } = await Searcher.checkAllDynamic(UID, uid_scan_page, search_wait);
const { allModifyDynamicResArray } = await Searcher.checkAllDynamic(UID, uid_scan_page, search_wait);
let { length } = allModifyDynamicResArray
@@ -236,8 +244,6 @@ class Searcher {
const results = await pre
, { origin_dynamic_id } = cur;
log.info('获取动态', `查看源动态(${origin_dynamic_id})的细节 (${length--})`)
const card = await bili.getOneDynamicByDyid(origin_dynamic_id)
if (card) {
@@ -245,18 +251,24 @@ class Searcher {
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
}]
log.info('获取动态', `查看源动态(${origin_dynamic_id})是否点赞 (${length--})`)
if (is_liked) {
log.info('获取动态', `动态(${origin_dynamic_id})已转发过`)
} else {
return [...results, {
lottery_info_type: 'uid',
create_time: cur.origin_create_time,
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
@@ -275,7 +287,6 @@ class Searcher {
*/
async getLotteryInfoByTag(tag_name) {
const
{ tag_scan_page, search_wait } = config,
tag_id = await bili.getTagIDByTagName(tag_name),
hotdy = await bili.getHotDynamicInfoByTagID(tag_id),
modDR = modifyDynamicRes(hotdy);
@@ -307,6 +318,7 @@ class Searcher {
const fomatdata = mDRdata.map(o => {
return {
lottery_info_type: 'tag',
create_time: o.create_time,
is_liked: o.is_liked,
uids: [o.uid, o.origin_uid],
uname: o.uname,
@@ -329,16 +341,19 @@ class Searcher {
*/
async getLotteryInfoByArticle(key_words) {
log.info('获取动态', `开始获取含关键词${key_words}的专栏信息`);
const
{ article_scan_page, not_check_article, get_dynamic_detail_wait } = config,
cvs = (await bili.searchArticlesByKeyword(key_words)).slice(0, article_scan_page);
const cvs = (await bili.searchArticlesByKeyword(key_words)).slice(0, article_scan_page);
/**存储所有专栏中的dyid */
let dyinfos = [];
/**遍历专栏s */
for (const cv of cvs) {
for (const { id, pub_time } of cvs) {
let now_time = Math.floor(Date.now() / 1000);
if ((now_time - pub_time) / 86400 > article_create_time) {
log.warn("获取动态", `该专栏(${id})创建时间大于设定天数(${article_create_time}天)`)
continue
}
const
content = await bili.getOneArticleByCv(cv),
content = await bili.getOneArticleByCv(id),
dyids = content.match(/(?<=t.bilibili.com\/)[0-9]+/g) || [],
dyids_set = [...new Set(dyids)],
/**判断此专栏是否查看过的权重 */
@@ -349,13 +364,13 @@ class Searcher {
_weight = 0,
/**单个专栏中的dyid */
_dyinfos = [];
log.info('获取动态', `提取专栏(${cv})中提及的dyid(${length})`)
log.info('获取动态', `提取专栏(${id})中提及的dyid(${length})`)
/**遍历某专栏中的dyids */
for (const dyid of dyids_set) {
if (dyid.length === utils.dyid_length) {
log.info('获取动态', `查看专栏中所提及动态(${dyid})的细节 (${length--})`)
log.info('获取动态', `查看专栏中所提及动态(${dyid}) (${length--})`)
const card = await bili.getOneDynamicByDyid(dyid)
if (card) {
@@ -364,7 +379,12 @@ class Searcher {
const parsed_card = parseDynamicCard(card)
, { is_liked } = parsed_card;
if (is_liked) {
if (
((!check_if_duplicated || check_if_duplicated === 2)
&& is_liked)
|| ((check_if_duplicated === 1 || check_if_duplicated === 2)
&& await d_storage.searchDyid(dyid))
) {
log.info('获取动态', `动态(${dyid})已转发过`)
_weight += 1;
}
@@ -386,6 +406,7 @@ class Searcher {
const fomatdata = dyinfos.map(o => {
return {
lottery_info_type: 'article',
create_time: o.create_time,
is_liked: o.is_liked,
uids: [o.uid, o.origin_uid],
uname: o.uname,
@@ -401,6 +422,81 @@ class Searcher {
return fomatdata
}
/**
* 从特定格式的api响应数据中获取抽奖信息
* @param {string} api
* @returns {Promise<LotteryInfo[] | null>}
*/
getLotteryInfoByAPI(api) {
return new Promise((resolve) => {
if (api) {
const { strToJson } = utils;
log.info('获取动态', `开始获取链接(${api})中的抽奖信息`)
send({
url: api,
config: {
redirect: true
},
method: 'GET',
success: ({ body }) => {
if (body.err_msg) {
log.error("从API响应数据中获取抽奖信息", body.err_msg)
resolve(null)
} else {
const raw_lottery_info = strToJson(body).lottery_info;
if (raw_lottery_info) {
let { length } = raw_lottery_info;
if (length) {
const lottery_info = raw_lottery_info
.reduce(async (pre, cur) => {
let results = await pre
, { dyid } = cur;
if (!check_if_duplicated || check_if_duplicated === 2) {
log.info('获取动态', `查看动态(${dyid})是否点赞 (${length--})`)
const card = await bili.getOneDynamicByDyid(dyid)
if (card) {
await utils.delay(get_dynamic_detail_wait)
const { is_liked } = parseDynamicCard(card)
if (is_liked) {
log.info('获取动态', `动态(${dyid})已转发过`)
} else {
cur.is_liked = is_liked
results.push(cur)
}
}
} else {
results.push(cur)
}
return results
}, Promise.resolve([]))
resolve(lottery_info)
return
}
}
log.error("从API响应数据中获取抽奖信息", "非Json数据或没有lottery_info或lottery为空")
resolve(null)
}
},
failure: err => {
log.error("从API响应数据中获取抽奖信息", err)
resolve(null)
}
})
} else {
log.warn('获取动态', `链接为空`)
resolve(null)
}
});
}
}
+74 -10
View File
@@ -16,13 +16,41 @@ const config = {
*/
TAGs: [],
/**
* 从API接口中获取抽奖信息
* @typedef {object} LotteryInfo
* @property {string} lottery_info_type
* @property {number} create_time
* @property {boolean} is_liked
* @property {number[]} uids `[uid,ouid]`
* @property {string} uname
* @property {Array<{}>} ctrl
* @property {string} dyid
* @property {string} rid
* @property {string} des
* @property {number} type
* @property {boolean} hasOfficialLottery 是否官方
* @typedef RespondBody
* @property {string} err_msg 错误信息
* @property {LotteryInfo[]} lottery_info
* API传回数据类型 {RespondBody}
* 获取抽奖信息的链接字符串
*/
APIs: [],
/**
* API发送数据类型 {LotteryInfo[]}
* 上传抽奖信息的链接字符串
*/
set_lottery_info_url: "",
/**
* 动态中的关键词(表示须同时满足以下条件)
* 符合js正则表达式的字符串
*/
key_words: [
"[抽奖]",
"[转关].*[转关]"
"[抽奖]",
"[转关]"
],
/**
@@ -41,6 +69,21 @@ const config = {
*/
chatmodel: '01',
/**
* 检查是否重复转发
* - 不检查 -1
* - 通过是否点赞判断 0
* - 检索本地dyids文件 1
* - 通过是否点赞判断+检索本地dyids文件 2
*/
check_if_duplicated: 1,
/**
* - 动态创建时间
* - 多少天前
*/
max_create_time: 60,
/**
* 不加判断的转发所监视的uid转发的动态
*/
@@ -61,6 +104,11 @@ const config = {
*/
article_scan_page: 3,
/**
* - 专栏创建时间距离现在的最大天数
*/
article_create_time: 7,
/**
* - 不检查专栏是否看过,若选择检查可以提高检测效率
* - 默认false(检查)
@@ -93,7 +141,7 @@ const config = {
* - 检索动态间隔
* - 单位毫秒
*/
search_wait: 1000,
search_wait: 2000,
/**
* - 读取下一页私信间隔
@@ -182,15 +230,20 @@ const config = {
at_users: [['转发抽奖娘', 294887687], ['你的工具人老公', 100680137]],
/**
* - 自动同步 https://gitee.com/shanmite/lottery-notice/raw/master/notice.json
* - 英文逗号分隔 如: 1,2,3
*/
blacklist: '',
/**
* - 自动同步 https://gitee.com/shanmite/lottery-notice/raw/master/notice.json
* - 使用公共黑名单
*/
use_public_blacklist: true,
/**
* 屏蔽词
*/
blockword: ["脚本抽奖", "恭喜", "结果", "抽奖号", "钓鱼", "涨粉"],
blockword: ["脚本", "抽奖号", "钓鱼"],
/**
* 转发评语
@@ -219,16 +272,29 @@ const config = {
*/
is_exception: false,
/**
* 是否关注已达上限
*/
is_outof_maxfollow: false,
/**
* - 中奖通知关键词(满足一个就推送)
* - 符合js正则表达式的字符串
* - 若以 ~ 开头则表示为黑名单规则
* - 优先级递增
*/
notice_key_words: [
"~预约成功|预约主题",
"中奖|获得|填写|写上|提供|收货地址|支付宝账号|码|大会员",
"~有奖预约通知"
"~你的账号在新设备或平台登录成功",
"~你预约的直播已开始"
],
/**
* - 获取私信页数
*/
check_session_pages: 16,
/**
* - 清理白名单uid或dyid
* - 英文逗号分隔 如: 1,2,3
@@ -300,10 +366,8 @@ const config = {
* @param {string} n
*/
updata(n) {
const new_config = this.raw_config()[`config_${n}`];
if (new_config) {
this.setObject(new_config)
}
this.init()
this.setObject(this.raw_config()[`config_${n}`])
},
init() {
+9 -5
View File
@@ -1,4 +1,4 @@
const { getRemoteConfig } = require("../utils");
const { getRemoteConfig, createDir, createFile } = require("../utils");
const config = require("../data/config");
const key_map = new Map([['DedeUserID', 'myUID'], ['bili_jct', 'csrf']]);
@@ -15,10 +15,11 @@ let global_var = {
* 全局变量初始化
* 更新config
* @param {string} cookie
* @param {string} num
*/
async init(cookie) {
async init(cookie, num) {
if (cookie) {
config.updata(process.env.NUMBER);
config.updata(num);
this.set('cookie', cookie);
@@ -28,14 +29,17 @@ let global_var = {
this.set(key_map.get(_item[0]), _item[1]);
});
const { UIDs = [], TAGs = [], Articles = [] } = config;
const { UIDs = [], TAGs = [], Articles = [], APIs = [] } = config;
this.set('Lottery', [
...UIDs.map(it => ['UIDs', it]),
...TAGs.map(it => ['TAGs', it]),
...Articles.map(it => ['Articles', it])
...Articles.map(it => ['Articles', it]),
...APIs.map(it => ['APIs', it])
]);
this.set('remoteconfig', await getRemoteConfig());
}
await createDir('dyids');
await createFile(num < 2 ? 'dyid.txt' : `dyid${num}.txt`, '', 'a')
}
};
+52
View File
@@ -0,0 +1,52 @@
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;
+23 -19
View File
@@ -8,32 +8,36 @@ const utils = require("../utils");
* @returns
*/
async function randomDynamic(num) {
const { create_dy_type, dy_contents, random_dynamic_wait } = config;
let dynamics = []
const
{ create_dy_type, dy_contents, random_dynamic_wait } = config,
hasShareVideo = create_dy_type === -1 || create_dy_type === 1,
hasRandomCreate = create_dy_type === -1 || create_dy_type === 0 || typeof create_dy_type === 'undefined';
if (create_dy_type === -1 || create_dy_type === 0 || typeof create_dy_type === 'undefined') {
if (hasShareVideo) {
dynamics = await bili.getTopRcmd()
for (let index = 0; dynamics.length < num; index++) {
dynamics.push(...await bili.getTopRcmd())
}
}
if (hasRandomCreate) {
for (let index = 0; index < num; index++) {
await bili.createDynamic(utils.getRandomOne(dy_contents));
await utils.delay(random_dynamic_wait);
dynamics.push(utils.getRandomOne(dy_contents))
}
}
if (create_dy_type === -1 || create_dy_type === 1) {
let videos = await bili.getTopRcmd()
for (let index = 0; videos.length < num; index++) {
videos.push(...await bili.getTopRcmd())
}
await utils.try_for_each(videos, async ([uid, aid]) => {
if (num--) {
await bili.shareVideo(uid, aid)
await utils.delay(random_dynamic_wait)
return false
await utils.try_for_each(
utils.shuffle(dynamics).slice(0, num),
async (dynamic) => {
await utils.delay(random_dynamic_wait)
if (dynamic instanceof Array && dynamic.length === 2 && typeof dynamic[0] === "number") {
return await bili.shareVideo(...dynamic)
} else {
return true
return await bili.createDynamic(dynamic)
}
})
}
}
)
}
module.exports = { randomDynamic }
+4 -2
View File
@@ -10,8 +10,10 @@ const { log } = utils;
async function createRandomDynamic(num) {
if (config.create_dy) {
log.info('随机动态', `准备创建${num}条随机动态`);
const Dynamic = await Searcher.checkAllDynamic(global_var.get("myUID"), 1);
if ((Dynamic.allModifyDynamicResArray[0] || { type: 0 }).type === 1) {
const
{ allModifyDynamicResArray } = await Searcher.checkAllDynamic(global_var.get("myUID"), 1),
{ type, orig_type } = allModifyDynamicResArray[0] || {};
if (type === 1 && orig_type !== 8) {
await randomDynamic(num)
} else {
log.info('随机动态', '已有非抽奖动态故无需创建');
+1
View File
@@ -7,6 +7,7 @@ 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',
LOTTERY_SVR_LOTTERY_NOTICE: 'https://api.vc.bilibili.com/lottery_svr/v1/lottery_svr/lottery_notice',
+148 -64
View File
@@ -204,10 +204,9 @@ const bili_client = {
}
},
/**
* 获取私信
* 获取一页私信
* @typedef SessionData
* @property {string} session_ts
* @property {string} content
* @property {number} timestamp
* @property {number} unread_count
* @property {number} sender_uid
@@ -241,8 +240,8 @@ const bili_client = {
data = sessions.map(session => {
const
{ session_ts, last_msg, unread_count, talker_id } = session,
{ content = '', timestamp = 0, sender_uid = 0, msg_seqno } = last_msg || {};
return { session_ts, content, timestamp, sender_uid, unread_count, talker_id, msg_seqno };
{ timestamp = 0, sender_uid = 0, msg_seqno } = last_msg || {};
return { session_ts, timestamp, sender_uid, unread_count, talker_id, msg_seqno };
});
return { has_more, data };
} else if (res.code === 2) {
@@ -253,6 +252,34 @@ const bili_client = {
return { has_more: 0, data: [] };
}
},
/**
* 获取私信细节
* @param {number} talker_id
* @param {number} size
*/
async fetch_session_msgs(talker_id, size) {
const
responseText = await get({
url: API.FETCH_SESSION_MSGS,
query: {
talker_id,
session_type: 1,
size
}
}),
res = strToJson(responseText);
if (res.code === 0) {
const msgs = res.data.messages
if (msgs instanceof Array) {
log.info('私信细节', `${talker_id}${size}条未读私信`)
return msgs.map(it => it.content).join('\n')
} else {
log.warn('私信细节', `${talker_id}无私信`)
}
}
log.error('私信细节', `获取失败`)
return ''
},
/**
* 获取未读私信数量
* @returns {Promise<{ unfollow_unread: number, follow_unread: number }>}
@@ -345,6 +372,7 @@ const bili_client = {
log.warn('获取一个动态的细节', `动态(${dynamic_id})不存在`);
return;
}
log.info('获取一个动态的细节', `动态id(${dynamic_id})`);
return card;
},
/**
@@ -425,7 +453,7 @@ const bili_client = {
/**
* 搜索专栏
* @param {string} keyword
* @return {Promise<Array<number>>}
* @return {Promise<Array<{pub_time: number, id: number}>>}
*/
async searchArticlesByKeyword(keyword) {
const
@@ -443,7 +471,12 @@ const bili_client = {
let cv_arr = [];
try {
log.info('搜索专栏', '成功 关键词: ' + keyword);
cv_arr = res.data.result.map(it => it.id);
cv_arr = res.data.result.map(it => {
return {
pub_time: it.pub_time,
id: it.id
}
});
} catch (error) {
log.error('搜索专栏', '失败 原因:\n' + responseText);
cv_arr = [];
@@ -493,6 +526,17 @@ const bili_client = {
query: {
vmid: uid
}
}),
/**
* 线路三
* @param {number} uid
* @returns {Promise<string>}
*/
(uid) => get({
url: "https://tenapi.cn/bilibilifo/",
query: {
uid
}
})
], responseText => {
const res = strToJson(responseText);
@@ -574,11 +618,13 @@ const bili_client = {
case 0:
return [false, 0, '关注+1']
case 22002:
return [false, -1, '您已被对方拉入黑名单']
return [false, 2, '您已被对方拉入黑名单']
case 22003:
return [false, -1, '黑名单用户无法关注', -1]
return [false, 3, '黑名单用户无法关注']
case 22015:
return [false, 2, '账号异常', 2]
return [false, 4, '账号异常']
case 22009:
return [false, 5, '关注已达上限']
default:
return [true, 1, `未知错误\n${responseText}`]
}
@@ -590,10 +636,12 @@ const bili_client = {
* @param {Number} uid
* 被关注者的UID
* @returns {Promise<number>}
* -1 - 黑名单
* 0 - 成功
* 1 - 失败
* 2 - 异常
* - 成功 0
* - 未知错误 1
* - 您已被对方拉入黑名单 2
* - 黑名单用户无法关注 3
* - 账号异常 4
* - 关注已达上限 5
*/
autoAttention(uid) {
return this._autoAttention.run(uid)
@@ -603,8 +651,8 @@ const bili_client = {
* @param {number} uid
* @param {number} tagid 关注分区的ID
* @returns {Promise<number>}
* 0 - 成功
* 1 - 失败
* - 成功 0
* - 失败 1
*/
async movePartition(uid, tagid) {
const responseText = await post({
@@ -656,25 +704,36 @@ const bili_client = {
* 动态自动点赞
* @param {string} dyid
* @returns {Promise<number>}
* 0 - 成功
* 1 - 失败
* - 成功 0
* - 未知错误 1
* - 点赞异常 2
* - 点赞频繁 3
*/
async autolike(dyid) {
const responseText = await post({
url: API.DYNAMIC_LIKE_THUMB,
contents: {
uid: GlobalVar.get("myUID"),
dynamic_id: dyid,
up: 1,
csrf: GlobalVar.get("csrf")
}
});
if (/^{"code":0/.test(responseText)) {
log.info('自动点赞', '点赞成功');
return 0;
} else {
log.error('自动点赞', `点赞失败\n${responseText}`);
return 1;
const
responseText = await post({
url: API.DYNAMIC_LIKE_THUMB,
contents: {
uid: GlobalVar.get("myUID"),
dynamic_id: dyid,
up: 1,
csrf: GlobalVar.get("csrf")
}
}),
res = strToJson(responseText);
switch (res.code) {
case 0:
log.info('自动点赞', '点赞成功');
return 0;
case 1000113:
log.warn('自动点赞', '点赞异常');
return 2;
case 1000001:
log.warn('自动点赞', '点赞频繁');
return 3;
default:
log.error('自动点赞', `未知错误\n${responseText}`);
return 1;
}
},
/**
@@ -686,33 +745,48 @@ const bili_client = {
* @param {string} [msg]
* 动态的ID
* @returns {Promise<number>}
* 0 - 成功
* 1 - 失败
* - 成功 0
* - 未知错误 1
* - 该动态不能转发分享 2
* - 请求数据发生错误,请刷新或稍后重试 3
* - 操作太频繁了,请稍后重试 4
*/
async autoRelay(uid, dyid, msg = '转发动态', ctrl = '[]') {
const len = msg.length;
if (len > 233) {
msg = msg.slice(0, 233 - len)
}
const responseText = await post({
url: API.DYNAMIC_REPOST_REPOST,
config: {
retry: false
},
contents: {
uid: `${uid}`,
dynamic_id: dyid,
content: msg,
ctrl,
csrf: GlobalVar.get("csrf")
}
});
if (/^{"code":0/.test(responseText)) {
log.info('转发动态', '成功转发一条动态');
return 0;
} else {
log.error('转发动态', `转发动态失败\n${responseText}`);
return 1;
const
responseText = await post({
url: API.DYNAMIC_REPOST_REPOST,
config: {
retry: false
},
contents: {
uid: `${uid}`,
dynamic_id: dyid,
content: msg,
ctrl,
csrf: GlobalVar.get("csrf")
}
}),
res = strToJson(responseText);
switch (res.code) {
case 0:
log.info('转发动态', '成功转发一条动态');
return 0;
case 1101004:
log.warn('转发动态', '该动态不能转发分享');
return 2;
case 2201116:
log.warn('转发动态', '请求数据发生错误,请刷新或稍后重试');
return 3;
case 1101008:
log.warn('转发动态', '操作太频繁了,请稍后重试');
return 4;
default:
log.error('转发动态', `未知错误\n${responseText}`);
return 1;
}
},
/**
@@ -722,7 +796,7 @@ const bili_client = {
* @property {number} img_height
* 发布一条动态
* @param { string | Picture[] } content
* @return {Promise<void>}
* @return {Promise<boolean>} isError true
*/
async createDynamic(content) {
let
@@ -751,9 +825,11 @@ const bili_client = {
contents,
});
if (/^{"code":0/.test(responseText)) {
log.info('发布动态', `成功创建一条随机内容的动态\n${content}\n`);
log.info('发布动态', `成功创建一条随机内容的动态\n${JSON.stringify(content)}\n`);
return false
} else {
log.error('发布动态', `发布动态失败\n${content}\n${responseText}`);
log.error('发布动态', `发布动态失败\n${JSON.stringify(content)}\n${responseText}`);
return true
}
},
/**
@@ -782,6 +858,7 @@ const bili_client = {
* 分享视频
* @param {number} uid
* @param {number} aid
* @return {boolean} isError true
*/
async shareVideo(uid, aid) {
const responseText = await post({
@@ -798,8 +875,10 @@ const bili_client = {
});
if (/^{"code":0/.test(responseText)) {
log.info('转发视频', `成功转发视频(av${aid})`);
return false
} else {
log.error('转发视频', `转发失败\n${responseText}`);
return true
}
},
/**
@@ -837,8 +916,13 @@ const bili_client = {
* 17(无图)
* @returns {Promise<number>}
* - 成功 0
* - 失败 1
* - 黑名单/评论区关闭/动态删除 -1
* - 未知错误 1
* - 动态删除 2
* - 评论区已关闭 3
* - 需要输入验证码 4
* - 已被对方拉入黑名单 5
* - 黑名单用户无法互动 6
* - UP主已关闭评论区 7
*/
async sendChat(rid, msg, type) {
const
@@ -858,22 +942,22 @@ const bili_client = {
return 0;
case -404:
log.error('自动评论', '原动态已删除');
return -1;
return 2;
case 12002:
log.error('自动评论', '评论区已关闭');
return -1;
return 3;
case 12015:
log.error('自动评论', '需要输入验证码');
return 1;
return 4;
case 12035:
log.error('自动评论', `已被对方拉入黑名单`);
return -1;
return 5;
case 12053:
log.error('自动评论', '黑名单用户无法互动');
return -1;
return 6;
case 12061:
log.error('自动评论', 'UP主已关闭评论区');
return -1;
return 7;
default:
log.error('自动评论', `未知错误\n${responseText}`);
return 1;
+5 -4
View File
@@ -26,7 +26,7 @@
* @property {string} url 完整链接
* @property {boolean} [stream] 是否流式数据
* @property {RequestConfig} [config] 设置
* @property {string} [proxy] 代理 IP:PORT
* @property {string} [proxy] HTTP代理 IP:PORT
* @property {Object.<string, string|number>} [query] 查询选项
* @property {Object.<string, string|number> | string} [contents] 内容
* @property {HttpHeaders} [headers] 请求头
@@ -65,11 +65,12 @@ function send(detail) {
const { timeout, wait, retry, redirect, retry_times } = config;
const thisURL = new URL(url)
, content = formatContents(headers["content-type"], contents)
, request = thisURL.protocol === 'https:' ? https_request : http_request;
, request = (thisURL.protocol === 'https:') && !proxy ? https_request : http_request;
let options = {
timeout,
method: method.toUpperCase(),
host: thisURL.host,
hostname: thisURL.hostname,
port: thisURL.port,
path: thisURL.pathname + thisURL.search + thisURL.hash,
headers,
};
@@ -82,7 +83,7 @@ function send(detail) {
if (proxy) {
options.headers.host = thisURL.host;
options.path = thisURL.href;
[options.hostname, options.port] = proxy.split(':');
[options.host, options.port] = proxy.split(':');
}
const req = request(options, res => {
let protodata = '';
+10 -9
View File
@@ -1,12 +1,12 @@
const { send } = require('./net/http')
const { strToJson, download } = require('./utils')
const { strToJson, download, try_for_each } = require('./utils')
const { version, checkVersion, log } = require('./utils')
/**
* 获取下载链接
* @param {string} owner
* @param {string} repo
* @returns {Promise<{ download_url: string, text: string }>}
* @returns {Promise<{ download_url: string[], text: string }>}
*/
function getLatestReleaseDownloadUrl(owner, repo) {
return new Promise((resolve, reject) => {
@@ -36,8 +36,8 @@ function getLatestReleaseDownloadUrl(owner, repo) {
try {
const download_url = assets
.filter(({ name }) => name.includes(platform) && name.includes(arch))
.map(({ browser_download_url }) => browser_download_url)[0]
if (!download_url) {
.map(({ browser_download_url }) => browser_download_url)
if (!download_url.length) {
reject(`未找到能在此平台(${process.platform})-(${process.arch})上运行的版本`)
}
resolve({ download_url, text })
@@ -67,11 +67,12 @@ function getLatestReleaseDownloadUrl(owner, repo) {
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')
await try_for_each(download_url.entries(), async ([i, url]) => {
let proxy_url = new URL(url)
proxy_url.host = 'download.fastgit.org'
await download(proxy_url.href, `latest_version${i}.zip`)
return false
})
log.info('自动下载', '成功下载到当前目录')
log.info('更新说明', '\n' + text + '\n')
+66 -1
View File
@@ -13,6 +13,8 @@ const utils = {
env_file: path.join(process.cwd(), "env.js"),
/**配置文件 */
config_file: path.join(process.cwd(), "my_config.js"),
/**dyids存放目录 */
dyids_dir: path.join(process.cwd(), "dyids"),
/**dyid长度 */
dyid_length: 18,
/**
@@ -57,6 +59,25 @@ const utils = {
if (await fn(item)) break
}
},
/**
* @template T
* @param {number} max_times
* @param {Array<T>} unexpected
* @param {() => Promise<T>} fn
*/
async retryfn(max_times, unexpected, fn) {
let ret = null;
for (let times = 0; times < max_times; times++) {
ret = await fn()
if (unexpected.includes(ret)) {
utils.log.warn('自动重试', `将在 ${times + 1} 分钟后再次尝试(${times + 1}/${max_times})`)
await utils.delay(60 * 1000 * (times + 1))
} else {
break
}
}
return ret;
},
/**
* 函数柯里化
* @template T
@@ -141,7 +162,7 @@ const utils = {
return array;
},
/**
* 关键词判断
* 关键词判断 优先级递增
* @param {string} text
* @param {string[]} key_words startwith '~' 表示黑名单
* @return {boolean}
@@ -306,6 +327,50 @@ 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' })
}
};
+2 -3
View File
@@ -10,8 +10,7 @@ const metainfo = [
` __/ | | | `,
` |___/ |_| `,
` `,
` Verison: v${ve}`,
` Written By shanmite`,
` This: v${ve} Nodejs: ${process.version} Written By shanmite`,
]
/**多账号存储 */
let multiple_account = [];
@@ -46,7 +45,7 @@ async function main() {
process.env.ENABLE_MULTIPLE_ACCOUNT = ENABLE_MULTIPLE_ACCOUNT;
} else if (COOKIE) {
const global_var = require("./lib/data/global_var");
await global_var.init(COOKIE, Number(NUMBER));
await global_var.init(COOKIE, NUMBER);
/**引入基础功能 */
const { start, isMe, clear, update, checkCookie } = require("./lib/index");
+74 -6
View File
@@ -28,13 +28,43 @@ module.exports = Object.freeze({
'抽奖',
],
/**
* 从API接口中获取抽奖信息
* @typedef {object} LotteryInfo
* @property {string} lottery_info_type
* @property {number} create_time
* @property {boolean} is_liked
* @property {number[]} uids `[uid,ouid]`
* @property {string} uname
* @property {Array<{}>} ctrl
* @property {string} dyid
* @property {string} rid
* @property {string} des
* @property {number} type
* @property {boolean} hasOfficialLottery 是否官方
* @typedef RespondBody
* @property {string} err_msg 错误信息
* @property {LotteryInfo[]} lottery_info
* API传回数据类型 {RespondBody}
* 获取抽奖信息的链接字符串
* @example
* "https://github.com/spiritLHL/sync_lottery"
*/
APIs: [],
/**
* API发送数据类型 {LotteryInfo[]}
* 上传抽奖信息的链接字符串
*/
set_lottery_info_url: "",
/**
* 动态中的关键词(表示须同时满足以下条件)
* 符合js正则表达式的字符串
*/
key_words: [
"[抽奖]",
"[转关].*[转关]"
"[抽奖]",
"[转关]"
],
/**
@@ -53,6 +83,21 @@ module.exports = Object.freeze({
*/
chatmodel: '01',
/**
* 检查是否重复转发
* - 不检查 -1
* - 通过是否点赞判断 0
* - 检索本地dyids文件 1
* - 通过是否点赞判断+检索本地dyids文件 2
*/
check_if_duplicated: 1,
/**
* - 动态创建时间
* - 多少天前
*/
max_create_time: 60,
/**
* 不加判断的转发所监视的uid转发的动态
*/
@@ -73,6 +118,11 @@ module.exports = Object.freeze({
*/
article_scan_page: 3,
/**
* - 专栏创建时间距离现在的最大天数
*/
article_create_time: 7,
/**
* - 不检查专栏是否看过,若选择检查可以提高检测效率
* - 默认false(检查)
@@ -105,7 +155,7 @@ module.exports = Object.freeze({
* - 检索动态间隔
* - 单位毫秒
*/
search_wait: 1000,
search_wait: 2000,
/**
* - 读取下一页私信间隔
@@ -194,15 +244,20 @@ module.exports = Object.freeze({
at_users: [['转发抽奖娘', 294887687], ['你的工具人老公', 100680137]],
/**
* - 自动同步 https://gitee.com/shanmite/lottery-notice/raw/master/notice.json
* - 英文逗号分隔 如: 1,2,3
*/
blacklist: '',
/**
* - 自动同步 https://gitee.com/shanmite/lottery-notice/raw/master/notice.json
* - 使用公共黑名单
*/
use_public_blacklist: true,
/**
* 屏蔽词
*/
blockword: ["脚本抽奖", "恭喜", "结果", "抽奖号", "钓鱼", "涨粉"],
blockword: ["脚本", "抽奖号", "钓鱼"],
/**
* 转发评语
@@ -231,16 +286,29 @@ module.exports = Object.freeze({
*/
is_exception: false,
/**
* 是否关注已达上限
*/
is_outof_maxfollow: false,
/**
* - 中奖通知关键词(满足一个就推送)
* - 符合js正则表达式的字符串
* - 若以 ~ 开头则表示为黑名单规则
* - 优先级递增
*/
notice_key_words: [
"~预约成功|预约主题",
"中奖|获得|填写|写上|提供|收货地址|支付宝账号|码|大会员",
"~有奖预约通知"
"~你的账号在新设备或平台登录成功",
"~你预约的直播已开始"
],
/**
* - 获取私信页数
*/
check_session_pages: 16,
/**
* - 清理白名单uid或dyid
* - 英文逗号分隔 如: 1,2,3
+13 -11
View File
@@ -1,6 +1,6 @@
{
"name": "lottery-auto-script",
"version": "2.2.8",
"version": "2.4.2",
"description": "自动参与B站动态抽奖",
"main": "main.js",
"scripts": {
@@ -8,9 +8,8 @@
"clear": "node main.js clear",
"check": "node main.js check",
"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"
"build_all": "bash script/build/pkg.sh",
"changelog": "bash script/build/changelog.sh"
},
"files": [
"lib",
@@ -24,9 +23,12 @@
"bin": "main.js",
"pkg": {
"targets": [
"linux-x64",
"win-x64",
"macos-x64"
"node12-win-x64",
"node16-win-x64",
"node16-linux-x64",
"node16-macos-x64",
"node16-linuxstatic-arm64",
"node16-linuxstatic-armv7"
],
"outputPath": "dist"
},
@@ -45,11 +47,11 @@
},
"homepage": "https://github.com/shanmiteko/AutoScript#readme",
"devDependencies": {
"eslint": "^7.17.0",
"pkg": "^5.2.1"
"eslint": "^8.1.0",
"pkg": "^5.4.1"
},
"dependencies": {
"chalk": "^4.1.1",
"nodemailer": "^6.5.0"
"chalk": "^4.1.2",
"nodemailer": "^6.7.0"
}
}
+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
# version: <major.minor.patch>
level=patch
npm version $level \
--no-commit-hooks \
--no-git-tag-version
OLD_VERSION_ARRAY=($(npm view lottery-auto-script version | tr '.' ' '))
major=${OLD_VERSION_ARRAY[0]}
minor=${OLD_VERSION_ARRAY[1]}
patch=${OLD_VERSION_ARRAY[2]}
case "${level}" in
"major")
((major += 1))
minor=0
patch=0
;;
"minor")
((minor += 1))
patch=0
;;
*)
((patch += 1))
;;
esac
NEW_VERSION="$major.$minor.$patch"
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
git add .
git commit -m "docs: 更新CHANGELOG"
+56
View File
@@ -0,0 +1,56 @@
#!/usr/bin/env bash
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"
BIN_NAME="lottery"
create_win_bat() {
echo "@echo off && lottery $1 && pause"
}
if [ -d "$TARGET_DIR" ]; then
rm -rf "$TARGET_DIR"
fi
npx pkg .
# 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"
if [ "$(echo $file | grep '.exe')" ]; then
BATS=("start" "check" "clear" "update")
for item in "${BATS[@]}"; do
create_win_bat "${item}" >"$TMPDIR/$item.bat"
done
mv "$TMPDIR/$BIN_NAME" "$TMPDIR/$BIN_NAME.exe"
else
ZIP_NAME=latest_version0
cat >"$TMPDIR/update.sh" <<-EOF
#!/bin/bash
./lottery update
ZIP_NAME=$ZIP_NAME
if [[ -r "\$ZIP_NAME.zip" ]]; then
unzip \$ZIP_NAME.zip
rm \$ZIP_NAME.zip
chmod u+x lottery
fi
EOF
fi
cd $TMPDIR
zip -r "$TMPDIR_NAME.zip" .
mv "$TMPDIR_NAME.zip" ../
cd $ROOT
done
Regular → Executable
+86 -23
View File
@@ -29,7 +29,9 @@ if [ ! -f "$ENV_FILE" ]; then
echo "create $ENV_FILE"
curl -fsSL $ENV_EXAMPLE -o $ENV_FILE
else
echo "$ENV_FILE exists"
echo "$ENV_FILE already existed"
echo "create new_$ENV_FILE"
curl -fsSL $ENV_EXAMPLE -o "new_$ENV_FILE"
fi
# 新建配置文件
@@ -37,38 +39,99 @@ if [ ! -f "$CONFIG_FILE" ]; then
echo "create $CONFIG_FILE"
curl -fsSL $CONFIG_EXAMPLE -o $CONFIG_FILE
else
echo "$CONFIG_FILE exists"
echo "$CONFIG_FILE already existed"
echo "create new_$CONFIG_FILE"
curl -fsSL $CONFIG_EXAMPLE -o "new_$CONFIG_FILE"
fi
echo "docker pull $DOCKER_REPO"
docker -v && docker pull $DOCKER_REPO
echo "create start.sh"
echo -e "#!/bin/bash\n\
docker run \
-v $PWD/$ENV_FILE:/lottery/$ENV_FILE \
-v $PWD/$CONFIG_FILE:/lottery/$CONFIG_FILE \
$DOCKER_REPO \
start" \
> start.sh
cat >start.sh <<EOF
#!/bin/sh
NAME=shanmite-lottery-start
if [[ -z "\$(docker ps -a | grep \$NAME)" ]]; then
docker run \\
-v $PWD/$ENV_FILE:/lottery/$ENV_FILE \\
-v $PWD/$CONFIG_FILE:/lottery/$CONFIG_FILE \\
--name \$NAME \\
$DOCKER_REPO \\
start
else
echo "container \$NAME already existed"
echo "history logs -> docker logs \$NAME"
echo "close this -> docker stop \$NAME"
echo "start \$NAME"
docker start \$NAME
fi
EOF
chmod +x start.sh
echo "create check.sh"
echo -e "#!/bin/bash\n\
docker run \
-v $PWD/$ENV_FILE:/lottery/$ENV_FILE \
-v $PWD/$CONFIG_FILE:/lottery/$CONFIG_FILE \
$DOCKER_REPO \
check" \
> check.sh
cat >check.sh <<EOF
#!/bin/sh
NAME=shanmite-lottery-check
if [[ -z "\$(docker ps -a | grep \$NAME)" ]]; then
docker run \\
-v $PWD/$ENV_FILE:/lottery/$ENV_FILE \\
-v $PWD/$CONFIG_FILE:/lottery/$CONFIG_FILE \\
--name \$NAME \\
$DOCKER_REPO \\
check
else
echo "container \$NAME already existed"
echo "history logs -> docker logs \$NAME"
echo "close this -> docker stop \$NAME"
echo "start \$NAME"
docker start \$NAME
fi
EOF
chmod +x check.sh
echo "create clear.sh"
echo -e "#!/bin/bash\n\
docker run \
-v $PWD/$ENV_FILE:/lottery/$ENV_FILE \
-v $PWD/$CONFIG_FILE:/lottery/$CONFIG_FILE \
$DOCKER_REPO \
clear" \
> clear.sh
cat >clear.sh <<EOF
#!/bin/sh
NAME=shanmite-lottery-clear
if [[ -z "\$(docker ps -a | grep \$NAME)" ]]; then
docker run \\
-v $PWD/$ENV_FILE:/lottery/$ENV_FILE \\
-v $PWD/$CONFIG_FILE:/lottery/$CONFIG_FILE \\
--name \$NAME \\
$DOCKER_REPO \\
clear
else
echo "container \$NAME already existed"
echo "history logs -> docker logs \$NAME"
echo "close this -> docker stop \$NAME"
echo "start \$NAME"
docker start \$NAME
fi
EOF
chmod +x clear.sh
echo "create debug.sh"
cat >debug.sh <<EOF
#!/bin/sh
NAME=shanmite-lottery-debug
echo "create temporary debug container"
docker run \\
-it \\
--name \$NAME \\
--entrypoint /bin/sh \\
$DOCKER_REPO -c sh
echo "remove temporary debug container"
docker rm -v \$NAME
EOF
chmod +x debug.sh
echo "create remove_all.sh"
cat >remove_all.sh <<EOF
#!/bin/sh
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"
docker image rm -f shanmite/lottery_auto_docker
echo "see you next time!"
EOF
chmod +x remove_all.sh
-57
View File
@@ -1,57 +0,0 @@
$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"
$NAME = 'lottery-auto-script'
$TRIARR = @(
@("$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
Set-Location -Path $TARGET_DIR
Move-Item -Path $TEMPLATE_ENV_FILE -Destination $ENV_FILE -Force
Move-Item -Path $TEMPLATE_CONFIG_FILE -Destination $CONFIG_FILE -Force
foreach ($TRI in $TRIARR) {
$PROTO_BIN,$BIN,$DIR = $TRI
New-Item -ItemType Directory -Force -Path $DIR
Move-Item -Path $PROTO_BIN -Destination $BIN -Force
Move-Item -Path $BIN -Destination $DIR -Force
Copy-Item -Path $ENV_FILE -Destination $DIR -Force
Copy-Item -Path $CONFIG_FILE -Destination $DIR -Force
Copy-Item -Path $README -Destination $DIR -Force
if ($DIR -eq "nlts-win-x64") {
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 -Force
}
Remove-Item -Path $ENV_FILE
Remove-Item -Path $CONFIG_FILE
Remove-Item -Path $README
-8
View File
@@ -1,8 +0,0 @@
#!/bin/bash
./lottery update
if [[ -r "latest_version.zip" ]]; then
unzip latest_version.zip
rm latest_version.zip
chmod u+x lottery
fi