Compare commits

...
72 Commits
Author SHA1 Message Date
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
shanmiteko f851ac1afe docs: 更新CHANGLOG 2021-10-15 20:43:25 +08:00
shanmiteko b53b698930 feat: 遇到过期的cookie跳过(#51) 2021-10-15 17:06:49 +08:00
shanmiteko 08d46c6f5c fix: UP关闭评论区(#52) 2021-10-15 16:46:43 +08:00
shanmiteko 80ae3df933 docs: 更新CHANGLOG 2021-10-14 16:32:19 +08:00
shanmiteko ac397c68ec fix: 未移动分区(#50) 2021-10-14 16:16:10 +08:00
shanmiteko 423bc24939 fix: 修改线路切换逻辑 2021-10-14 16:15:39 +08:00
shanmiteko 41b28a133e docs: 更新README 2021-10-13 20:48:10 +08:00
shanmiteko b1ead1329d feat: LOG日志显示随机动态内容(#47) 2021-10-13 20:28:06 +08:00
shanmiteko e0e99a07bb feat: 增加设置过滤间隔 2021-10-13 19:31:25 +08:00
shanmiteko 30d0e8b1bd docs: 增加CHANGELOG 2021-10-12 12:09:49 +08:00
shanmiteko dd234691ea fix: 因黑名单而关注失败(#45) 2021-10-11 18:46:32 +08:00
shanmiteko c3c8ffba95 feat: 内置默认设置 2021-10-11 09:32:11 +08:00
shanmiteko ec9a11d5c0 feat: 增加更多时延自定义值(#44) 2021-10-10 21:50:45 +08:00
shanmiteko 1458c800b8 feat: api线路切换具有记忆功能
perf: 重构部分代码
fix: 清理动态时关注列表获取失败
2021-10-10 20:48:17 +08:00
shanmiteko b5fdb2d247 feat: clear_dynamic_type类型可以多选(#42) 2021-10-07 12:44:33 +08:00
shanmiteko 1c8e5915d9 fix: 番剧动态无user_profile(#41) 2021-10-07 12:29:48 +08:00
shanmiteko e845e3f7ef feat: 随机转发热门视频(#40) 2021-10-06 20:42:22 +08:00
shanmiteko 27eae63762 action: update npmp.yml 2021-10-06 18:16:36 +08:00
shanmiteko 634f45a4c4 action: update pkg.yml 2021-10-06 17:57:21 +08:00
shanmiteko 3c269b2f96 action: update pkg.yml 2021-10-06 14:08:04 +08:00
shanmiteko 3851f51621 fix: 动态不存在时出错(#39) 2021-10-06 13:26:31 +08:00
shanmiteko d676a10e56 feat: 可间隔插入随机动态(#33) 2021-10-05 18:13:00 +08:00
shanmiteko 88d3e97595 feat: 修改转发验重逻辑
直接根据是否点赞判断
2021-10-05 17:04:47 +08:00
shanmiteko 88ad8ecfcc fix(lib/data/env): [23:9] 2021-09-27 19:04:39 +08:00
shanmiteko 478d10d27e feat: 设置支持热更新(#29) 2021-09-27 18:40:11 +08:00
shanmite 6fbcf6e0b7 action: Publishing to NPM 2021-09-15 18:20:07 +08:00
jkluio78andshanmiteko 8bf47698ad feat: 新增设置not_check_article(#25) 2021-09-14 17:00:01 +08:00
shanmite c0bc4878e3 fix: 漏了逗号导致无法更新 2021-09-11 07:33:05 +00:00
shanmiteandGitHub e9b7965a76 doc: 增加徽标 2021-09-09 22:08:20 +08:00
shanmiteandGitHub 0a54cd20db fix(action): no match for platform in manifest 2021-09-09 22:02:34 +08:00
shanmite a2591f260a fix: 黑名单处理(#22) 2021-09-09 13:57:04 +00:00
shanmiteandGitHub e6dc9d7abb Merge pull request #21 from licncnn/main
修改了Linux 定时使用的操作文档
2021-09-09 14:24:00 +08:00
shanmite 179f4d0d41 fix: 错误码变更(#20) 2021-09-09 04:37:27 +00:00
licncnnandGitHub 5a625dbd12 Update linux_schedule.md 2021-09-09 11:43:12 +08:00
licncnnandGitHub 65fd4b3112 Update linux_schedule.md 2021-09-09 11:39:03 +08:00
licncnnandGitHub 14067ca923 Update linux_schedule.md 2021-09-09 11:38:28 +08:00
shanmite 33e55721f6 chore: 修改打包文件名 2021-08-26 15:25:09 +08:00
shanmite aa1aad7ddd fix: copy my_config.js 2021-08-26 15:02:32 +08:00
shanmite 0c0d112aaf feat: arm平台可更新 2021-08-26 14:55:09 +08:00
shanmite b4ec45a48d fix: node16-linuxstatic-armv7 2021-08-26 14:30:31 +08:00
shanmite 1ce8e966e8 fix: 调整arm目标 2021-08-26 14:23:58 +08:00
shanmite f252365809 chore: arm64,armv7 2021-08-26 14:13:45 +08:00
shanmite 30fee87485 chore: 自动打包 2021-08-26 13:53:37 +08:00
shanmite 214abd449f feat: 改变账号异常应对策略 2021-08-26 13:25:18 +08:00
shanmiteandGitHub 79b348d37e Merge pull request #17 from Adamcrg/main
fix: 修改dingtalk签名base64问题
2021-08-26 12:13:17 +08:00
ruigangChen 965734c2f2 修改dingtalk签名base64问题 2021-08-26 11:54:52 +08:00
shanmite 3cc42c0fc5 fix: 获取未读私信接口变化 2021-08-21 18:08:13 +08:00
shanmite b24c32a877 doc: 图片换源 2021-08-20 14:38:14 +08:00
shanmite ef822df5bf fix: 两处潜在问题
- 存储专栏获取结果
- 专栏获取为null
2021-08-17 18:43:59 +08:00
shanmite 9842107f52 fix: (#14) 2021-08-16 13:00:12 +08:00
shanmite 89dea18ae3 feat: 账号异常时切换线路 2021-08-16 12:51:21 +08:00
shanmite a426eb48f5 fix: 账号异常处理 2021-08-14 20:14:35 +08:00
shanmite c06f69457a pref: 时区+8(#13) 2021-08-14 13:24:54 +08:00
shanmite 155332751f fix: 解构赋初值异常 2021-08-14 13:02:46 +08:00
shanmite a28ec20b12 feat: 检查更新
fix: tag在中间的情况
2021-08-13 12:32:54 +08:00
shanmite 35cb1c24c2 fix: lib/main[48:9] 2021-08-09 14:52:41 +08:00
shanmite 4f961250be feat: 不参与主站黑名单用户抽奖 2021-08-09 13:48:44 +08:00
shanmite dce1ff61fd fix: 可从环境变量中读取COOKIE 2021-08-09 11:32:45 +08:00
shanmite ab6bc97f50 chore: 部分修改 2021-08-09 10:49:33 +08:00
shanmite da8903944a doc: 更新readme 2021-08-08 11:46:39 +08:00
shanmite 08f4375c21 feat: 中奖通知设置可设黑名单 2021-08-08 10:34:14 +08:00
shanmite ec0c5da092 fix: this丢失 2021-08-07 16:01:54 +08:00
38 changed files with 2599 additions and 1184 deletions
+1 -1
View File
@@ -6,7 +6,7 @@
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 12
"ecmaVersion": "latest"
},
"rules": {
}
+40
View File
@@ -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
+18
View File
@@ -0,0 +1,18 @@
name: "Publishing to NPM"
on:
push:
branches:
- main
paths:
- "package.json"
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
+82
View File
@@ -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/
- 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:
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/
-27
View File
@@ -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 }}
+2
View File
@@ -1,4 +1,6 @@
node_modules/
.vscode/
tests/
dyids/
dist/
package-lock.json
-123
View File
@@ -1,123 +0,0 @@
{
"HttpRequest-get": {
"scope": "javascript,typescript",
"prefix": "hrget",
"body": [
"HttpRequest({",
" method: 'GET',",
" url: '$1',",
" query: {",
" $2",
" },",
" headers: {",
" accept: 'application/json, text/plain, */*',",
" cookie: '$3',",
" },",
" success: res => {",
" $4",
" },",
" failure: err => {",
" $5",
" }",
"})$6"
],
"description": "简化http-get请求"
},
"HttpRequest-post": {
"scope": "javascript,typescript",
"prefix": "hrpost",
"body": [
"HttpRequest({",
" method: 'POST',",
" url: '$1',",
" contents: {",
" $2",
" },",
" headers: {",
" accept: 'application/json, text/plain, */*',",
" 'content-type': 'application/x-www-form-urlencoded; charset=utf-8',",
" cookie: '$3',",
" },",
" success: res => {",
" $4",
" },",
" failure: err => {",
" $5",
" }",
"})$6"
],
"description": "简化http-post请求"
},
"CORSajax-get": {
"scope": "javascript,typescript",
"prefix": "corsget",
"body": [
"CORSajax.get({",
" proxy_link: '$1',",
" proxy_querystring: {",
" $2",
" },",
" proxy_headers: {",
" Cookie: '$3'",
" },",
"},chunk => {",
" $4",
"})$5"
],
"description": "简化跨域Ajax本地nodejsのget代理"
},
"CORSajax-post": {
"scope": "javascript,typescript",
"prefix": "corspost",
"body": [
"CORSajax.post({",
" proxy_link: '$1',",
" proxy_headers: {",
" 'content-type': 'application/x-www-form-urlencoded; charset=utf-8',",
" cookie: '$2'",
" },",
" proxy_body: {",
" $3",
" },",
"},chunk => {",
" $4",
"})$5"
],
"description": "简化跨域Ajax本地nodejsのpost代理"
},
"Ajax-get": {
"scope": "javascript,typescript",
"prefix": "myget",
"body": [
"Ajax.get({",
" url: '$1',",
" queryStringsObj: {",
" $2",
" },",
" hasCookies: true,",
" success: responseText => {",
" $3",
" }",
"})",
],
"description": "简化AjaxのGet请求"
},
"Ajax-post": {
"scope": "javascript,typescript",
"prefix": "mypost",
"body": [
"Ajax.post({",
" url: '$1',",
" hasCookies: true,",
" dataType: 'application/x-www-form-urlencoded',",
" data: {",
" $2",
" },",
" success: responseText => {",
" $3",
" }",
"})",
],
"description": "简化Ajaxのpost请求"
},
}
-14
View File
@@ -1,14 +0,0 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "启动程序",
"skipFiles": [
"<node_internals>/**"
],
"program": "${file}"
}
]
}
+593
View File
@@ -0,0 +1,593 @@
<!-- markdownlint-disable MD036 MD024-->
# CHANGELOG
## 主要变化(2.3.1)
## 问题修复
- 该动态不能转发分享(#60)
- 发布的动态内容未序列化(#47)
## 较上一版本变化
- `env.js`
- `my_config.js`
**替换可执行文件**
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
**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`
**替换可执行文件和更改配置文件(建议修改)**
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
**Full Changelog**: <https://github.com/shanmiteko/LotteryAutoScript/compare/v2.2.5...v2.2.6>
## 主要变化(2.2.5)
## 问题修复
- 因黑名单而关注失败(#45)
## 较上一版本变化
- `env.js`
- `my_config.js`
**替换可执行文件**
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
**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` 随机动态间隔
**替换可执行文件和更改配置文件(建议修改)**
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
**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`
**替换可执行文件和更改配置文件(建议修改)**
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
**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`
**替换可执行文件和更改配置文件(建议修改)**
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
**Full Changelog**: <https://github.com/shanmiteko/LotteryAutoScript/compare/v2.2.1...v2.2.2>
## 主要变化(2.2.1)
- 动态不存在时出错(#39)
## 较上一版本变化
- `env.js`
- `my_config.js`
**替换可执行文件**
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
**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
**替换可执行文件和更改配置文件(建议修改)**
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化(2.1.8)
- 设置支持热更新(#29)
## 较上一版本变化
- `env.js`文件格式更改
- `my_config.js`文件格式更改
**替换可执行文件和更改配置文件(建议修改)**
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化(2.1.7)
- 设置支持热更新(#29)
## 较上一版本变化
- `env.js`文件格式更改
- `my_config.js`
**替换可执行文件和更改env.js**
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化(2.1.6)
- 新增设置not_check_article(#25)
## 较上一版本变化
- `env.js`
- `my_config.js`新增设置not_check_article
**替换可执行文件和更改my_config.js**
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化(2.1.5)
- 修复之前无法更新的问题
## 较上一版本变化
- `env.js`
- `my_config.js`
**仅需替换可执行文件**
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化(2.1.4)
- 黑名单处理(#22)
## 较上一版本变化
- `env.js`
- `my_config.js`
**仅需替换可执行文件**
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化(2.1.3)
- 错误码变更(#20)
## 较上一版本变化
- `env.js`
- `my_config.js`
**仅需替换可执行文件**
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化(2.1.2)
- 支持arm平台运行
- 改变账号异常应对策略
- 修改dingtalk签名base64问题(#17)
## 较上一版本变化
- `env.js`
- `my_config.js`
**仅需替换可执行文件**
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化(2.1.1)
- 获取未读私信接口变化
## 较上一版本变化
- `env.js`
- `my_config.js`
**仅需替换可执行文件**
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化(2.1.0)
- 修复两处问题
## 较上一版本变化
- `env.js`
- `my_config.js`
**仅需替换可执行文件**
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化(2.0.9)
- 账号异常自动切换线路(#14)
## 较上一版本变化
- `env.js`
- `my_config.js`
**仅需替换可执行文件**
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化(2.0.8)
- 账号异常时未处理和发送通知
## 较上一版本变化
- `env.js`
- `my_config.js`
**仅需替换可执行文件**
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化(2.0.7)
- 修复一处问题
- 日志时间UTC+8(#13)
## 较上一版本变化
- `env.js`
- `my_config.js`
**仅需替换可执行文件**
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化
- 支持更新检查
- 增加设置`update_loop_wait`
## 较上一版本(v2.0.5)变化
- `env.js`
- `my_config.js`增加设置`update_loop_wait`
**替换可执行文件和更新my_config.js**
_如果之前版本小于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
## 较上一版本(2.0.1)变化
`env.js`
`my_config.js`
**仅需替换可执行文件**
## 新增特性
增加两处自定义设置(`my_config.js`)
- `clear_quick_remove_attention`
- `notice_key_words`
## 问题修复
# 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`
只需替换可执行文件
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
fix: 开奖时间过滤失效
# 1.7
change 修复一处bug
change 重新上传zip
change 重新上传zip
## 1.6
perf: 重构代码
- 分离动态筛选部分的网络请求和数据处理
- 优化部分ifelse判断
feat:
- 新增NOT_GO_LOTTERY环境变量
- 边转边存dyid
- 滤除的dyid也进行存储
fix: 修复部分bug
## 1.5
feat: 日志相关
- 彩色输出
- 环境变量LOTTERY_LOG_LEVEL更改日志等级
feat: 设置相关
- lottery_loop_wait 抽奖循环
- check_loop_wait 检奖循环
- clear_loop_wait 清理循环
## 1.4
fix: 部分动态无法获取描述
## 1.3
feat: 新增loop_wait设置
可执行文件压缩包
# 命令行工具
可执行文件压缩包
可执行文件压缩包
+64 -24
View File
@@ -1,5 +1,4 @@
# AutoScript
- [AutoScript](#autoscript)
- [操作步骤](#操作步骤)
- [获取COOKIE](#获取cookie)
@@ -17,15 +16,30 @@
[Github仓库链接](https://github.com/shanmiteko/LotteryAutoScript)
已实现功能:
> 点赞 评论 转发 @好友 带话题 随机动态 检测开奖 清理
[![Package Node.js project into an executable](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/pkg.yml/badge.svg)](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/pkg.yml)<br>
[![Build and push Docker images](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/docker.yml/badge.svg)](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/docker.yml)<br>
[![Publishing to NPM](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/npmp.yml/badge.svg)](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/npmp.yml)
声明: 此脚本仅用于学习和测试,作者本人并不对其负责,请于运行测试完成后自行删除,请勿滥用!
已实现功能:
- 监控用户转发
- 监控话题页面
- 监控专栏合集
- 自动点赞、评论、乱序转发、@好友、带话题、可选随机动态
- 检测是否中奖
- 已读@
- 已读私信
- 清理动态关注
- 检查更新
- 更多功能设置请参考配置文件
----------------------------------------
**声明**: 此脚本仅用于学习和测试,作者本人并不对其负责,请于运行测试完成后自行删除,请勿滥用!
---------------------------------
## 操作步骤
**使用前务必阅读此教程和配置文件内注释**
右上角<kbd>★ Star</kbd>
↓↓
@@ -42,7 +56,7 @@ Chrome浏览器:
(此步骤是为了方便后续采用JS获取Cookies,获取完毕后应再次勾选)
![取消httponly](doc/pic/getCookies.png)
![取消httponly](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/getCookies.png)
3. 在Console中复制以下代码回车
@@ -70,20 +84,41 @@ 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)]压缩包并解压后有三个文件
1. [[下载](https://github.com/shanmiteko/LotteryAutoScript/releases)|[cnpmjs镜像下载](https://github.com.cnpmjs.org/shanmiteko/LotteryAutoScript/releases)|[Fastgit镜像下载](https://hub.fastgit.org/shanmiteko/LotteryAutoScript/releases)]压缩包并解压后
```
env.js 便捷设置环境变量和多账号参数
lottery.exe 可执行文件
my_config.js 自定义设置文件
~/nlts-linux-x64
=> tree
.
├── env.js (便捷设置环境变量和多账号参数)
├── lottery (可执行文件)
├── my_config.js (自定义设置文件) (!使用前必读)
└── README.md (说明文件)
```
2. 用记事本或其他编辑器修改`env.js`和`my_config.js`文件(右键选择用记事本打开)
3. 在`env.js`中填入`COOKIE`和推送参数
4. 在`my_config.js`中自定义设置
5. 在当前目录下**打开终端**运行可执行文件`lottery`(勿直接点击`lottery`)
6. 键入`lottery start`启动抽奖|`lottery check`检测中奖|`lottery clear`清理动态
> 或者新建文本文档写入`lottery start`然后更改扩展名为.bat点击运行
```sh
# unix-like
## 进入脚本所在目录
## 授予执行权限
$ chmod u+x lottery
## 启动脚本
$ ./lottery start
## 检测中奖
$ ./lottery check
## 清理关注动态
$ ./lottery clear
## 下载最新版本
$ ./lottery clear
# windows
## 不需要chmod
## 把`./`换成`.\`或去掉
## 已自带*.bat可直接点击
```
7. 运行截图
![lottery_start](doc/pic/lottery_start.png)
![lottery_start](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/lottery_start.png)
#### 以源码方式运行
@@ -97,7 +132,7 @@ step1: 下载代码到本地
[点此下载](https://github.com/shanmiteko/LotteryAutoScript/archive/refs/heads/main.zip)或如图示下载↓
![点我加载下载操作图示](doc/pic/download.png)
![点我加载下载操作图示](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/download.png)
下载的压缩包解压后修改env.example.js文件,详见step3
@@ -105,7 +140,7 @@ step2: 下载并安装Node.js
[点此进入nodejs下载页面](http://nodejs.cn/download)
![点我加载下载nodejs操作图示](doc/pic/nodejs.png)
![点我加载下载nodejs操作图示](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/nodejs.png)
step3:修改env.example.js文件及创建运行文件(打开扩展名显示)
@@ -156,12 +191,12 @@ npm i && npm run clear
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 | sh
```
进入`lottery`文件夹
```bash
cd lottery
$ cd lottery
```
编辑`env.js`与`my_config.js`文件
@@ -173,7 +208,7 @@ cd lottery
例如:
```bash
./start.sh
$ ./start.sh
```
2.更新
@@ -187,14 +222,19 @@ cd lottery
进入lottery上一级目录
```bash
docker image rm -f shanmite/lottery_auto_docker
rm -rf lottery/
$ docker image rm -f shanmite/lottery_auto_docker
$ rm -rf lottery/
```
----------------------------------------
## 防重复转发
脚本将转发过的动态和被过滤的动态都写入`dyids/dyid*.txt`文件中
~~存储在专栏草稿~~
~~脚本将转发过的动态和被过滤的动态都写入`dyids/dyid*.txt`文件中~~
是否点赞
----------------------------------------
@@ -217,14 +257,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/) |
@@ -242,4 +282,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
View File
@@ -4,16 +4,16 @@
.首先在Telegram上搜索[BotFather](https://t.me/BotFather)机器人<br>
![TG_PUSH1](pic/TG_PUSH1.png)
![TG_PUSH1](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/TG_PUSH1.png)
Ⅱ.利用[BotFather](https://t.me/BotFather)创建一个属于自己的通知机器人,按照下图中的1、2、3步骤拿到token,格式形如```10xxx4:AAFcqxxxxgER5uw```。填入```TG_BOT_TOKEN```<br>
![TG_PUSH2](pic/TG_PUSH2.png)<br>
![TG_PUSH2](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/TG_PUSH2.png)<br>
**新创建的机器人需要跟它发一条消息来开启对话,否则可能会遇到secret填对了但是收不到消息的情况**<br>
Ⅲ.再次在Telegram上搜索[getuserIDbot](https://t.me/getuserIDbot)机器人,获取UserID。填入```TG_USER_ID```<br>
![TG_PUSH3](pic/TG_PUSH3.png)
![TG_PUSH3](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/TG_PUSH3.png)
至此,获取**TG_BOT_TOKEN**以及**TG_USER_ID**的教程结束
+14 -15
View File
@@ -10,15 +10,14 @@
2.下载脚本到本地
```sh
git clone https://github.com/shanmite/LotteryAutoScript.git
git clone https://github.com/shanmiteko/LotteryAutoScript.git
```
![image_download](pic/image_download.png)
**注意**: 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的使用手册
```
![image-envjs](pic/image-envjs.png)
详见[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
![crontab](pic/crontab.png)
`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
看看有没有效果
![image-start](pic/image-start.png)
![image-start](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/image-start.png)
7.如果本地的脚本需要更新
@@ -83,4 +82,4 @@ crontab -e
```sh
git pull
```
```
Binary file not shown.

Before

Width:  |  Height:  |  Size: 123 KiB

After

Width:  |  Height:  |  Size: 274 KiB

+3 -3
View File
@@ -16,13 +16,13 @@
7.在`操作`页面中点击`新建`,选择操作为`启动程序`,在设置里点击浏览找到`start.bat`文件并选择,在`起始于(可选)(T)`中的空白框里输入`start.bat`文件的目录地址,也就是`程序或脚本(P)``start.bat`的前面那一串目录地址,最后是以`\`结尾的 ,填好东西后按下面`确认`
![点我加载步骤7结果图示](pic/step_menu.png)
![点我加载步骤7结果图示](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/step_menu.png)
8.在`条件`页面中选择`网络`,设定启动条件为任何连接
9.在`设置`页面中选择如图示选项,或者不修改默认设置
![点我加载步骤9结果图示](pic/shezhi_renwu.png)
![点我加载步骤9结果图示](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/shezhi_renwu.png)
10.最后按`确定`
@@ -30,6 +30,6 @@
最后你可以在任务列表中选择已有的任务,右边的操作框中选择`运行`点击,启动计划的任务,如下图所示
![点我加载运行图示](pic/start_renwu.png)
![点我加载运行图示](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/start_renwu.png)
具体看任务是否正常执行,你可以看看自己的账号动态的最新转发,运行成功每几分钟自动转发抽奖动态
+63 -82
View File
@@ -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 };
})
+32 -25
View File
@@ -1,54 +1,61 @@
const { log, delay, infiniteNumber } = require('./utils')
const { log, delay, infiniteNumber, judge } = require('./utils')
const { sendNotify } = require('./helper/notify')
const config = require('./data/config')
const global_var = require('./data/global_var')
const bili_client = require('./net/bili')
const bili = require('./net/bili')
/**
* 是否中奖
*/
async function isMe() {
let desp = '';
const UnreadAtNum = await bili_client.getUnreadAtNum();
const UnreadSessionNum = await bili_client.getUnreadSessionNum();
const { follow_unread, unfollow_unread } = UnreadSessionNum || { unfollow_unread: 0, follow_unread: 0 };
const
{ notice_key_words, update_session_wait, get_session_wait } = config,
UnreadAtNum = await bili.getUnreadAtNum(),
UnreadSessionNum = await bili.getUnreadSessionNum(),
{ follow_unread, unfollow_unread } = UnreadSessionNum || { unfollow_unread: 0, follow_unread: 0 };
if (UnreadAtNum > 0) {
log.info('中奖检测', '<-- 正在检查at');
const MyAtInfo = await bili_client.getMyAtInfo();
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');
}
if (follow_unread + unfollow_unread > 0) {
const check = async (type) => {
let session_t = '';
let MySession = await bili_client.getSessionInfo(type)
let MySession = await bili.getSessionInfo(type)
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_client.updateSessionStatus(talker_id, type, msg_seqno);
await delay(1000);
if (config.notice_key_words.some(it => new RegExp(it).test(content))) {
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`
const content = await bili.fetch_session_msgs(talker_id, unread_count);
if (judge(content, notice_key_words)) {
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) {
await delay(3e3);
MySession = await bili_client.getSessionInfo(type, session_t)
await delay(get_session_wait);
MySession = await bili.getSessionInfo(type, session_t)
} else {
break
}
@@ -69,7 +76,7 @@ async function isMe() {
log.info('可能中奖了', desp);
await sendNotify('可能中奖了', desp);
} else {
log.info('中奖检测', "未中奖");
log.info('中奖检测', "未中奖");
}
return;
}
+29 -17
View File
@@ -9,20 +9,22 @@ const config = require("./data/config");
* @returns { Promise<number[]> }
*/
async function getFollowList() {
const tagid = await bili.checkMyPartition(config.clear_partition);
const
{ clear_partition, clear_white_list, get_partition_wait } = config,
tagid = await bili.checkMyPartition(clear_partition);
let rmup = [];
if (typeof tagid === 'undefined') {
log.info('获取关注列表', '未能成功获取关注分区id');
return
return rmup
}
let rmup = [];
for (let index = 1; index < 42; index++) {
const uids = await bili.getPartitionUID(tagid, index);
await delay(2e3);
await delay(get_partition_wait);
if (!uids.length) break;
rmup.push(...uids)
}
return config.clear_white_list.length
? rmup.filter(uid => config.clear_white_list.split(',').indexOf(String(uid)) === -1)
return clear_white_list.length
? rmup.filter(uid => clear_white_list.split(',').indexOf(String(uid)) === -1)
: rmup;
}
@@ -30,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) {
@@ -63,15 +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 || {};
if (type === clear_dynamic_type) {
const
{ origin_uid } = dyinfo,
days_ago = (Now - createtime) / 86400;
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 days_ago = (Now - create_time) / 86400;
if (days_ago > clear_max_day) {
/* 移除动态 */
@@ -90,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}`)
+116 -68
View File
@@ -1,12 +1,11 @@
const utils = require('../utils');
const { log, hasEnv, shuffle, getRandomOne, delay, try_for_each } = require('../utils');
const bili = require('../net/bili');
const { sendNotify } = require('../helper/notify');
const event_bus = require('../helper/event_bus');
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');
const { log, hasEnv } = utils;
/**
* 监视器
@@ -52,13 +51,14 @@ class Monitor extends Searcher {
event_bus.emit('Turn_off_the_Monitor', '评论失败')
break
case 21:
event_bus.emit('Turn_on_the_Monitor')
event_bus.emit('Turn_off_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
, { create_dy, create_dy_mode, wait, filter_wait } = config;
log.info('筛选动态', `筛选完毕(${len})`);
if (len) {
for (const Lottery of utils.shuffle(allLottery)) {
let is_exception = false;
for (const [index, Lottery] of 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,12 @@ class Monitor extends Searcher {
}
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]) {
@@ -111,19 +114,41 @@ class Monitor extends Searcher {
}
if (followerNum < config.minfollower) {
log.info('过滤', `粉丝数(${followerNum})小于指定数量`)
d_storage.updateDyid(Lottery.dyid)
await delay(filter_wait)
continue
}
}
status = await this.go(Lottery)
if (status % 2 !== 0) {
return status
if (create_dy
&& create_dy_mode instanceof Array
&& index > 0
&& index % getRandomOne(create_dy_mode[0]) === 0
) {
const number = getRandomOne(create_dy_mode[1]) || 0;
randomDynamic(number)
}
d_storage.updateDyid(Lottery.dyid);
await utils.delay(config.wait * (Math.random() + 0.5));
status = await this.go(Lottery)
switch (status) {
case 0:
case 9:
case 19:
break;
case 22:
is_exception = true
break;
default:
return status
}
await delay(wait * (Math.random() + 0.5));
}
log.info('抽奖', '开始转发下一组动态');
return 0
if (is_exception) {
return 22
} else {
return 0
}
} else {
log.info('抽奖', '无未转发抽奖');
return 0
@@ -146,6 +171,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)
@@ -157,8 +185,13 @@ class Monitor extends Searcher {
/** 所有抽奖信息 */
let alllotteryinfo = [];
const { key_words, model, chatmodel, is_imitator, only_followed, at_users, blockword, blacklist } = config;
/**Map<String, Boolean> */
const
{ key_words, model, chatmodel, max_create_time, is_imitator, only_followed, at_users, blockword, blacklist } = config,
now_ts = Date.now() / 1000;
/**
* @type {Map<String, Boolean>}
*/
let dyids_map = new Map();
/**去重 */
@@ -170,41 +203,35 @@ 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,
await try_for_each(protoLotteryInfo, async function ({
lottery_info_type, is_liked,
uids, uname, dyid, create_time,
ctrl, rid, des, type,
hasOfficialLottery
}) {
/* 遇到转发过就退出 */
if (dyids_map.get(dyid)) return false;
if (is_liked) return false;
/* 超过指定时间退出 */
if (now_ts - create_time > max_create_time * 86400) 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');
@@ -239,7 +266,7 @@ class Monitor extends Searcher {
let
/**转发评语 */
RandomStr = utils.getRandomOne(config.relay),
RandomStr = getRandomOne(config.relay),
/**控制字段 */
new_ctrl = [];
@@ -308,7 +335,9 @@ class Monitor extends Searcher {
* @param {LotteryOptions} option
* @returns {Promise<number>}
* 0 - 成功
* 9 - 评论黑名单/评论区关闭/动态删除
* 11 - 评论错误
* 19 - 关注黑名单
* 21 - 关注错误
* 22 - 关注异常
* 31 - 转发失败
@@ -319,36 +348,55 @@ class Monitor extends Searcher {
log.info('NOT_GO_LOTTERY', 'ON');
return 0
}
const { uid, dyid, chat_type, rid, relay_chat, ctrl } = option;
/* 评论 */
if (rid && chat_type) {
let status = 0;
const max_retry_times = 5;
for (let times = 0; times < max_retry_times; times++) {
status = await bili.sendChat(rid, utils.getRandomOne(config.chat), chat_type)
if (!status) {
break
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
}
log.info('自动评论', `将在 ${times + 1} 分钟后再次发送评论(${times + 1}/${max_retry_times})`)
await utils.delay(60 * 1000 * (times + 1))
}
if (status) return 11;
})
if (status) return 10 + status;
}
/* 关注 */
const [u1, u2] = uid
if (u1) {
let status = await bili.autoAttention(u1)
if (status) return 20 + status;
status = await bili.movePartition(u1, this.tagid)
if (status) return 20 + status;
if (u2) {
utils.delay(5000)
status = await bili.autoAttention(u2)
if (status) return 20 + status;
status = await bili.movePartition(u2, this.tagid)
if (status) return 20 + 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) return 20 + status
}
/* 点赞 */
+115 -67
View File
@@ -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,14 +10,15 @@ const { log } = utils
* @typedef {object} UsefulDynamicInfo
* @property {number} uid
* @property {string} uname
* @property {number} createtime 10
* @property {boolean} is_liked
* @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 +27,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}
*/
@@ -35,15 +49,18 @@ function parseDynamicCard(dynamic_detail_card) {
/**临时储存单个动态中的信息 */
let obj = {};
const { desc, card, extension, extend_json } = dynamic_detail_card
, { info } = desc.user_profile
, { is_liked = 1, user_profile = {} } = desc
, { info = {} } = user_profile
, cardToJson = strToJson(card)
, { item } = cardToJson;
/* 转发者的UID */
obj.uid = info.uid;
obj.uid = desc.uid
/* 转发者的name */
obj.uname = info.uname;
obj.uname = info.uname || ''
/* 动态是否点过赞 */
obj.is_liked = is_liked > 0
/* 动态的ts10 */
obj.createtime = desc.timestamp
obj.create_time = desc.timestamp
/* 动态类型 */
obj.type = desc.type
/* 用于发送评论 */
@@ -62,6 +79,8 @@ function parseDynamicCard(dynamic_detail_card) {
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(用于发评论) */
@@ -86,8 +105,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);
@@ -128,19 +147,6 @@ function modifyDynamicRes(res) {
*/
class Searcher {
constructor() { }
/**
* 整理后的抽奖信息
* @typedef {object} LotteryInfo
* @property {string} lottery_info_type
* @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
@@ -211,23 +217,55 @@ class Searcher {
*/
async getLotteryInfoByUID(UID) {
log.info('获取动态', `开始获取用户${UID}的动态信息`);
const { allModifyDynamicResArray } = await Searcher.checkAllDynamic(UID, config.uid_scan_page, config.search_wait);
const
{ uid_scan_page, search_wait, get_dynamic_detail_wait } = config,
{ allModifyDynamicResArray } = await Searcher.checkAllDynamic(UID, uid_scan_page, 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(get_dynamic_detail_wait)
const { is_liked } = parseDynamicCard(card)
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
}, 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;
@@ -240,6 +278,7 @@ 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);
@@ -255,7 +294,7 @@ class Searcher {
let mDRdata = modDR.modifyDynamicResArray;
let next_offset = modDR.nextinfo.next_offset;
for (let index = 0; index < config.tag_scan_page; index++) {
for (let index = 0; index < tag_scan_page; index++) {
log.info('获取动态', `读取第${index + 1}页动态`);
const
newdy = await bili.getOneDynamicInfoByTag(tag_name, next_offset),
@@ -266,11 +305,13 @@ class Searcher {
mDRdata.push.apply(mDRdata, _modify.modifyDynamicResArray);
next_offset = _modify.nextinfo.next_offset;
await utils.delay(config.search_wait);
await utils.delay(search_wait);
}
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,
ctrl: o.ctrl,
@@ -292,9 +333,13 @@ class Searcher {
*/
async getLotteryInfoByArticle(key_words) {
log.info('获取动态', `开始获取含关键词${key_words}的专栏信息`);
const cvs = (await bili.searchArticlesByKeyword(key_words)).slice(0, config.article_scan_page);
const
{ article_scan_page, not_check_article, get_dynamic_detail_wait } = config,
cvs = (await bili.searchArticlesByKeyword(key_words)).slice(0, article_scan_page);
/**存储所有专栏中的dyid */
let dyinfos = [];
/**遍历专栏s */
for (const cv of cvs) {
const
content = await bili.getOneArticleByCv(cv),
@@ -304,46 +349,49 @@ 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(get_dynamic_detail_wait)
const parsed_card = parseDynamicCard(card)
, { is_liked } = parsed_card;
if (is_liked) {
log.info('获取动态', `动态(${dyid})已转发过`)
_weight += 1;
}
if (_weight >= weight && !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',
create_time: o.create_time,
is_liked: o.is_liked,
uids: [o.uid, o.origin_uid],
uname: o.uname,
ctrl: o.ctrl,
@@ -361,4 +409,4 @@ class Searcher {
}
module.exports = { Searcher };
module.exports = { Searcher };
+311 -6
View File
@@ -1,19 +1,324 @@
const { config_file } = require('../utils');
const my_config = require(config_file);
const config = {
...my_config["default_config"],
/**
* 监视更转的用户uid
*/
UIDs: [],
/**
* 监视的专栏关键词
*/
Articles: [],
/**
* 监视的tag
*/
TAGs: [],
/**
* 动态中的关键词(表示须同时满足以下条件)
* 符合js正则表达式的字符串
*/
key_words: [
"[抽奖]",
"[转关].*[转关]"
],
/**
* - '00' 关闭自动抽奖
* - '10' 只转发官方抽奖
* - '01' 只转发非官方抽奖
* - '11' 都转
*/
model: '11',
/**
* - '00'关闭自动评论
* - '10'只评论官抽
* - '01'只评论非官抽
* - '11'都评论
*/
chatmodel: '01',
/**
* - 动态创建时间
* - 多少天前
*/
max_create_time: 60,
/**
* 不加判断的转发所监视的uid转发的动态
*/
is_imitator: false,
/**
* - 在uid里检索的页数
*/
uid_scan_page: 3,
/**
* - 在tag里检索的页数
*/
tag_scan_page: 3,
/**
* - 获取专栏数量
*/
article_scan_page: 3,
/**
* - 不检查专栏是否看过,若选择检查可以提高检测效率
* - 默认false(检查)
*/
not_check_article: false,
/**
* - 开奖时间距离现在的最大天数
* - 默认不限制
*/
maxday: Infinity,
/**
* - 循环等待时间(指所有操作完毕后的休眠时间)
* - 单位毫秒
*/
lottery_loop_wait: 0,
check_loop_wait: 0,
clear_loop_wait: 0,
update_loop_wait: 0,
/**
* - 转发间隔时间
* - 单位毫秒
* - 上下浮动50%
*/
wait: 30 * 1000,
/**
* - 检索动态间隔
* - 单位毫秒
*/
search_wait: 2000,
/**
* - 读取下一页私信间隔
* - 单位毫秒
*/
get_session_wait: 3000,
/**
* - 已读私信间隔
* - 单位毫秒
*/
update_session_wait: 1000,
/**
* - 读取下一页关注列表间隔
* - 单位毫秒
*/
get_partition_wait: 2000,
/**
* - 获取动态细节间隔
* - 单位毫秒
*/
get_dynamic_detail_wait: 2000,
/**
* - 过滤间隔(开奖时间/粉丝数)
* - 单位毫秒
*/
filter_wait: 1000,
/**
* - 随机动态间隔
* - 单位毫秒
*/
random_dynamic_wait: 2000,
/**
* - up主粉丝数限制
*/
minfollower: 1000,
/**
* - 只转发已关注的
*/
only_followed: false,
/**
* - 是否发送随机动态(防止被开奖机过滤)
*/
create_dy: false,
/**
* 随机动态类型
* - 0 自定义文字与图片
* - 1 推荐视频
* - -1 混合
*/
create_dy_type: 0,
/**
* - 结束运行时发送随机动态的数量
*/
create_dy_num: 1,
/**
* - 随机动态内容
* - 类型 `content[]`
* @typedef Picture
* @property {string} img_src 站内源
* @property {number} img_width
* @property {number} img_height
* @param { string | Picture[] } content
*/
dy_contents: ['[doge]', '[doge][doge]'],
/**
* - 每转发x条抽奖动态就发送x条随机动态
* - @example [[10,11,9],[6,8,9]] 每转发9,10,11条抽奖动态就发送6,8,9条随机动态
*/
create_dy_mode: [[0], [0]],
/**
* 转发时[at]的用户
*/
at_users: [['转发抽奖娘', 294887687], ['你的工具人老公', 100680137]],
/**
* - 自动同步 https://gitee.com/shanmite/lottery-notice/raw/master/notice.json
* - 英文逗号分隔 如: 1,2,3
*/
blacklist: '',
/**
* 屏蔽词
*/
blockword: ["脚本抽奖", "恭喜", "结果", "抽奖号", "钓鱼", "涨粉"],
/**
* 转发评语
*/
relay: ['转发动态'],
/**
* 评论内容
*/
chat: [
'[OK]', '[星星眼]', '[歪嘴]', '[喜欢]', '[偷笑]', '[笑]', '[喜极而泣]', '[辣眼睛]', '[吃瓜]', '[奋斗]',
'永不缺席 永不中奖 永不放弃!', '万一呢', '在', '冲吖~', '来了', '万一', '[保佑][保佑]', '从未中,从未停', '[吃瓜]', '[抠鼻][抠鼻]',
'来力', '秋梨膏', '[呲牙]', '从不缺席', '分子', '可以', '恰', '不会吧', '1', '好',
'rush', '来来来', 'ok', '冲', '凑热闹', '我要我要[打call]', '我还能中!让我中!!!', '大家都散了吧,已经抽完了,是我的', '我是天选之子', '给我中一次吧!',
'坚持不懈,迎难而上,开拓创新!', '[OK][OK]', '我来抽个奖', '中中中中中中', '[doge][doge][doge]', '我我我',
],
/**
* - 抽奖UP用户分组id(网页端点击分区后地址栏中的tagid)
* - 自动获取
*/
partition_id: 0,
/**
* 是否关注异常
*/
is_exception: false,
/**
* - 中奖通知关键词(满足一个就推送)
* - 符合js正则表达式的字符串
* - 若以 ~ 开头则表示为黑名单规则
* - 优先级递增
*/
notice_key_words: [
"~预约成功|预约主题",
"中奖|获得|填写|写上|提供|收货地址|支付宝账号|码|大会员"
],
/**
* - 清理白名单uid或dyid
* - 英文逗号分隔 如: 1,2,3
*/
clear_white_list: '',
/**
* - 取关分区
* - 默认为: 此处存放因抽奖临时关注的up
*/
clear_partition: '',
/**
* 清理多少天之前的动态或关注
*/
clear_max_day: 30,
/**
* - 快速移除关注
* - 不加判断只去除关注
*/
clear_quick_remove_attention: false,
/**
* 是否移除动态
*/
clear_remove_dynamic: true,
/**
* 是否移除关注
*/
clear_remove_attention: true,
/**
* 清除动态延时(毫秒)
*/
clear_remove_delay: 8000,
/**
* 清除动态类型
*
* | 动态类型 | type值 |
* | :------- |:----- |
* | 无 | `0` |
* | 转发 | `1` |
* | 含图片 | `2` |
* | 无图纯文字 | `4` |
* | 视频 | `8` |
* | 番剧 | `512` |
* | 活动 | `2048` |
* | 专栏 | `64` |
*
* @example
* 1
* [1,2,4]
*/
clear_dynamic_type: [1],
/**
* 原始设置
* @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)
}
};
+34
View File
@@ -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;
+2 -5
View File
@@ -1,4 +1,4 @@
const { getRemoteConfig, createDir, createFile } = require("../utils");
const { getRemoteConfig } = require("../utils");
const config = require("../data/config");
const key_map = new Map([['DedeUserID', 'myUID'], ['bili_jct', 'csrf']]);
@@ -15,9 +15,8 @@ let global_var = {
* 全局变量初始化
* 更新config
* @param {string} cookie
* @param {number} n
*/
async init(cookie, n) {
async init(cookie) {
if (cookie) {
config.updata(process.env.NUMBER);
@@ -37,8 +36,6 @@ let global_var = {
]);
this.set('remoteconfig', await getRemoteConfig());
}
await createDir('dyids');
await createFile(n < 2 ? 'dyid.txt' : `dyid${n}.txt`, '', 'a')
}
};
-52
View File
@@ -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
View File
@@ -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推送消息通知');
}
}
+39
View File
@@ -0,0 +1,39 @@
const config = require("../data/config");
const bili = require("../net/bili");
const utils = require("../utils");
/**
* 随机动态
* @param {number} num
* @returns
*/
async function randomDynamic(num) {
const { create_dy_type, dy_contents, random_dynamic_wait } = config;
if (create_dy_type === -1 || create_dy_type === 0 || typeof create_dy_type === 'undefined') {
for (let index = 0; index < num; index++) {
await bili.createDynamic(utils.getRandomOne(dy_contents));
await utils.delay(random_dynamic_wait);
}
}
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
} else {
return true
}
})
}
}
module.exports = { randomDynamic }
+3 -2
View File
@@ -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 -6
View File
@@ -1,10 +1,10 @@
const utils = require('./utils');
const bili = require('./net/bili');
const event_bus = require('./helper/event_bus');
const global_var = require('./data/global_var');
const { Searcher } = require('./core/searcher');
const { Monitor } = require('./core/monitor');
const config = require('./data/config');
const { randomDynamic } = require('./helper/randomDynamic');
const { log } = utils;
async function createRandomDynamic(num) {
@@ -12,10 +12,7 @@ async function createRandomDynamic(num) {
log.info('随机动态', `准备创建${num}条随机动态`);
const Dynamic = await Searcher.checkAllDynamic(global_var.get("myUID"), 1);
if ((Dynamic.allModifyDynamicResArray[0] || { type: 0 }).type === 1) {
for (let index = 0; index < num; index++) {
await bili.createDynamic(utils.getRandomOne(config.dy_contents));
await utils.delay(2000);
}
await randomDynamic(num)
} else {
log.info('随机动态', '已有非抽奖动态故无需创建');
}
@@ -39,7 +36,6 @@ function start() {
return;
}
if (times.value() === lotterys.length) {
await createRandomDynamic(config.create_dy_num);
log.info('抽奖', '所有动态转发完毕');
times.clear();
event_bus.emit('Turn_off_the_Monitor', '目前无抽奖信息,过一会儿再来看看吧')
+5 -2
View File
@@ -1,11 +1,13 @@
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_REPOST_SHARE: 'https://api.vc.bilibili.com/dynamic_repost/v1/dynamic_repost/share',
DYNAMIC_SVR_CREATE_DRAW: 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/create_draw',
DYNAMIC_SVR_CREATE: 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/create',
DYNAMIC_SVR_GET_DYNAMIC_DETAIL: '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',
@@ -25,8 +27,9 @@ module.exports = {
SESSION_SVR_UPDATE_ACK: 'https://api.vc.bilibili.com/session_svr/v1/session_svr/update_ack',
SPACE_MYINFO: 'https://api.bilibili.com/x/space/myinfo',
TAG_INFO: 'https://api.bilibili.com/x/tag/info',
TOP_RCMD: "https://api.bilibili.com/x/web-interface/index/top/rcmd",
TOPIC_SVR_TOPIC_HISTORY: 'https://api.vc.bilibili.com/topic_svr/v1/topic_svr/topic_history',
TOPIC_SVR_TOPIC_NEW: 'https://api.vc.bilibili.com/topic_svr/v1/topic_svr/topic_new',
WEB_INTERFACE_CARD: 'https://api.bilibili.com/x/web-interface/card',
WEB_INTERFACE_SEARCH_TYPE: 'https://api.bilibili.com/x/web-interface/search/type',
}
})
+635 -480
View File
File diff suppressed because it is too large Load Diff
+3 -3
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,7 +65,7 @@ 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(),
@@ -82,7 +82,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 = '';
+84
View File
@@ -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 }
+87 -56
View File
@@ -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字符串转为对象
* 超出精度的数转为字符串
@@ -67,10 +77,10 @@ const utils = {
},
/**
* 延时函数
* @param {number} time ms
* @param {number} [time] ms
* @returns {Promise<void>}
*/
delay(time) {
delay(time = 1000) {
utils.log.info('时延', `${~~time}ms`);
return new Promise(resolve => {
setTimeout(() => {
@@ -130,6 +140,20 @@ const utils = {
}
return array;
},
/**
* 关键词判断 优先级递增
* @param {string} text
* @param {string[]} key_words startwith '~' 表示黑名单
* @return {boolean}
*/
judge(text, key_words) {
return key_words.reduce((acc, word) => {
word.startsWith('~')
? RegExp(word.slice(1)).test(text) && (acc = false)
: RegExp(word).test(text) && (acc = true)
return acc
}, false)
},
/**
* 是否有指定环境变量
* @param {string} env_name
@@ -140,7 +164,7 @@ const utils = {
},
/**日志 */
log: {
level: 0,
level: 3,
/**
* 初始化默认level为3
*/
@@ -153,27 +177,78 @@ const utils = {
* @param {String} [split] 分隔符
*/
proPrint(msg, split = ' ') {
console.log([msg].flat().join(split))
if (msg instanceof Array) {
msg = msg.join(split)
}
console.log(msg)
},
/**
* @param {Array<string>} msg
* @returns
*/
rainbow(msg) {
const
colors = ['red', 'yellow', 'green', 'cyan', 'blue', 'magenta'],
colorsCount = colors.length;
this.proPrint(msg.map(it => it.split('').map((l, i) => chalk[colors[i % colorsCount]](l)).join('')), '\n')
},
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>}
@@ -191,14 +266,14 @@ const utils = {
success: res => {
try {
const body = JSON.parse(res.body);
if (body.node_msg) this.log.info('公告', '\n' + body.node_msg + '\n');
if (body.node_msg) utils.log.info('公告', '\n' + body.node_msg + '\n');
resolve(body.config)
} catch (error) {
resolve(JSON.parse('{}'))
}
},
failure: err => {
this.log.error('获取远程设置', '获取远程设置错误: ' + err);
utils.log.error('获取远程设置', '获取远程设置错误: ' + err);
resolve(JSON.parse('{}'));
}
})
@@ -231,50 +306,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' })
}
};
+56 -21
View File
@@ -1,4 +1,4 @@
const { env_file, config_file, log, delay, hasFileOrDir } = require("./lib/utils");
const { version: ve, env_file, config_file, log, hasEnv, delay, hasFileOrDir } = require("./lib/utils");
const metainfo = [
` _ _ _ _____ _ _ `,
@@ -10,8 +10,8 @@ const metainfo = [
` __/ | | | `,
` |___/ |_| `,
` `,
` Verison: v2.0.3`,
` Written by shanmite`,
` Verison: v${ve}`,
` Written By shanmite`,
]
/**多账号存储 */
let multiple_account = [];
@@ -44,21 +44,19 @@ async function main() {
/**多账号状态还原 */
process.env.ENABLE_MULTIPLE_ACCOUNT = ENABLE_MULTIPLE_ACCOUNT;
} else {
if (!COOKIE) {
return '请查看README文件, 在env.js指定位置填入cookie'
}
} else if (COOKIE) {
const global_var = require("./lib/data/global_var");
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('抽奖', '开始运行');
@@ -77,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:
@@ -84,50 +87,82 @@ async function main() {
default:
return `提供了错误的[OPTIONS] -> ${mode}\n\n` + help_msg
}
} else {
log.error('Cookie已失效', '切换账号时不要点击退出账号而应直接删除Cookie退出')
return ''
}
} else {
return '请查看README文件, 在env.js指定位置填入cookie'
}
}
(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')) {
log.init();
log.info('环境变量初始化', '成功从环境变量中读取COOKIE设置');
} else {
log.init();
log.warn('环境变量初始化', '未在当前目录下找到env.js文件 也可在环境变量中设置所需参数');
return
log.error('环境变量初始化', '未在当前目录下找到env.js文件或者在环境变量中设置所需参数');
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.rainbow(metainfo)
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('结束运行', '未设置休眠时间')
log.info('结束运行', '未在config.js中设置休眠时间')
}
process.exit(0);
+80 -12
View File
@@ -1,4 +1,4 @@
module.exports = {
module.exports = Object.freeze({
/**
* 默认设置(公用)
*/
@@ -7,7 +7,6 @@ module.exports = {
* 监视更转的用户uid
*/
UIDs: [
31252386,
689277291,
241675899
],
@@ -54,6 +53,12 @@ module.exports = {
*/
chatmodel: '01',
/**
* - 动态创建时间
* - 多少天前
*/
max_create_time: 60,
/**
* 不加判断的转发所监视的uid转发的动态
*/
@@ -74,6 +79,12 @@ module.exports = {
*/
article_scan_page: 3,
/**
* - 不检查专栏是否看过,若选择检查可以提高检测效率
* - 默认false(检查)
*/
not_check_article: false,
/**
* - 开奖时间距离现在的最大天数
* - 默认不限制
@@ -87,6 +98,7 @@ module.exports = {
lottery_loop_wait: 0,
check_loop_wait: 0,
clear_loop_wait: 0,
update_loop_wait: 0,
/**
* - 转发间隔时间
@@ -99,7 +111,43 @@ module.exports = {
* - 检索动态间隔
* - 单位毫秒
*/
search_wait: 1000,
search_wait: 2000,
/**
* - 读取下一页私信间隔
* - 单位毫秒
*/
get_session_wait: 3000,
/**
* - 已读私信间隔
* - 单位毫秒
*/
update_session_wait: 1000,
/**
* - 读取下一页关注列表间隔
* - 单位毫秒
*/
get_partition_wait: 2000,
/**
* - 获取动态细节间隔
* - 单位毫秒
*/
get_dynamic_detail_wait: 2000,
/**
* - 过滤间隔(开奖时间/粉丝数)
* - 单位毫秒
*/
filter_wait: 1000,
/**
* - 随机动态间隔
* - 单位毫秒
*/
random_dynamic_wait: 2000,
/**
* - up主粉丝数限制
@@ -117,15 +165,21 @@ module.exports = {
create_dy: false,
/**
* - 发送随机动态的数量
* 随机动态类型
* - 0 自定义文字与图片
* - 1 推荐视频
* - -1 混合
*/
create_dy_type: 0,
/**
* - 结束运行时发送随机动态的数量
*/
create_dy_num: 1,
/**
* - 随机动态内容
* - 类型 `content[]`
*/
/**
* @typedef Picture
* @property {string} img_src 站内源
* @property {number} img_width
@@ -134,13 +188,19 @@ module.exports = {
*/
dy_contents: ['[doge]', '[doge][doge]'],
/**
* - 每转发x条抽奖动态就发送x条随机动态
* - @example [[10,11,9],[6,8,9]] 每转发9,10,11条抽奖动态就发送6,8,9条随机动态
*/
create_dy_mode: [[0], [0]],
/**
* 转发时[at]的用户
*/
at_users: [['转发抽奖娘', 294887687], ['你的工具人老公', 100680137]],
/**
* - 同步 https://gitee.com/shanmite/lottery-notice/raw/master/notice.json
* - 自动同步 https://gitee.com/shanmite/lottery-notice/raw/master/notice.json
* - 英文逗号分隔 如: 1,2,3
*/
blacklist: '',
@@ -178,11 +238,14 @@ module.exports = {
is_exception: false,
/**
* 中奖通知关键词(满足一个就推送)
* 符合js正则表达式的字符串
* - 中奖通知关键词(满足一个就推送)
* - 符合js正则表达式的字符串
* - 若以 ~ 开头则表示为黑名单规则
* - 优先级递增
*/
notice_key_words: [
"中奖", "获得", "填写", "写上", "提供", "收货地址", "支付宝账号", "码", "大会员"
"~预约成功|预约主题",
"中奖|获得|填写|写上|提供|收货地址|支付宝账号|码|大会员"
],
/**
@@ -233,10 +296,15 @@ module.exports = {
* | 含图片 | `2` |
* | 无图纯文字 | `4` |
* | 视频 | `8` |
* | 番剧 | `512` |
* | 活动 | `2048` |
* | 专栏 | `64` |
*
* @example
* 1
* [1,2,4]
*/
clear_dynamic_type: 1
clear_dynamic_type: [1]
},
/**
@@ -246,4 +314,4 @@ module.exports = {
config_1: {},
config_2: {},
config_3: {}
}
})
+20 -11
View File
@@ -1,17 +1,26 @@
{
"name": "lottery-in-bili",
"version": "3.0.0",
"description": "自动抽奖",
"name": "lottery-auto-script",
"version": "2.3.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": [
@@ -36,11 +45,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"
}
}
-13
View File
@@ -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
View File
@@ -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
+8
View File
@@ -0,0 +1,8 @@
#!/bin/bash
./lottery update
if [[ -r "latest_version.zip" ]]; then
unzip latest_version.zip
rm latest_version.zip
chmod u+x lottery
fi