Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
04c25a88fc | ||
|
|
9ab605a186 | ||
|
|
a83c5ab91a | ||
|
|
092bd843e1 | ||
|
|
2f2eaabc57 | ||
|
|
da8d460dc6 | ||
|
|
3825be45df | ||
|
|
248c78d669 | ||
|
|
3d90e11b96 | ||
|
|
d44981b7eb | ||
|
|
3bfc93fd4e | ||
|
|
ef8366be66 | ||
|
|
a7e31b484e | ||
|
|
f4f45c5107 | ||
|
|
c8876a7fd1 | ||
|
|
2f935bbebb | ||
|
|
eec22ffd76 | ||
|
|
909fb83f79 | ||
|
|
41b036966e | ||
|
|
c282d8492d | ||
|
|
5a3c16d20d | ||
|
|
75383e8faa | ||
|
|
29645bc4e7 | ||
|
|
d950a59b4d | ||
|
|
d3e3436075 | ||
|
|
3828a0f054 | ||
|
|
67313f4a23 | ||
|
|
fd2921cb07 | ||
|
|
ad6af9705f | ||
|
|
b6c56c5061 | ||
|
|
c7bdf74d5c | ||
|
|
2426fe2384 | ||
|
|
d370fef899 | ||
|
|
00174b0fdc | ||
|
|
ea711ae048 | ||
|
|
881923ba54 | ||
|
|
097e2d61e7 | ||
|
|
82d285e841 | ||
|
|
bf4e8945c0 | ||
|
|
9c9bc18a44 | ||
|
|
52c6464650 | ||
|
|
0630c8931a | ||
|
|
7b9d251e80 | ||
|
|
5ae7801086 | ||
|
|
0ab5ec0540 | ||
|
|
50c22a4ecf | ||
|
|
8ac7466878 | ||
|
|
7f6188d510 | ||
|
|
2ad128ce99 | ||
|
|
e945be4347 | ||
|
|
bfdbc7ae9e | ||
|
|
dcf08b17f9 | ||
|
|
d13c0a584c | ||
|
|
9615d25909 | ||
|
|
6a0564ed8b | ||
|
|
af8c4a6071 | ||
|
|
c1ca2b637e | ||
|
|
1e2c04f6bc | ||
|
|
92f1ad2085 | ||
|
|
3d5b2780af | ||
|
|
c84cb3f2b7 | ||
|
|
4fa6d9ace4 | ||
|
|
0814154c7a | ||
|
|
5097f2af39 | ||
|
|
cb08e7afe0 | ||
|
|
7b5a1778ea | ||
|
|
63b550edca | ||
|
|
1bf0bd7d19 | ||
|
|
28fc79ea33 | ||
|
|
9e6fe661ca | ||
|
|
5b50611ffe | ||
|
|
003508e1f3 | ||
|
|
847e6806c6 | ||
|
|
8bf5070459 | ||
|
|
727883a269 | ||
|
|
fd33478af1 | ||
|
|
b2d9e192aa | ||
|
|
db7ba49ca1 | ||
|
|
b51882819a | ||
|
|
e0a8ce5b20 | ||
|
|
2b2613386d | ||
|
|
92f700384e | ||
|
|
8e77afadc3 | ||
|
|
bfc8fb6a14 | ||
|
|
f8dbe5ea5a | ||
|
|
47e09a1263 | ||
|
|
b91a4f979d | ||
|
|
d9cecbe163 | ||
|
|
989f836ba2 | ||
|
|
98948ad7f0 | ||
|
|
a363b4ee34 | ||
|
|
c220ff5d27 | ||
|
|
2b6cc8d602 | ||
|
|
856dd79ee9 | ||
|
|
468300227d | ||
|
|
ae4d1fde91 | ||
|
|
ca1acd21e8 | ||
|
|
dabf8f9d75 | ||
|
|
affe24f441 | ||
|
|
3a5a8d0ded | ||
|
|
5d3103102e | ||
|
|
7ab38f258c | ||
|
|
35fe4481fa | ||
|
|
58edd4129c | ||
|
|
c8e1a328ec | ||
|
|
4f8f50f90b | ||
|
|
3b4b85bc42 | ||
|
|
db11265b28 | ||
|
|
6df137201a | ||
|
|
82efbb4219 | ||
|
|
886ccff341 | ||
|
|
0d5f5eca1d | ||
|
|
f75d2b66c4 | ||
|
|
29bf439288 | ||
|
|
d3a8b86f55 | ||
|
|
d205cb5ddc | ||
|
|
223a6e13c9 | ||
|
|
664e33b3a6 | ||
|
|
5a7b6721b9 | ||
|
|
aae3de84f4 | ||
|
|
3491888f88 | ||
|
|
f6aa0d0544 | ||
|
|
1415f18fea | ||
|
|
f498ee39b4 | ||
|
|
292b8e05eb | ||
|
|
ca6549dc6f | ||
|
|
e03b4832e4 | ||
|
|
3e01e423b7 | ||
|
|
00b5310b59 | ||
|
|
ba100e0444 | ||
|
|
29676d5c4b | ||
|
|
dd9ff1b3c8 | ||
|
|
d53881cbbd | ||
|
|
4238ee50a6 | ||
|
|
784f148d75 | ||
|
|
607b2d7055 | ||
|
|
03e24b9b84 | ||
|
|
73f04a357a | ||
|
|
2742dcbd4f | ||
|
|
329c5e506f | ||
|
|
3bc7dafe3e | ||
|
|
23432edb74 | ||
|
|
df7b3210a3 | ||
|
|
31e8941415 | ||
|
|
f329457c9a | ||
|
|
0eddee4f15 | ||
|
|
ce2c9e58dd | ||
|
|
f1bbc9d1da | ||
|
|
29bb2f32a3 | ||
|
|
22e4d2aaa1 | ||
|
|
354d8cff1a | ||
|
|
1b80f853ed | ||
|
|
b1f478cb8e | ||
|
|
39d69e0448 | ||
|
|
45ac58e312 | ||
|
|
a0d910632a | ||
|
|
41b954081a | ||
|
|
2723048bb3 | ||
|
|
3f59076d83 | ||
|
|
b80c65558d | ||
|
|
f569207dc5 | ||
|
|
6dbb9854c8 | ||
|
|
2fbd292e7a | ||
|
|
484f2e9ba9 | ||
|
|
266ecf75a9 | ||
|
|
4d90d83b67 | ||
|
|
c56ec7a2c2 | ||
|
|
aa9cb68c81 | ||
|
|
dd1b1db76a | ||
|
|
86e6b7dbc9 | ||
|
|
731b8475ec | ||
|
|
043fee21e7 | ||
|
|
ae34c691b1 | ||
|
|
7496bc58a8 | ||
|
|
7c455aff9c | ||
|
|
ef969bb2c2 | ||
|
|
0cbacd6ddf | ||
|
|
da75c8c17b | ||
|
|
548ad4b589 | ||
|
|
922dd989bc | ||
|
|
c486abf0ed | ||
|
|
4bbbfc89a7 | ||
|
|
aba17ed0ad | ||
|
|
5a23043466 | ||
|
|
76f715248d | ||
|
|
0d4185d02a | ||
|
|
2ff4ec812b | ||
|
|
20c423fc09 | ||
|
|
6851f29f75 | ||
|
|
77d198bec5 | ||
|
|
0ba6acec31 | ||
|
|
dd994263b9 | ||
|
|
12847d7cfc | ||
|
|
01562b6ee0 | ||
|
|
90ac347ff2 | ||
|
|
3cf3939b49 | ||
|
|
d0a8aa9169 | ||
|
|
10db52f9ae | ||
|
|
f9ebbb30eb | ||
|
|
b36c555c13 | ||
|
|
7338e09caf | ||
|
|
80a54e87f8 | ||
|
|
1a6291471a | ||
|
|
449c8d9272 | ||
|
|
136379a3aa | ||
|
|
313942adb7 | ||
|
|
66efd62d56 | ||
|
|
d7cf7422f4 | ||
|
|
094e019063 | ||
|
|
8de74537f7 | ||
|
|
70c10f247b | ||
|
|
2f26a393ca | ||
|
|
a19739d2d8 | ||
|
|
50e18e2772 | ||
|
|
b9c73bda96 | ||
|
|
608b1fb83e | ||
|
|
07ef8dfb2e | ||
|
|
6b09e26cbf | ||
|
|
7babd5780b | ||
|
|
8b57a85476 | ||
|
|
c85ea6bc77 | ||
|
|
eae72dbdd7 | ||
|
|
111602f248 | ||
|
|
d366e252e9 | ||
|
|
40dcc5f879 | ||
|
|
8c0d96afc6 | ||
|
|
09b6db4f8b | ||
|
|
24e16ed8bc | ||
|
|
fabe9f7d6e | ||
|
|
1962d97bc1 | ||
|
|
c43ab13790 | ||
|
|
11625b3850 | ||
|
|
8c7a6d13d6 | ||
|
|
c2bd7b15ee | ||
|
|
b4c7a83f57 | ||
|
|
72b07a0f45 | ||
|
|
4accd2df2b | ||
|
|
d1c2c61626 | ||
|
|
6b0971170e | ||
|
|
a6410df3cf | ||
|
|
25811f20a0 | ||
|
|
778d8e5ef1 | ||
|
|
156c31a3f5 | ||
|
|
051a181210 | ||
|
|
e8b9e05a65 | ||
|
|
e298970d3f | ||
|
|
1eaa188374 | ||
|
|
b36d24a4d8 | ||
|
|
3b73d6a2f5 | ||
|
|
f851ac1afe | ||
|
|
b53b698930 | ||
|
|
08d46c6f5c | ||
|
|
80ae3df933 | ||
|
|
ac397c68ec | ||
|
|
423bc24939 | ||
|
|
41b28a133e | ||
|
|
b1ead1329d | ||
|
|
e0e99a07bb | ||
|
|
30d0e8b1bd | ||
|
|
dd234691ea | ||
|
|
c3c8ffba95 | ||
|
|
ec9a11d5c0 | ||
|
|
1458c800b8 | ||
|
|
b5fdb2d247 | ||
|
|
1c8e5915d9 | ||
|
|
e845e3f7ef | ||
|
|
27eae63762 | ||
|
|
634f45a4c4 | ||
|
|
3c269b2f96 | ||
|
|
3851f51621 | ||
|
|
d676a10e56 | ||
|
|
88d3e97595 | ||
|
|
88ad8ecfcc | ||
|
|
478d10d27e | ||
|
|
6fbcf6e0b7 | ||
|
|
8bf47698ad | ||
|
|
c0bc4878e3 | ||
|
|
e9b7965a76 | ||
|
|
0a54cd20db | ||
|
|
a2591f260a | ||
|
|
e6dc9d7abb | ||
|
|
179f4d0d41 | ||
|
|
5a625dbd12 | ||
|
|
65fd4b3112 | ||
|
|
14067ca923 | ||
|
|
33e55721f6 | ||
|
|
aa1aad7ddd | ||
|
|
0c0d112aaf | ||
|
|
b4ec45a48d | ||
|
|
1ce8e966e8 | ||
|
|
f252365809 | ||
|
|
30fee87485 | ||
|
|
214abd449f | ||
|
|
79b348d37e | ||
|
|
965734c2f2 |
@@ -1,4 +1,9 @@
|
||||
**/**
|
||||
!lib/
|
||||
!package*
|
||||
!main.js
|
||||
!script/
|
||||
!test/
|
||||
!main.js
|
||||
!package.json
|
||||
!env.example.js
|
||||
!my_config.example.js
|
||||
!README.md
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
},
|
||||
"extends": "eslint:recommended",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 12
|
||||
"ecmaVersion": "latest"
|
||||
},
|
||||
"rules": {
|
||||
}
|
||||
|
||||
@@ -60,9 +60,11 @@ body:
|
||||
attributes:
|
||||
label: "运行日志"
|
||||
description: |
|
||||
控制台日志。
|
||||
控制台日志,请用md代码格式上传,日志内容过多时请上传文件
|
||||
placeholder: |
|
||||
```
|
||||
请在此黏贴运行日志。
|
||||
```
|
||||
|
||||
- id: system
|
||||
type: input
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
name: "Build and push Docker images"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "lib/**"
|
||||
- "*.js"
|
||||
- "*.json"
|
||||
- ".github/workflows/docker.yml"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
docker:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
push: true
|
||||
tags: ${{ secrets.DOCKERHUB_REPO }}
|
||||
platforms: "linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/ppc64le,linux/s390x"
|
||||
@@ -0,0 +1,26 @@
|
||||
name: Mirror and run GitLab CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Mirror + trigger CI
|
||||
uses: SvanBoxel/gitlab-mirror-and-ci-action@master
|
||||
with:
|
||||
args: "https://gitlab.com/shanmiteko/LotteryAutoScript"
|
||||
env:
|
||||
FORCE_PUSH: "true"
|
||||
GITLAB_HOSTNAME: "gitlab.com"
|
||||
GITLAB_USERNAME: "shanmiteko"
|
||||
GITLAB_PASSWORD: ${{ secrets.GITLAB_PASSWORD }}
|
||||
GITLAB_PROJECT_ID: "36365601"
|
||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
@@ -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@v3
|
||||
- uses: JS-DevTools/npm-publish@v1
|
||||
with:
|
||||
token: ${{ secrets.NPM_TOKEN }}
|
||||
@@ -0,0 +1,81 @@
|
||||
name: "Package Node.js project into an executable"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- pkg
|
||||
paths:
|
||||
- "lib/**"
|
||||
- "*.js"
|
||||
- "*.json"
|
||||
- ".github/workflows/pkg.yml"
|
||||
- "script/build/pkg.sh"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
x64:
|
||||
runs-on: ubuntu-latest
|
||||
name: node${{ matrix.nodev }}-${{ matrix.platform }}-x64
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- platform: linux
|
||||
nodev: 18
|
||||
- platform: macos
|
||||
nodev: 18
|
||||
- platform: win
|
||||
nodev: 18
|
||||
# - platform: win
|
||||
# nodev: 12
|
||||
steps:
|
||||
- name: "Checkout codes"
|
||||
uses: actions/checkout@v3
|
||||
- name: "Use Node.js"
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: "*"
|
||||
- name: "Pkg this"
|
||||
run: |
|
||||
npm run pkg "node${{ matrix.nodev }}-${{ matrix.platform }}-x64"
|
||||
- name: "Upload to artifact"
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: node${{ matrix.nodev }}-${{ matrix.platform }}-x64
|
||||
path: "dist/*.zip"
|
||||
- name: "Upload to release draft"
|
||||
uses: xresloader/upload-to-github-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
with:
|
||||
file: "dist/*.zip"
|
||||
tag_name: "v2"
|
||||
overwrite: true
|
||||
arm64:
|
||||
runs-on: ubuntu-latest
|
||||
name: node18-${{ matrix.platform }}-arm64
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- platform: linux
|
||||
- platform: linuxstatic
|
||||
- platform: alpine
|
||||
steps:
|
||||
- name: "Checkout codes"
|
||||
uses: actions/checkout@v3
|
||||
- name: "Pkg this"
|
||||
run: |
|
||||
npm run pkg "${{ matrix.platform }}-arm64"
|
||||
- name: "Upload to artifact"
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: arm64
|
||||
path: "dist/*.zip"
|
||||
- name: "Upload to release draft"
|
||||
uses: xresloader/upload-to-github-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
with:
|
||||
file: "dist/*.zip"
|
||||
tag_name: "v2"
|
||||
overwrite: true
|
||||
@@ -1,27 +0,0 @@
|
||||
name: 'Automatic sync'
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 0 * * *'
|
||||
workflow_dispatch:
|
||||
watch:
|
||||
types: started
|
||||
repository_dispatch:
|
||||
types: repo-sync
|
||||
jobs:
|
||||
repo-sync:
|
||||
env:
|
||||
PAT: ${{ github.event.client_payload.PAT || secrets.PAT }}
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event.repository.owner.id == github.event.sender.id
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: 开始自动同步
|
||||
uses: repo-sync/github-sync@v2
|
||||
if: env.PAT
|
||||
with:
|
||||
source_repo: "https://github.com/shanmite/LotteryAutoScript.git"
|
||||
source_branch: "main"
|
||||
destination_branch: "main"
|
||||
github_token: ${{ github.event.client_payload.PAT || secrets.PAT }}
|
||||
@@ -1,6 +1,13 @@
|
||||
node_modules/
|
||||
.vscode/
|
||||
tests/
|
||||
dyids/
|
||||
lottery_info/
|
||||
lottery_dyids/
|
||||
dist/
|
||||
.env
|
||||
*.log
|
||||
*.zip
|
||||
package-lock.json
|
||||
env.js
|
||||
my_config.js
|
||||
@@ -1,13 +1,10 @@
|
||||
# Latest Nodejs + Alpine Linux
|
||||
FROM node:lts-alpine
|
||||
|
||||
MAINTAINER [email protected]
|
||||
|
||||
LABEL version="1.0" description="自动参与B站动态抽奖"
|
||||
LABEL author="shanmite" version="1.1" description="自动参与B站动态抽奖"
|
||||
|
||||
WORKDIR /lottery
|
||||
|
||||
COPY ["package.json", "package*.json", "./"]
|
||||
COPY ["package.json", "./"]
|
||||
|
||||
RUN npm install
|
||||
|
||||
@@ -15,4 +12,4 @@ COPY ["main.js", "./"]
|
||||
COPY ["lib/", "lib/"]
|
||||
|
||||
ENTRYPOINT ["npm", "run"]
|
||||
CMD ["start"]
|
||||
CMD ["start"]
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
FROM arm64v8/node:lts-alpine
|
||||
|
||||
WORKDIR /root/lottery
|
||||
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories && \
|
||||
apk add --no-cache curl
|
||||
|
||||
ENV DOWNLOAD_HOST=https://ghproxy.com/https://github.com \
|
||||
RELEASE_TAG=v3.4 \
|
||||
NODEV=18.5.0 \
|
||||
PKG_CACHE_PATH=/root/.pkg-cache \
|
||||
PKG_IGNORE_TAG=true
|
||||
|
||||
RUN mkdir -p "${PKG_CACHE_PATH}" && \
|
||||
curl -L "$DOWNLOAD_HOST/vercel/pkg-fetch/releases/download/$RELEASE_TAG/node-v$NODEV-linux-arm64" -o \
|
||||
"${PKG_CACHE_PATH}/fetched-v$NODEV-linux-arm64" && \
|
||||
curl -L "$DOWNLOAD_HOST/vercel/pkg-fetch/releases/download/$RELEASE_TAG/node-v$NODEV-alpine-arm64" -o \
|
||||
"${PKG_CACHE_PATH}/fetched-v$NODEV-alpine-arm64" && \
|
||||
curl -L "$DOWNLOAD_HOST/vercel/pkg-fetch/releases/download/$RELEASE_TAG/node-v$NODEV-linuxstatic-arm64" -o \
|
||||
"${PKG_CACHE_PATH}/fetched-v$NODEV-linuxstatic-arm64"
|
||||
|
||||
ENTRYPOINT ["npx", "pkg"]
|
||||
CMD [""]
|
||||
@@ -1,21 +1,674 @@
|
||||
MIT License
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (c) 2020 shanmite
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
Preamble
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
|
||||
@@ -6,23 +6,36 @@
|
||||
- [本地运行](#本地运行)
|
||||
- [可执行文件](#可执行文件)
|
||||
- [以源码方式运行](#以源码方式运行)
|
||||
- [Windows](#windows)
|
||||
- [Linux](#linux)
|
||||
- [Docker](#docker)
|
||||
- [防重复转发](#防重复转发)
|
||||
- [青龙面板](#青龙面板)
|
||||
- [检测中奖](#检测中奖)
|
||||
- [检测未读信息, 已读未读信息](#检测未读信息-已读未读信息)
|
||||
- [中奖推送(可选)](#中奖推送可选)
|
||||
- [中奖推送](#中奖推送)
|
||||
- [设置说明](#设置说明)
|
||||
- [评论验证码识别](#评论验证码识别)
|
||||
- [其他](#其他)
|
||||
- [Awesome](#awesome)
|
||||
|
||||
[Github仓库链接](https://github.com/shanmiteko/LotteryAutoScript)
|
||||
|
||||
[](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/pkg.yml)
|
||||
|
||||
[](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/docker.yml)
|
||||
|
||||
[](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/npmp.yml)
|
||||
|
||||
[](https://github.com/shanmiteko/LotteryAutoScript/actions/workflows/mirror.yml)
|
||||
|
||||
已实现功能:
|
||||
|
||||
- 监控用户转发
|
||||
- 监控话题页面
|
||||
- 监控专栏合集
|
||||
- 自动点赞、评论、乱序转发、@好友、带话题、可选随机动态
|
||||
- 直播预约抽奖
|
||||
- 检测是否中奖
|
||||
- 已读@
|
||||
- 已读私信
|
||||
- 清理动态关注
|
||||
- 检查更新
|
||||
- 更多功能设置请参考配置文件
|
||||
@@ -33,6 +46,8 @@
|
||||
|
||||
## 操作步骤
|
||||
|
||||
**使用前务必阅读此教程和配置文件内注释**
|
||||
|
||||
右上角<kbd>★ Star</kbd>
|
||||
|
||||
↓↓
|
||||
@@ -49,7 +64,7 @@ Chrome浏览器:
|
||||
|
||||
(此步骤是为了方便后续采用JS获取Cookies,获取完毕后应再次勾选)
|
||||
|
||||

|
||||

|
||||
|
||||
3. 在Console中复制以下代码回车
|
||||
|
||||
@@ -59,16 +74,18 @@ Chrome浏览器:
|
||||
.cookie
|
||||
.split(/\s*;\s*/)
|
||||
.map(it => it.split('='))
|
||||
.filter(it => ['DedeUserID','bili_jct', 'SESSDATA'].indexOf(it[0]) > -1)
|
||||
.filter(it => ['DedeUserID','bili_jct', 'SESSDATA', 'buvid3'].indexOf(it[0]) > -1)
|
||||
.map(it => it.join('='))
|
||||
.join('; ')
|
||||
.split()
|
||||
.forEach(it => copy(it) || console.log(it))
|
||||
```
|
||||
```
|
||||
|
||||
也可以采用**其他方式获取**所需的Cookie
|
||||
|
||||
只需含有 `DedeUserID=...;SESSDATA=...;bili_jct=...` 三项即可
|
||||
只需含有 `DedeUserID=...;SESSDATA=...;bili_jct=...;buvid3=...` 即可
|
||||
|
||||
buvid3亦可不填 使用随机生成值
|
||||
|
||||
(分号分割, 不要换行, 顺序随意)
|
||||
|
||||
@@ -77,182 +94,124 @@ Chrome浏览器:
|
||||
### 本地运行
|
||||
|
||||
#### 可执行文件
|
||||
|
||||
1. [[下载](https://github.com/shanmiteko/LotteryAutoScript/releases)|[cnpmjs镜像下载](https://github.com.cnpmjs.org/shanmiteko/LotteryAutoScript/releases)|[Fastgit镜像下载](https://hub.fastgit.org/shanmiteko/LotteryAutoScript/releases)]压缩包并解压后
|
||||
|
||||
```
|
||||
~/nlts-linux-x64
|
||||
=> tree
|
||||
.
|
||||
├── dyids (自动生成的dyid存储)
|
||||
│ └── dyid.txt
|
||||
├── 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点击运行
|
||||
7. 运行截图
|
||||

|
||||
- windows 可直接点击对应的`*.bat`文件
|
||||
|
||||
```
|
||||
用法: lottery [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
start 启动抽奖
|
||||
check 中奖检查
|
||||
acount 查看帐号信息
|
||||
clear 清理动态和关注
|
||||
update 检查更新
|
||||
help 帮助信息
|
||||
```
|
||||
|
||||
1. 运行截图
|
||||

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

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

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

|
||||

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

|
||||

|
||||
|
||||
至此,获取**TG_BOT_TOKEN**以及**TG_USER_ID**的教程结束
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
使用此功能前需启动OCR服务
|
||||
|
||||
## 拉取镜像
|
||||
```
|
||||
docker pull shanmite/ocr_api_server
|
||||
```
|
||||
## 启动容器
|
||||
```
|
||||
docker run -p 9898:9898 -d ocr_api_server
|
||||
```
|
||||
|
||||
### 非docker启动方式
|
||||
|
||||

|
||||
|
||||
[ocr_api_server](https://github.com/shanmiteko/ocr_api_server)
|
||||
|
||||

|
||||
@@ -10,15 +10,14 @@
|
||||
2.下载脚本到本地
|
||||
|
||||
```sh
|
||||
git clone https://github.com/shanmite/LotteryAutoScript.git
|
||||
git clone https://github.com/shanmiteko/LotteryAutoScript.git
|
||||
```
|
||||
|
||||

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

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

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

|
||||

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

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

|
||||
|
||||

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

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

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

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

|
||||

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

|
||||

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

|
||||

|
||||
|
||||
具体看任务是否正常执行,你可以看看自己的账号动态的最新转发,运行成功每几分钟自动转发抽奖动态
|
||||
|
||||
@@ -1,89 +1,97 @@
|
||||
/**
|
||||
* ## 账号相关
|
||||
* - `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` 是必填项
|
||||
* - `NOTE` 帐号备注
|
||||
* - `NUMBER` 表示是第几个账号
|
||||
* - `CLEAR` 是否启用清理功能
|
||||
* ## 高级功能
|
||||
* - `ENABLE_CHAT_CAPTCHA_OCR` 开启评论验证码识别 使用方法见README
|
||||
* - `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: "",
|
||||
NOTE: "",
|
||||
NUMBER: 1,
|
||||
CLEAR: true,
|
||||
WAIT: 60 * 1000,
|
||||
|
||||
ENABLE_CHAT_CAPTCHA_OCR: "",
|
||||
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: ""
|
||||
}
|
||||
/**
|
||||
* 为防止环境变量过长, 请将多账号填在此处
|
||||
* 以 **大括号内容** 为模板依次复制(包含大括号),逗号分割
|
||||
*
|
||||
* ```txt
|
||||
* [
|
||||
* {
|
||||
* ...
|
||||
* NUMBER: 1
|
||||
* ...
|
||||
* },
|
||||
* {
|
||||
* ...
|
||||
* NUMBER: 2
|
||||
* ...
|
||||
* }
|
||||
* ]
|
||||
* ```
|
||||
*/
|
||||
multiple_account_parm: [
|
||||
{
|
||||
COOKIE: "",
|
||||
NOTE: "",
|
||||
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: "",
|
||||
PUSHDEER_URL: "",
|
||||
PUSHDEER_PUSHKEY: "",
|
||||
TG_BOT_TOKEN: "",
|
||||
TG_USER_ID: "",
|
||||
TG_PROXY_HOST: "",
|
||||
TG_PROXY_PORT: "",
|
||||
DD_BOT_TOKEN: "",
|
||||
DD_BOT_SECRET: "",
|
||||
QYWX_AM: "",
|
||||
QYWX_KEY: "",
|
||||
IGOT_PUSH_KEY: "",
|
||||
PUSH_PLUS_TOKEN: "",
|
||||
PUSH_PLUS_USER: "",
|
||||
QMSG_KEY: "",
|
||||
QMSG_QQ: "",
|
||||
SMTP_HOST: "",
|
||||
SMTP_PORT: "",
|
||||
SMTP_USER: "",
|
||||
SMTP_PASS: "",
|
||||
SMTP_TO_USER: ""
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module.exports = { initEnv, multiple_account_parm };
|
||||
})
|
||||
@@ -0,0 +1,15 @@
|
||||
const bili = require('./net/bili')
|
||||
const { log } = require('./utils')
|
||||
|
||||
async function account() {
|
||||
const my_info = await bili.getMyinfo();
|
||||
const stat = await bili.getStat();
|
||||
if (my_info && stat) {
|
||||
log.info("帐号信息", `${my_info.name} Lv${my_info.level} ${my_info.silence ? "已封禁" : "未封禁"} 升级还需${my_info.level_exp.next_exp - my_info.level_exp.current_exp}经验`)
|
||||
log.info("帐号信息", `当前关注数:${stat.following} 粉丝数:${stat.follower} 动态数量:${stat.dynamic_count}`)
|
||||
} else {
|
||||
log.error("帐号信息", "获取失败");
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { account }
|
||||
@@ -6,48 +6,76 @@ const bili = require('./net/bili')
|
||||
|
||||
/**
|
||||
* 是否中奖
|
||||
* @param {number} num
|
||||
*/
|
||||
async function isMe() {
|
||||
async function isMe(num) {
|
||||
let desp = '';
|
||||
const UnreadAtNum = await bili.getUnreadAtNum();
|
||||
const UnreadSessionNum = await bili.getUnreadSessionNum();
|
||||
const { follow_unread, unfollow_unread } = UnreadSessionNum || { unfollow_unread: 0, follow_unread: 0 };
|
||||
if (UnreadAtNum > 0) {
|
||||
const
|
||||
{ notice_key_words, update_session_wait, get_session_wait, check_session_pages } = config,
|
||||
{ at: unread_at_num, reply: unread_reply_num } = await bili.getUnreadNum(),
|
||||
unread_session_num = await bili.getUnreadSessionNum(),
|
||||
{ follow_unread, unfollow_unread } = unread_session_num || { unfollow_unread: 0, follow_unread: 0 };
|
||||
if (unread_at_num) {
|
||||
log.info('中奖检测', '<-- 正在检查at');
|
||||
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`
|
||||
});
|
||||
MyAtInfo
|
||||
.slice(0, unread_at_num)
|
||||
.forEach(({ at_time, up_uname, business, source_content, url }) => {
|
||||
desp += '## [at]检测结果\n\n'
|
||||
desp += '- - - -\n\n'
|
||||
desp += `发生时间: ${new Date(at_time * 1000).toLocaleString()}\n\n`
|
||||
desp += `用户: ${up_uname}\n\n`
|
||||
desp += `在${business}中@了[你](https://space.bilibili.com/${global_var.get("myUID")})\n\n`
|
||||
desp += `原内容为: ${source_content}\n\n`
|
||||
desp += `[直达链接](${url})\n\n`
|
||||
desp += '- - - -\n\n'
|
||||
});
|
||||
log.info('中奖检测', '--> OK');
|
||||
}
|
||||
if (unread_reply_num) {
|
||||
log.info('中奖检测', '<-- 正在检查回复');
|
||||
const replys = await bili.getReplyMsg();
|
||||
replys
|
||||
.slice(0, unread_reply_num)
|
||||
.forEach(({ nickname, uri, source, timestamp }) => {
|
||||
if (judge(source, notice_key_words)) {
|
||||
desp += '## 回复检测结果\n\n'
|
||||
desp += '- - - -\n\n'
|
||||
desp += `发生时间: ${new Date(timestamp * 1000).toLocaleString()}\n\n`
|
||||
desp += `用户: ${nickname}\n\n`
|
||||
desp += `回复[你](https://space.bilibili.com/${global_var.get("myUID")})说:\n${source}\n\n`
|
||||
desp += `[直达链接](${uri})\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.getSessionInfo(type)
|
||||
log.info("准备检查私信", check_session_pages + "页")
|
||||
for (const index of infiniteNumber()) {
|
||||
for (const Session of MySession.data) {
|
||||
const { content, sender_uid, session_ts, timestamp, unread_count, talker_id, msg_seqno } = Session;
|
||||
const { sender_uid, session_ts, timestamp, unread_count, talker_id, msg_seqno } = Session;
|
||||
session_t = session_ts;
|
||||
if (unread_count) {
|
||||
bili.updateSessionStatus(talker_id, type, msg_seqno);
|
||||
await delay(1000);
|
||||
if (judge(content, config.notice_key_words)) {
|
||||
desp += `发生时间: ${new Date(timestamp * 1000).toLocaleString()} \n\n`
|
||||
desp += `用户: ${sender_uid} \n\n`
|
||||
desp += `私信你(${global_var.get("myUID")})说: ${content} \n\n`
|
||||
desp += `[直达链接](https://message.bilibili.com/#/whisper/mid${sender_uid}) \n\n`
|
||||
desp += `\n\n`
|
||||
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 += `私信[你](https://space.bilibili.com/${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);
|
||||
if (MySession.has_more && index < check_session_pages) {
|
||||
await delay(get_session_wait);
|
||||
MySession = await bili.getSessionInfo(type, session_t)
|
||||
} else {
|
||||
break
|
||||
@@ -65,9 +93,8 @@ async function isMe() {
|
||||
log.info('中奖检测', '--> OK');
|
||||
}
|
||||
if (desp) {
|
||||
desp += '中奖了别忘给脚本(https://github.com/shanmiteko/LotteryAutoScript)点一个Star哦, 赞助一两块也不是不可以_(:з」∠)_\n\n'
|
||||
log.info('可能中奖了', desp);
|
||||
await sendNotify('可能中奖了', desp);
|
||||
await sendNotify(`帐号${num}可能中奖了`, desp);
|
||||
} else {
|
||||
log.info('中奖检测', "暂未中奖");
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const { log, delay, infiniteNumber } = require("./utils");
|
||||
const { log, delay, infiniteNumber, retryfn } = require("./utils");
|
||||
const bili = require("./net/bili");
|
||||
const { Searcher } = require("./core/searcher");
|
||||
const global_var = require('./data/global_var');
|
||||
@@ -6,23 +6,26 @@ const config = require("./data/config");
|
||||
|
||||
/**
|
||||
* 获取关注分区里的uid
|
||||
* @param {string} partition
|
||||
* @returns { Promise<number[]> }
|
||||
*/
|
||||
async function getFollowList() {
|
||||
const tagid = await bili.checkMyPartition(config.clear_partition);
|
||||
async function getFollowList(partition) {
|
||||
const
|
||||
{ clear_white_list, get_partition_wait } = config,
|
||||
tagid = await bili.checkMyPartition(partition);
|
||||
let rmup = [];
|
||||
if (typeof tagid === 'undefined') {
|
||||
log.info('获取关注列表', '未能成功获取关注分区id');
|
||||
return
|
||||
return rmup
|
||||
}
|
||||
let rmup = [];
|
||||
for (let index = 1; index < 42; index++) {
|
||||
for (let index = 1; index < 100; 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,9 +33,9 @@ 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_quick_remove_attention_fans_number_smallest, clear_remove_dynamic, clear_remove_attention, clear_remove_delay, clear_dynamic_type, clear_partition } = config;
|
||||
let success = true;
|
||||
const uid_list = await getFollowList();
|
||||
const uid_list = (await Promise.all(clear_partition.split(',').map(getFollowList))).flat();
|
||||
if (!uid_list.length) {
|
||||
log.info('清理关注', `关注为空`)
|
||||
} else {
|
||||
@@ -42,13 +45,17 @@ async function clear() {
|
||||
log.info('清理关注', '进入只清理关注模式')
|
||||
/* 专清关注 */
|
||||
for (const [index, uid] of uid_list.entries()) {
|
||||
log.info('清理关注', `(${index}) (${uid})`)
|
||||
/* 取消关注 */
|
||||
if (await bili.cancelAttention(uid)) {
|
||||
log.info('清理关注', '成功')
|
||||
} else {
|
||||
log.error('清理关注', '失败')
|
||||
break
|
||||
const fannumber = await bili.getUserInfo(uid);
|
||||
log.info('清理关注', `粉丝数${fannumber}`)
|
||||
if (fannumber !== -1 && fannumber < clear_quick_remove_attention_fans_number_smallest) {
|
||||
log.info('清理关注', `(${index}) (${uid})`)
|
||||
/* 取消关注 */
|
||||
if (await retryfn(3, [false], () => bili.cancelAttention(uid))) {
|
||||
log.info('清理关注', '成功')
|
||||
} else {
|
||||
log.error('清理关注', '失败')
|
||||
break
|
||||
}
|
||||
}
|
||||
/* 延时 */
|
||||
await delay(clear_remove_delay);
|
||||
@@ -63,22 +70,29 @@ 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 retryfn(
|
||||
3,
|
||||
[null],
|
||||
() => Searcher.checkAllDynamic(MY_UID, 1, search_wait, next_offset)
|
||||
)) || { allModifyDynamicResArray: [], offset: '0' };
|
||||
next_offset = offset;
|
||||
for (const [index, dyinfo] of allModifyDynamicResArray.entries()) {
|
||||
log.info('清理动态', `第${page + 1}页中的第${index + 1}个动态`)
|
||||
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) {
|
||||
log.debug('清理动态', `当前UID保护列表:\n${before_separate.join(',')}\n`)
|
||||
/* 移除动态 */
|
||||
if (dynamic_id
|
||||
&& clear_remove_dynamic
|
||||
&& !(new RegExp(dynamic_id).test(clear_white_list))) {
|
||||
success = await bili.rmDynamic(dynamic_id)
|
||||
success = await retryfn(3, [false], () => bili.rmDynamic(dynamic_id))
|
||||
}
|
||||
|
||||
/* 取消关注 */
|
||||
@@ -87,16 +101,24 @@ async function clear() {
|
||||
&& clear_remove_attention
|
||||
&& before_separate.indexOf(origin_uid) === -1
|
||||
&& uid_list.indexOf(origin_uid) > -1) {
|
||||
success = await bili.cancelAttention(origin_uid);
|
||||
success = await retryfn(3, [false], () => bili.cancelAttention(origin_uid))
|
||||
}
|
||||
|
||||
if (!success) 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}`)
|
||||
@@ -110,4 +132,4 @@ async function clear() {
|
||||
}
|
||||
|
||||
|
||||
module.exports = { clear }
|
||||
module.exports = { clear }
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
const utils = require('../utils');
|
||||
const { log, hasEnv, shuffle, getRandomOne, delay, try_for_each, retryfn, appendLotteryInfoFile } = require('../utils');
|
||||
const { send } = require('../net/http');
|
||||
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;
|
||||
|
||||
/**
|
||||
* 监视器
|
||||
@@ -25,6 +26,8 @@ class Monitor extends Searcher {
|
||||
['UIDs', this.getLotteryInfoByUID.bind(this)],
|
||||
['TAGs', this.getLotteryInfoByTag.bind(this)],
|
||||
['Articles', this.getLotteryInfoByArticle.bind(this)],
|
||||
['APIs', this.getLotteryInfoByAPI.bind(this)],
|
||||
['TxT', this.getLotteryInfoByTxT.bind(this)]
|
||||
]);
|
||||
}
|
||||
/**
|
||||
@@ -35,7 +38,8 @@ class Monitor extends Searcher {
|
||||
event_bus.emit('Turn_off_the_Monitor', '已关闭所有转发行为')
|
||||
return
|
||||
}
|
||||
if (!this.tagid) {
|
||||
if (!this.tagid
|
||||
&& config.is_not_create_partition !== true) {
|
||||
this.tagid = await bili.checkMyPartition() /* 检查关注分区 */
|
||||
if (!this.tagid) {
|
||||
event_bus.emit('Turn_off_the_Monitor', '分区获取失败')
|
||||
@@ -44,36 +48,52 @@ class Monitor extends Searcher {
|
||||
}
|
||||
/** 关注列表初始化 */
|
||||
this.attentionList = await bili.getAttentionList(global_var.get("myUID"));
|
||||
switch (await this.startLottery()) {
|
||||
const status = await this.startLottery();
|
||||
switch (status) {
|
||||
case 0:
|
||||
event_bus.emit('Turn_on_the_Monitor')
|
||||
break;
|
||||
case 11:
|
||||
case 1001:
|
||||
event_bus.emit('Turn_off_the_Monitor', '评论失败')
|
||||
break;
|
||||
case 1004:
|
||||
event_bus.emit('Turn_off_the_Monitor', '需要输入验证码')
|
||||
break
|
||||
case 21:
|
||||
event_bus.emit('Turn_on_the_Monitor')
|
||||
break
|
||||
case 22:
|
||||
config.only_followed = true;
|
||||
log.warn('账号异常', `UID(${global_var.get('myUID')})临时进入只转已关注模式(异常号只会对部分UP出现关注异常)`)
|
||||
case 2001:
|
||||
event_bus.emit('Turn_off_the_Monitor', '关注出错')
|
||||
break;
|
||||
case 3001:
|
||||
event_bus.emit('Turn_off_the_Monitor', '分区移动出错')
|
||||
break;
|
||||
case 2004:
|
||||
case 4005:
|
||||
log.warn(`账号异常${status}`, `UID(${global_var.get('myUID')})异常号只会对部分UP出现异常`)
|
||||
if (!config.is_exception) {
|
||||
await sendNotify('[动态抽奖]账号异常通知', `UID: ${global_var.get('myUID')}\n\n临时进入只转已关注模式(异常号只会对部分UP出现关注异常)\n\n可在设置中令is_exception为true关闭此推送`)
|
||||
await sendNotify(
|
||||
`[动态抽奖]账号异常${status}通知`,
|
||||
`UID: ${global_var.get('myUID')}\n异常号只会对部分UP出现异常\n可在设置中令is_exception为true关闭此推送\n${log._cache.filter(it => /Error|\s抽奖信息\]/.test(it)).join('\n')}`
|
||||
)
|
||||
}
|
||||
config.is_exception = true;
|
||||
event_bus.emit('Turn_on_the_Monitor')
|
||||
break
|
||||
case 31:
|
||||
case 2005:
|
||||
log.warn('关注已达上限', `UID(${global_var.get('myUID')})关注已达上限,已临时进入只转已关注模式`)
|
||||
if (!config.is_outof_maxfollow) {
|
||||
await sendNotify(
|
||||
'[动态抽奖]关注已达上限',
|
||||
`UID: ${global_var.get('myUID')}\n关注已达上限,已临时进入只转已关注模式\n可在设置中令is_outof_maxfollow为true关闭此推送\n${log._cache.filter(it => /Error|\s抽奖信息\]/.test(it)).join('\n')}`
|
||||
)
|
||||
}
|
||||
config.is_outof_maxfollow = true;
|
||||
config.only_followed = true;
|
||||
event_bus.emit('Turn_on_the_Monitor')
|
||||
break
|
||||
case 5001:
|
||||
event_bus.emit('Turn_off_the_Monitor', '转发失败')
|
||||
break
|
||||
case 41:
|
||||
event_bus.emit('Turn_off_the_Monitor', '获取开奖时间失败')
|
||||
break
|
||||
case 51:
|
||||
event_bus.emit('Turn_off_the_Monitor', '获取关注数失败')
|
||||
break
|
||||
default:
|
||||
event_bus.emit('Turn_off_the_Monitor', '未知错误')
|
||||
event_bus.emit('Turn_off_the_Monitor', `??? 未知错误: ${status}`)
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -83,49 +103,140 @@ 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 status = 0;
|
||||
if (Lottery.isOfficialLottery) {
|
||||
let { ts } = await bili.getLotteryNotice(Lottery.dyid);
|
||||
let
|
||||
status = 0,
|
||||
is_exception = 0,
|
||||
is_outof_maxfollow = 0,
|
||||
relayed_nums = 0,
|
||||
total_nums = 0;
|
||||
for (const [index, lottery] of shuffle(allLottery).entries()) {
|
||||
total_nums += 1;
|
||||
let is_shutdown = false;
|
||||
if (
|
||||
is_outof_maxfollow
|
||||
&& lottery.uid.length
|
||||
&& (new RegExp(lottery.uid.join('|'))).test(this.attentionList)
|
||||
) {
|
||||
log.info('过滤', `已关注(${lottery.uid.join(',')})`)
|
||||
continue
|
||||
}
|
||||
|
||||
if (lottery.isOfficialLottery) {
|
||||
let { ts } = await bili.getLotteryNotice(lottery.dyid);
|
||||
const ts_10 = Date.now() / 1000;
|
||||
if (ts < 0) {
|
||||
return 41
|
||||
if (ts === -1) {
|
||||
log.warn('过滤', '无法判断开奖时间')
|
||||
await delay(filter_wait)
|
||||
continue
|
||||
}
|
||||
if (ts === -9999) {
|
||||
log.info('过滤', '已撤销抽奖')
|
||||
d_storage.updateDyid(lottery.dyid)
|
||||
await delay(filter_wait)
|
||||
continue
|
||||
}
|
||||
if (ts < ts_10) {
|
||||
log.info('过滤', '已过开奖时间')
|
||||
d_storage.updateDyid(Lottery.dyid)
|
||||
d_storage.updateDyid(lottery.dyid)
|
||||
await delay(filter_wait)
|
||||
continue
|
||||
}
|
||||
if (ts > ts_10 + config.maxday * 86400) {
|
||||
log.info('过滤', '超过指定开奖时间')
|
||||
d_storage.updateDyid(Lottery.dyid)
|
||||
d_storage.updateDyid(lottery.dyid)
|
||||
await delay(filter_wait)
|
||||
continue
|
||||
}
|
||||
} else if (Lottery.uid[0]) {
|
||||
const followerNum = await bili.getUserInfo(Lottery.uid[0]);
|
||||
if (followerNum < 0) {
|
||||
return 51
|
||||
}
|
||||
if (followerNum < config.minfollower) {
|
||||
log.info('过滤', `粉丝数(${followerNum})小于指定数量`)
|
||||
d_storage.updateDyid(Lottery.dyid)
|
||||
continue
|
||||
} else if (lottery.uid[0]) {
|
||||
const { minfollower } = config
|
||||
if (minfollower > 0) {
|
||||
const followerNum = await bili.getUserInfo(lottery.uid[0]);
|
||||
if (followerNum === -1) {
|
||||
log.warn('过滤', `粉丝数(${followerNum})获取失败`)
|
||||
await delay(filter_wait)
|
||||
continue
|
||||
}
|
||||
if (followerNum < minfollower) {
|
||||
log.info('过滤', `粉丝数(${followerNum})小于指定数量`)
|
||||
d_storage.updateDyid(lottery.dyid)
|
||||
await delay(filter_wait)
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
log.info('过滤', "不过滤粉丝数")
|
||||
}
|
||||
}
|
||||
status = await this.go(Lottery)
|
||||
if (status) {
|
||||
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:
|
||||
relayed_nums += 1
|
||||
break;
|
||||
case 1002:
|
||||
case 1003:
|
||||
case 1005:
|
||||
case 1006:
|
||||
case 1007:
|
||||
case 1008:
|
||||
case 1009:
|
||||
case 1010:
|
||||
case 1011:
|
||||
case 2002:
|
||||
case 2003:
|
||||
case 4001:
|
||||
case 4002:
|
||||
case 4003:
|
||||
case 4004:
|
||||
case 5002:
|
||||
case 5003:
|
||||
case 5004:
|
||||
status = 0
|
||||
break;
|
||||
case 2004:
|
||||
is_exception = 2004
|
||||
break;
|
||||
case 4005:
|
||||
is_exception = 4005
|
||||
break;
|
||||
case 2005:
|
||||
is_outof_maxfollow = 2005
|
||||
break;
|
||||
case 1001:
|
||||
case 1004:
|
||||
case 2001:
|
||||
case 3001:
|
||||
case 5001:
|
||||
is_shutdown = true
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (is_shutdown) break
|
||||
|
||||
d_storage.updateDyid(lottery.dyid)
|
||||
|
||||
await delay(wait * (Math.random() + 0.5));
|
||||
}
|
||||
log.info('抽奖', '开始转发下一组动态');
|
||||
return 0
|
||||
log.info('抽奖', `本轮共处理${total_nums}条,成功参与${relayed_nums}条`);
|
||||
return is_exception
|
||||
|| is_outof_maxfollow
|
||||
|| status
|
||||
} else {
|
||||
log.info('抽奖', '无未转发抽奖');
|
||||
return 0
|
||||
@@ -140,14 +251,18 @@ class Monitor extends Searcher {
|
||||
* @property {boolean} isOfficialLottery 是否官方抽奖
|
||||
* @property {string} relay_chat 转发词
|
||||
* @property {string} ctrl 定位@
|
||||
* @property {string} rid 评论标识
|
||||
* @property {string} [rid] 评论标识
|
||||
* @property {number} chat_type 评论类型
|
||||
* @property {string} [chat] 评论词
|
||||
*/
|
||||
/**
|
||||
* @returns {Promise<LotteryOptions[]>}
|
||||
*/
|
||||
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)
|
||||
@@ -155,12 +270,24 @@ class Monitor extends Searcher {
|
||||
|
||||
log.info('筛选动态', `开始筛选(${protoLotteryInfo.length})`);
|
||||
|
||||
log.debug('未进行筛选的动态信息', protoLotteryInfo);
|
||||
|
||||
/** 所有抽奖信息 */
|
||||
let alllotteryinfo = [];
|
||||
const { key_words, model, chatmodel, is_imitator, only_followed, at_users, blockword, blacklist } = config;
|
||||
/**Map<String, Boolean> */
|
||||
const
|
||||
{
|
||||
check_if_duplicated, save_lottery_info_to_file,
|
||||
set_lottery_info_url, disable_reserve_lottery,
|
||||
is_not_relay_reserve_lottery,
|
||||
reserve_lottery_wait, sneaktower, key_words,
|
||||
model, chatmodel, chat: chats, relay: relays,
|
||||
block_dynamic_type, max_create_time, is_imitator,
|
||||
only_followed, at_users, blockword, blacklist,
|
||||
use_public_blacklist
|
||||
} = config,
|
||||
now_ts = Date.now() / 1000;
|
||||
|
||||
/**
|
||||
* @type {Map<String, Boolean>}
|
||||
*/
|
||||
let dyids_map = new Map();
|
||||
|
||||
/**去重 */
|
||||
@@ -172,60 +299,180 @@ class Monitor extends Searcher {
|
||||
return true
|
||||
});
|
||||
|
||||
log.info('筛选动态', `去重后(${protoLotteryInfo.length})`);
|
||||
|
||||
/**并发查询dyid */
|
||||
await Promise.all(
|
||||
[...dyids_map.keys()]
|
||||
.map(it => d_storage
|
||||
.searchDyid(it)
|
||||
.then(hasIt => dyids_map.set(it, hasIt))
|
||||
)
|
||||
)
|
||||
if (check_if_duplicated >= 1) {
|
||||
await Promise.all(
|
||||
[...dyids_map.keys()]
|
||||
.map(it => d_storage
|
||||
.searchDyid(it)
|
||||
.then(hasIt => dyids_map.set(it, hasIt))
|
||||
)
|
||||
)
|
||||
log.info('筛选动态', `并发查询本地dyid完毕`);
|
||||
}
|
||||
|
||||
if (lottery_param[0] !== "APIs" && save_lottery_info_to_file && protoLotteryInfo.length) {
|
||||
log.info("保存抽奖信息", "保存开始")
|
||||
await appendLotteryInfoFile(lottery_param[1].toString(), protoLotteryInfo)
|
||||
}
|
||||
|
||||
if (lottery_param[0] !== "APIs" && set_lottery_info_url && protoLotteryInfo.length) {
|
||||
log.info("上传抽奖信息", "上传开始")
|
||||
await new Promise((resolve) => {
|
||||
send({
|
||||
url: set_lottery_info_url,
|
||||
method: "POST",
|
||||
headers: {
|
||||
"content-type": "application/json"
|
||||
},
|
||||
contents: protoLotteryInfo,
|
||||
success: ({ body }) => {
|
||||
log.info("发送获取到的动态数据", body)
|
||||
resolve()
|
||||
},
|
||||
failure: err => {
|
||||
log.error("发送获取到的动态数据", err)
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/* 检查动态是否满足要求 */
|
||||
await utils.try_for_each(protoLotteryInfo, async function ({
|
||||
lottery_info_type, uids,
|
||||
uname, dyid,
|
||||
ctrl, rid, des, type,
|
||||
hasOfficialLottery
|
||||
}) {
|
||||
/* 遇到转发过就退出 */
|
||||
if (dyids_map.get(dyid)) return false;
|
||||
await try_for_each(protoLotteryInfo, async function (lottery_info) {
|
||||
const {
|
||||
lottery_info_type, is_liked,
|
||||
uids, uname, dyid, reserve_id,
|
||||
reserve_lottery_text,
|
||||
is_charge_lottery,
|
||||
create_time, chat_type,
|
||||
ctrl, rid, des, type,
|
||||
hasOfficialLottery
|
||||
} = lottery_info;
|
||||
|
||||
log.debug('正在筛选的动态信息', lottery_info);
|
||||
|
||||
if (lottery_info_type.startsWith('sneak') && sneaktower) {
|
||||
log.info("筛选动态", `偷塔模式不检查是否已转发(https://t.bilibili.com/${dyid})`)
|
||||
} else {
|
||||
/* 遇到转发过就退出 */
|
||||
if (
|
||||
((!check_if_duplicated || check_if_duplicated >= 2) && is_liked)
|
||||
|| ((check_if_duplicated >= 1) && dyids_map.get(dyid))
|
||||
) {
|
||||
log.info("筛选动态", `已转发(https://t.bilibili.com/${dyid})`)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/* 超过指定时间退出 */
|
||||
if (now_ts - create_time > max_create_time * 86400) {
|
||||
log.info("筛选动态", `过时动态(https://t.bilibili.com/${dyid})`)
|
||||
return false
|
||||
}
|
||||
|
||||
if (is_charge_lottery) {
|
||||
log.info("筛选动态", `充电抽奖(https://t.bilibili.com/${dyid})`)
|
||||
return false
|
||||
}
|
||||
|
||||
const
|
||||
/**判断是转发源动态还是现动态 */
|
||||
uid = lottery_info_type === 'uid' ? uids[1] : uids[0],
|
||||
isFollowed = (new RegExp(uid)).test(attentionList),
|
||||
description = typeof des === 'string' ? des : '',
|
||||
[m_uid, ori_uid] = uids,
|
||||
mIsFollowed = !m_uid || (new RegExp(m_uid)).test(attentionList),
|
||||
oriIsFollowed = !ori_uid || (new RegExp(ori_uid)).test(attentionList),
|
||||
/**判断是转发源动态还是现动态 实际发奖人*/
|
||||
[real_uid, realIsFollowed] = lottery_info_type === 'uid'
|
||||
? [ori_uid, oriIsFollowed]
|
||||
: [m_uid, mIsFollowed],
|
||||
description = des.split(/\/\/@.*?:/)[0],
|
||||
needAt = /(?:@|艾特)[^@|(艾特)]*?好友/.test(description),
|
||||
needTopic = [...new Set(description.match(/(?<=[带加上](?:话题|tag).*)#.+?#|(?<=[带加上])#.+?#(?=话题|tag)/ig) || [])].join(' '),
|
||||
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),
|
||||
isBlock = blockword.length && new RegExp(blockword.join('|')).test(description + reserve_lottery_text),
|
||||
isLottery =
|
||||
(is_imitator && lottery_info_type === 'uid' && model !== '00')
|
||||
|| (hasOfficialLottery && model[0] === '1')
|
||||
|| (!hasOfficialLottery && model[1] === '1' && !isTwoLevelDynamic && has_key_words),
|
||||
|| (!hasOfficialLottery && model[1] === '1' && has_key_words),
|
||||
isSendChat =
|
||||
(is_imitator && lottery_info_type === 'uid' && chatmodel !== '00')
|
||||
|| (hasOfficialLottery && chatmodel[0] === '1')
|
||||
|| (!hasOfficialLottery && chatmodel[1] === '1');
|
||||
(hasOfficialLottery && chatmodel[0] === '1')
|
||||
|| (!hasOfficialLottery && chatmodel[1] === '1'),
|
||||
{ blacklist: remote_blacklist } = use_public_blacklist === false
|
||||
? { blacklist: "" }
|
||||
: global_var.get("remoteconfig"),
|
||||
/**
|
||||
* 获取黑名单并去重合并
|
||||
* @type {string[]}
|
||||
*/
|
||||
new_blacklist = remote_blacklist
|
||||
? [
|
||||
...new Set([...blacklist.split(','),
|
||||
...remote_blacklist.split(',')])
|
||||
]
|
||||
: blacklist.split(','),
|
||||
keys = [dyid, m_uid, ori_uid];
|
||||
|
||||
log.debug("筛选动态", { real_uid, mIsFollowed, oriIsFollowed, realIsFollowed, needAt, needTopic, type, isRelayDynamic, key_words, has_key_words, blockword, isBlock, isLottery, isSendChat })
|
||||
|
||||
if (
|
||||
new_blacklist.some(id => keys.some(key => {
|
||||
if (key + '' === id) {
|
||||
log.info("筛选动态", `黑名单匹配(${id})(https://t.bilibili.com/${dyid})`)
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}))
|
||||
) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (block_dynamic_type.includes(type)) {
|
||||
log.warn("筛选动态", `屏蔽动态类型 ${type}`)
|
||||
return false
|
||||
}
|
||||
|
||||
/**屏蔽词 */
|
||||
if (isBlock) return false;
|
||||
if (isBlock) {
|
||||
log.info("筛选动态", `包含屏蔽词(https://t.bilibili.com/${dyid})`)
|
||||
return false
|
||||
}
|
||||
|
||||
if (reserve_id) {
|
||||
if (disable_reserve_lottery) {
|
||||
log.info("已关闭预约抽奖功能")
|
||||
} else {
|
||||
log.info("预约抽奖", "开始");
|
||||
log.info("预约抽奖", `奖品: ${reserve_lottery_text}`);
|
||||
if (hasEnv('NOT_GO_LOTTERY')) {
|
||||
log.info('NOT_GO_LOTTERY', 'ON');
|
||||
} else {
|
||||
await delay(reserve_lottery_wait);
|
||||
await bili.reserve_lottery(reserve_id)
|
||||
}
|
||||
}
|
||||
if (is_not_relay_reserve_lottery === true) {
|
||||
log.info("预约抽奖", "已关闭预约抽奖转关功能");
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasOfficialLottery && model[1] === '1' && !has_key_words && description) {
|
||||
log.warn("筛选动态", `无关键词动态的描述: ${description}\n\n考虑是否修改设置key_words:\n${key_words.join('\n且满足: ')}`)
|
||||
}
|
||||
|
||||
/**若勾选只转已关注 */
|
||||
if (only_followed && !isFollowed) return false;
|
||||
|
||||
/* 获取黑名单并去重合并 */
|
||||
const { blacklist: remote_blacklist } = global_var.get("remoteconfig")
|
||||
, new_blacklist = remote_blacklist
|
||||
? [...new Set([...blacklist.split(','), ...remote_blacklist.split(',')])].join()
|
||||
: blacklist;
|
||||
if ((new RegExp(dyid + '|' + uid)).test(new_blacklist)) return false;
|
||||
|
||||
if (only_followed
|
||||
&& (!mIsFollowed || !oriIsFollowed)
|
||||
) {
|
||||
log.info("筛选动态", `只转已关注(https://t.bilibili.com/${dyid})`)
|
||||
return false
|
||||
}
|
||||
|
||||
if (isLottery) {
|
||||
const { uname_map = {} } = global_var.get("remoteconfig")
|
||||
let onelotteryinfo = {};
|
||||
|
||||
onelotteryinfo.isOfficialLottery = hasOfficialLottery;
|
||||
@@ -233,15 +480,16 @@ class Monitor extends Searcher {
|
||||
/**初始化待关注列表 */
|
||||
onelotteryinfo.uid = []
|
||||
|
||||
if (!isFollowed) {
|
||||
onelotteryinfo.uid.push(uid);
|
||||
if (!realIsFollowed) {
|
||||
onelotteryinfo.uid.push(real_uid);
|
||||
}
|
||||
|
||||
onelotteryinfo.dyid = dyid;
|
||||
|
||||
let
|
||||
/**转发评语 */
|
||||
RandomStr = utils.getRandomOne(config.relay),
|
||||
RandomStr = (getRandomOne(relays) || "!!!")
|
||||
.replace(/\$\{uname\}/g, uname_map[real_uid] || uname),
|
||||
/**控制字段 */
|
||||
new_ctrl = [];
|
||||
|
||||
@@ -269,7 +517,7 @@ class Monitor extends Searcher {
|
||||
const addlength = RandomStr.length + 2 + uname.length + 1 + 1;
|
||||
onelotteryinfo.relay_chat = RandomStr + `//@${uname}:` + des;
|
||||
new_ctrl.push({
|
||||
data: String(uid),
|
||||
data: String(real_uid),
|
||||
location: RandomStr.length + 2,
|
||||
length: uname.length + 1,
|
||||
type: 1
|
||||
@@ -278,8 +526,9 @@ class Monitor extends Searcher {
|
||||
item.location += addlength;
|
||||
return item;
|
||||
}).forEach(it => new_ctrl.push(it))
|
||||
if (!(new RegExp(uids[1])).test(attentionList))
|
||||
onelotteryinfo.uid.push(uids[1]);
|
||||
if (!oriIsFollowed) {
|
||||
onelotteryinfo.uid.push(ori_uid);
|
||||
}
|
||||
} else {
|
||||
onelotteryinfo.relay_chat = RandomStr;
|
||||
}
|
||||
@@ -287,19 +536,18 @@ class Monitor extends Searcher {
|
||||
onelotteryinfo.ctrl = JSON.stringify(new_ctrl);
|
||||
|
||||
/* 根据动态的类型决定评论的类型 */
|
||||
onelotteryinfo.chat_type =
|
||||
type === 2
|
||||
? 11
|
||||
: type === 4 || type === 1
|
||||
? 17
|
||||
: type === 8
|
||||
? 1
|
||||
: 0;
|
||||
onelotteryinfo.chat_type = chat_type;
|
||||
|
||||
/* 是否评论 */
|
||||
if (isSendChat) onelotteryinfo.rid = rid;
|
||||
if (isSendChat) {
|
||||
onelotteryinfo.rid = rid
|
||||
onelotteryinfo.chat = (getRandomOne(chats) || "!!!")
|
||||
.replace(/\$\{uname\}/g, uname_map[real_uid] || uname)
|
||||
}
|
||||
|
||||
alllotteryinfo.push(onelotteryinfo);
|
||||
} else {
|
||||
log.info("筛选动态", `非抽奖动态(https://t.bilibili.com/${dyid})`)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -309,11 +557,33 @@ class Monitor extends Searcher {
|
||||
* 关注转发评论
|
||||
* @param {LotteryOptions} option
|
||||
* @returns {Promise<number>}
|
||||
* 0 - 成功
|
||||
* 11 - 评论错误
|
||||
* 21 - 关注错误
|
||||
* 22 - 关注异常
|
||||
* 31 - 转发失败
|
||||
* - 成功 0
|
||||
* - 评论 未知错误 1001
|
||||
* - 评论 原动态已删除 1002
|
||||
* - 评论 评论区已关闭 1003
|
||||
* - 评论 需要输入验证码 1004
|
||||
* - 评论 已被对方拉入黑名单 1005
|
||||
* - 评论 黑名单用户无法互动 1006
|
||||
* - 评论 UP主已关闭评论区 1007
|
||||
* - 评论 内容包含敏感信息 1008
|
||||
* - 评论 重复评论 1009
|
||||
* - 评论 帐号未登录 1010
|
||||
* - 评论 关注UP主7天以上的人可发评论 1011
|
||||
* - 关注 未知错误 2001
|
||||
* - 关注 您已被对方拉入黑名单 2002
|
||||
* - 关注 黑名单用户无法关注 2003
|
||||
* - 关注 账号异常 2004
|
||||
* - 关注 关注已达上限 2005
|
||||
* - 分区 移动失败 3001
|
||||
* - 点赞 未知错误 4001
|
||||
* - 点赞 点赞异常 4002
|
||||
* - 点赞 点赞频繁 4003
|
||||
* - 点赞 已赞过 4004
|
||||
* - 点赞 账号异常,点赞失败 4005
|
||||
* - 转发 未知错误 5001
|
||||
* - 转发 该动态不能转发分享 5002
|
||||
* - 转发 请求数据发生错误,请刷新或稍后重试 5003
|
||||
* - 转发 操作太频繁了,请稍后重试 5004
|
||||
*/
|
||||
async go(option) {
|
||||
log.debug('正在转发的动态信息', option);
|
||||
@@ -321,48 +591,104 @@ class Monitor extends Searcher {
|
||||
log.info('NOT_GO_LOTTERY', 'ON');
|
||||
return 0
|
||||
}
|
||||
const { uid, dyid, chat_type, rid, relay_chat, ctrl } = option;
|
||||
|
||||
let
|
||||
status = 0,
|
||||
{ uid, dyid, chat_type, rid, relay_chat, ctrl, chat } = option,
|
||||
{ check_if_duplicated, is_copy_chat, copy_blockword, is_repost_then_chat, is_not_create_partition } = config;
|
||||
|
||||
/* 评论 */
|
||||
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 === -1) {
|
||||
return 0
|
||||
}
|
||||
if (!status) {
|
||||
break
|
||||
}
|
||||
log.info('自动评论', `将在 ${times + 1} 分钟后再次发送评论(${times + 1}/${max_retry_times})`)
|
||||
await utils.delay(60 * 1000 * (times + 1))
|
||||
if (is_copy_chat) {
|
||||
const copy_chat = getRandomOne(
|
||||
(await bili.getChat(rid, chat_type))
|
||||
.filter(it => !(new RegExp(copy_blockword.join('|')).test(it[1])))
|
||||
) || [";;;;;;;;;", chat || "!!!"];
|
||||
chat = copy_chat[1]
|
||||
.replace(
|
||||
new RegExp(copy_chat[0], 'g'),
|
||||
global_var.get("myUNAME") || '')
|
||||
}
|
||||
|
||||
status = await retryfn(
|
||||
6,
|
||||
[4],
|
||||
() => bili.sendChatWithOcr(
|
||||
rid,
|
||||
is_repost_then_chat ? relay_chat.split('//')[0] : chat,
|
||||
chat_type
|
||||
)
|
||||
)
|
||||
|
||||
if (status === 8 ||
|
||||
status === 9) {
|
||||
status = await bili.sendChatWithOcr(
|
||||
rid,
|
||||
"[doge][doge][doge][doge][doge]",
|
||||
chat_type
|
||||
)
|
||||
}
|
||||
|
||||
if (status) {
|
||||
log.warn("抽奖信息", `dyid: ${dyid}, rid: ${rid}, chat_type: ${chat_type}`)
|
||||
return 1000 + status
|
||||
}
|
||||
if (status) return 11;
|
||||
}
|
||||
|
||||
/* 关注 */
|
||||
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) {
|
||||
await try_for_each(uid, async (u) => {
|
||||
status = await bili.autoAttention(u)
|
||||
if (status) {
|
||||
log.warn("抽奖信息", `dyid: ${dyid}, uid: ${u}`)
|
||||
return true
|
||||
} else {
|
||||
if (is_not_create_partition !== true) {
|
||||
if (await bili.movePartition(u, this.tagid)) {
|
||||
log.warn("抽奖信息", `dyid: ${dyid}, uid: ${u} tagid: ${this.tagid}`)
|
||||
/* 3000系错误 */
|
||||
status = 1001
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
})
|
||||
if (status) return 2000 + status
|
||||
}
|
||||
|
||||
/* 点赞 */
|
||||
await bili.autolike(dyid)
|
||||
if (!check_if_duplicated || check_if_duplicated === 3) {
|
||||
status = await retryfn(
|
||||
5,
|
||||
[3],
|
||||
() => bili.autolike(dyid)
|
||||
)
|
||||
|
||||
if (status) {
|
||||
log.warn("抽奖信息", `dyid: ${dyid}`)
|
||||
return 4000 + status
|
||||
}
|
||||
}
|
||||
|
||||
/* 转发 */
|
||||
if (await bili.autoRelay(global_var.get("myUID"), dyid, relay_chat, ctrl)) return 31;
|
||||
if (dyid) {
|
||||
status = await retryfn(
|
||||
5,
|
||||
[3, 4],
|
||||
() => bili.autoRelay(global_var.get("myUID"), dyid, relay_chat, ctrl)
|
||||
)
|
||||
|
||||
return 0
|
||||
if (status) {
|
||||
log.warn("抽奖信息", `dyid: ${dyid}`)
|
||||
return 5000 + status
|
||||
}
|
||||
}
|
||||
|
||||
return status
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
const utils = require('../utils');
|
||||
const bili = require('../net/bili');
|
||||
const config = require("../data/config");
|
||||
const d_storage = require('../helper/d_storage');
|
||||
const { send } = require("../net/http");
|
||||
const { check_if_duplicated, article_scan_page, article_create_time, not_check_article, get_dynamic_detail_wait, uid_scan_page, search_wait, tag_scan_page } = require("../data/config");
|
||||
const d_storage = require("../helper/d_storage")
|
||||
|
||||
const { log } = utils
|
||||
|
||||
@@ -11,22 +12,49 @@ 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 {number} chat_type
|
||||
* @property {string} dynamic_id
|
||||
* @property {number} type
|
||||
* @property {string} description
|
||||
* @property {string} reserve_id
|
||||
* @property {string} reserve_lottery_text
|
||||
* @property {boolean} is_charge_lottery
|
||||
* @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
|
||||
* @property {number} origin_chat_type
|
||||
* @property {string} origin_dynamic_id
|
||||
* @property {number} orig_type
|
||||
* @property {number} origin_type
|
||||
* @property {string} origin_description
|
||||
* @property {string} origin_reserve_id
|
||||
* @property {string} origin_reserve_lottery_text
|
||||
* @property {boolean} origin_is_charge_lottery
|
||||
* @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} reserve_id
|
||||
* @property {string} reserve_lottery_text
|
||||
* @property {boolean} is_charge_lottery
|
||||
* @property {string} rid
|
||||
* @property {number} chat_type
|
||||
* @property {string} des
|
||||
* @property {number} type
|
||||
* @property {boolean} hasOfficialLottery 是否官方
|
||||
*
|
||||
* @param {object} dynamic_detail_card
|
||||
* @return {UsefulDynamicInfo}
|
||||
*/
|
||||
@@ -34,46 +62,123 @@ function parseDynamicCard(dynamic_detail_card) {
|
||||
const { strToJson } = utils;
|
||||
/**临时储存单个动态中的信息 */
|
||||
let obj = {};
|
||||
const { desc, card, extension, extend_json } = dynamic_detail_card
|
||||
, { info } = desc.user_profile
|
||||
const { desc, card, extension, extend_json = "{}", display = {} } = dynamic_detail_card
|
||||
, { is_liked = 1, user_profile = {} } = desc
|
||||
, { info = {} } = user_profile
|
||||
, cardToJson = strToJson(card)
|
||||
, extendjsonToJson = strToJson(extend_json)
|
||||
, { add_on_card_info = [] } = display
|
||||
, { item } = cardToJson;
|
||||
const dy_type2chat_type = new Map([[1, 17], [2, 11], [4, 17], [8, 1], [64, 12]]);
|
||||
/* 转发者的UID */
|
||||
obj.uid = 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
|
||||
/* 用于发送评论 */
|
||||
obj.rid_str = desc.rid_str.length > 12 ? desc.dynamic_id_str : desc.rid_str;
|
||||
/* 源动态类型 */
|
||||
obj.orig_type = desc.orig_type
|
||||
/* 用于发送评论 */
|
||||
obj.chat_type = dy_type2chat_type.get(obj.type) || 0;
|
||||
/* 转发者的动态ID !!!!此为大数需使用字符串值,不然JSON.parse()会有丢失精度 */
|
||||
obj.dynamic_id = desc.dynamic_id_str;
|
||||
/* 定位@信息 */
|
||||
obj.ctrl = (extend_json && strToJson(extend_json).ctrl) || [];
|
||||
obj.ctrl = (extendjsonToJson.ctrl) || [];
|
||||
/* 预约抽奖信息 */
|
||||
if (add_on_card_info.length > 0) {
|
||||
const [status, oid_str, text] = add_on_card_info
|
||||
.filter(it => typeof it.reserve_attach_card !== 'undefined'
|
||||
&& typeof it.reserve_attach_card.reserve_lottery !== 'undefined'
|
||||
&& typeof it.reserve_attach_card.reserve_button !== 'undefined')
|
||||
.map(({ reserve_attach_card }) => [
|
||||
reserve_attach_card.reserve_button.status,
|
||||
reserve_attach_card.oid_str,
|
||||
reserve_attach_card.reserve_lottery.text])[0] || [];
|
||||
if (status === 1) {
|
||||
obj.reserve_id = oid_str;
|
||||
obj.reserve_lottery_text = text;
|
||||
}
|
||||
}
|
||||
if (extendjsonToJson[""]) {
|
||||
let r = extendjsonToJson[""].reserve || {};
|
||||
let { reserve_id, reserve_lottery } = r;
|
||||
if (reserve_lottery === 1) {
|
||||
obj.reserve_id = reserve_id + "";
|
||||
obj.reserve_lottery_text = "信息丢失";
|
||||
}
|
||||
}
|
||||
if (extend_json.match(/"":\{"lottery/)) {
|
||||
obj.is_charge_lottery = true
|
||||
}
|
||||
/* 是否有官方抽奖 */
|
||||
obj.hasOfficialLottery = extension && extension.lott && true;
|
||||
/* 转发者的描述 后两个分别是视频动态的描述和视频本身的描述*/
|
||||
obj.description = (item && (item.content || item.description || cardToJson.dynamic || cardToJson.desc)) || '';
|
||||
/* 转发者的描述 纯文字内容 图片动态描述 后两个分别是视频动态的描述和视频本身的描述*/
|
||||
obj.description =
|
||||
(item && ((item.content || '') + (item.description || '')))
|
||||
|| (
|
||||
(cardToJson.dynamic || '')
|
||||
+ (cardToJson.desc || '')
|
||||
+ (cardToJson.vest && cardToJson.vest.content || '')
|
||||
)
|
||||
|| '';
|
||||
/* 转发 */
|
||||
if (obj.type === 1) {
|
||||
const { origin_extension, origin } = cardToJson
|
||||
const { origin_extension, origin, origin_extend_json = "{}" } = cardToJson
|
||||
, originToJson = strToJson(origin)
|
||||
, { add_on_card_info = [] } = display.origin || {}
|
||||
, originExtendjsonToJson = strToJson(origin_extend_json)
|
||||
, { user, item } = originToJson;
|
||||
/* 源动态的ts10 */
|
||||
obj.origin_create_time = desc.origin.timestamp;
|
||||
/* 被转发者的UID */
|
||||
obj.origin_uid = desc.origin.uid;
|
||||
/* 源动态类型 */
|
||||
obj.origin_type = desc.orig_type
|
||||
/* 被转发者的rid(用于发评论) */
|
||||
obj.origin_rid_str = desc.origin.rid_str.length > 12 ? desc.origin.dynamic_id_str : desc.origin.rid_str;
|
||||
/* 用于发送评论 */
|
||||
obj.origin_chat_type = dy_type2chat_type.get(obj.origin_type) || 0
|
||||
/* 被转发者的动态的ID !!!!此为大数需使用字符串值,不然JSON.parse()会有丢失精度 */
|
||||
obj.origin_dynamic_id = desc.orig_dy_id_str;
|
||||
/* 预约抽奖信息 */
|
||||
if (add_on_card_info.length > 0) {
|
||||
const [status, oid_str, text] = add_on_card_info
|
||||
.filter(it => typeof it.reserve_attach_card !== 'undefined'
|
||||
&& typeof it.reserve_attach_card.reserve_lottery !== 'undefined'
|
||||
&& typeof it.reserve_attach_card.reserve_button !== 'undefined')
|
||||
.map(({ reserve_attach_card }) => [
|
||||
reserve_attach_card.reserve_button.status,
|
||||
reserve_attach_card.oid_str,
|
||||
reserve_attach_card.reserve_lottery.text])[0] || [];
|
||||
if (status === 1) {
|
||||
obj.origin_reserve_id = oid_str;
|
||||
obj.origin_reserve_lottery_text = text;
|
||||
}
|
||||
}
|
||||
if (originExtendjsonToJson[""]) {
|
||||
let r = originExtendjsonToJson[""].reserve || {};
|
||||
let { reserve_id, reserve_lottery } = r;
|
||||
if (reserve_lottery === 1) {
|
||||
obj.origin_reserve_id = reserve_id + "";
|
||||
obj.origin_reserve_lottery_text = "信息丢失";
|
||||
}
|
||||
}
|
||||
if (origin_extend_json.match(/"":\{"lottery/)) {
|
||||
obj.origin_is_charge_lottery = true
|
||||
}
|
||||
/* 是否有官方抽奖 */
|
||||
obj.origin_hasOfficialLottery = origin_extension && origin_extension.lott;
|
||||
/* 被转发者的name */
|
||||
obj.origin_uname = (user && (user.name || user.uname)) || '';
|
||||
/* 被转发者的描述 */
|
||||
obj.origin_description = (item && (item.content || item.description || originToJson.dynamic || originToJson.desc)) || '';
|
||||
obj.origin_description =
|
||||
(item && (item.content || '' + item.description || ''))
|
||||
|| (originToJson.dynamic || '' + originToJson.desc || '')
|
||||
|| '';
|
||||
}
|
||||
|
||||
return obj
|
||||
@@ -98,6 +203,12 @@ function modifyDynamicRes(res) {
|
||||
log.warn('处理动态数据', '未找到任何动态信息')
|
||||
}
|
||||
|
||||
if (typeof has_more === "undefined"
|
||||
&& typeof offset === "undefined") {
|
||||
log.error('处理动态数据', '该功能已失效');
|
||||
return null;
|
||||
}
|
||||
|
||||
const
|
||||
/**
|
||||
* 字符串offset防止损失精度
|
||||
@@ -128,26 +239,13 @@ 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
|
||||
* @param {number} pages 读取页数
|
||||
* @param {number} time 时延
|
||||
* @param {string} [offset] 默认'0'
|
||||
* @returns {Promise<{allModifyDynamicResArray: UsefulDynamicInfo[], offset: string}>} 获取前 `pages*12` 个动态信息
|
||||
* @returns {Promise<{allModifyDynamicResArray: UsefulDynamicInfo[], offset: string} | null>} 获取前 `pages*12` 个动态信息
|
||||
*/
|
||||
static async checkAllDynamic(hostuid, pages, time = 0, offset = '0') {
|
||||
log.info('检查所有动态', `准备读取${pages}页动态`);
|
||||
@@ -176,7 +274,7 @@ class Searcher {
|
||||
mDRdata = modifyDynamicRes(OneDynamicInfo);
|
||||
|
||||
if (mDRdata === null) {
|
||||
break;
|
||||
return null
|
||||
}
|
||||
|
||||
const
|
||||
@@ -203,6 +301,7 @@ class Searcher {
|
||||
|
||||
return ({ allModifyDynamicResArray, offset });
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最新动态信息(转发子动态)
|
||||
* 并初步整理
|
||||
@@ -211,27 +310,65 @@ class Searcher {
|
||||
*/
|
||||
async getLotteryInfoByUID(UID) {
|
||||
log.info('获取动态', `开始获取用户${UID}的动态信息`);
|
||||
const { allModifyDynamicResArray } = await Searcher.checkAllDynamic(UID, config.uid_scan_page, config.search_wait);
|
||||
const AllDynamic = await Searcher.checkAllDynamic(UID, uid_scan_page, search_wait);
|
||||
|
||||
if (!allModifyDynamicResArray.length) return null;
|
||||
if (AllDynamic === null) return null
|
||||
|
||||
let { allModifyDynamicResArray } = AllDynamic,
|
||||
{ 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) => {
|
||||
let
|
||||
results = await pre,
|
||||
{ origin_dynamic_id } = cur,
|
||||
is_liked = false;
|
||||
|
||||
if (!check_if_duplicated || check_if_duplicated >= 2) {
|
||||
const card = await bili.getOneDynamicByDyid(origin_dynamic_id)
|
||||
log.info('获取动态', `查看源动态(${origin_dynamic_id})是否点赞 (${length--})`)
|
||||
if (card) {
|
||||
({ is_liked } = parseDynamicCard(card))
|
||||
}
|
||||
await utils.delay(get_dynamic_detail_wait)
|
||||
}
|
||||
|
||||
results.push({
|
||||
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,
|
||||
reserve_id: cur.origin_reserve_id,
|
||||
reserve_lottery_text: cur.origin_reserve_lottery_text,
|
||||
is_charge_lottery: cur.origin_is_charge_lottery,
|
||||
rid: cur.origin_rid_str,
|
||||
chat_type: cur.origin_chat_type,
|
||||
des: cur.origin_description,
|
||||
type: cur.origin_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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取tag下的抽奖信息(转发母动态)
|
||||
* 并初步整理
|
||||
@@ -239,6 +376,8 @@ class Searcher {
|
||||
* @returns {Promise<LotteryInfo[] | null>}
|
||||
*/
|
||||
async getLotteryInfoByTag(tag_name) {
|
||||
log.info('获取动态', `开始获取带话题#${tag_name}#的动态信息`);
|
||||
|
||||
const
|
||||
tag_id = await bili.getTagIDByTagName(tag_name),
|
||||
hotdy = await bili.getHotDynamicInfoByTagID(tag_id),
|
||||
@@ -246,7 +385,6 @@ class Searcher {
|
||||
|
||||
if (modDR === null) return null;
|
||||
|
||||
log.info('获取动态', `开始获取带话题#${tag_name}#的动态信息`);
|
||||
log.info('获取动态', '成功获取热门动态');
|
||||
|
||||
/**
|
||||
@@ -255,7 +393,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,16 +404,22 @@ 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,
|
||||
dyid: o.dynamic_id,
|
||||
reserve_id: o.reserve_id,
|
||||
reserve_lottery_text: o.reserve_lottery_text,
|
||||
is_charge_lottery: o.is_charge_lottery,
|
||||
rid: o.rid_str,
|
||||
chat_type: o.chat_type,
|
||||
des: o.description,
|
||||
type: o.type,
|
||||
hasOfficialLottery: o.hasOfficialLottery
|
||||
@@ -285,6 +429,7 @@ class Searcher {
|
||||
|
||||
return fomatdata
|
||||
}
|
||||
|
||||
/**
|
||||
* 从专栏中获取抽奖信息
|
||||
* @param {string} key_words
|
||||
@@ -292,55 +437,65 @@ class Searcher {
|
||||
*/
|
||||
async getLotteryInfoByArticle(key_words) {
|
||||
log.info('获取动态', `开始获取含关键词${key_words}的专栏信息`);
|
||||
const cvs = (await bili.searchArticlesByKeyword(key_words)).slice(0, config.article_scan_page);
|
||||
const cvs = (await bili.searchArticlesByKeyword(key_words)).slice(0, article_scan_page);
|
||||
|
||||
/**存储所有专栏中的dyid */
|
||||
let dyinfos = [];
|
||||
/**遍历专栏s */
|
||||
for (const cv of cvs) {
|
||||
for (const { id, pub_time } of cvs) {
|
||||
let now_time = Math.floor(Date.now() / 1000);
|
||||
if ((now_time - pub_time) / 86400 > article_create_time) {
|
||||
log.warn("获取动态", `该专栏(${id})创建时间大于设定天数(${article_create_time}天)`)
|
||||
continue
|
||||
}
|
||||
const
|
||||
content = await bili.getOneArticleByCv(cv),
|
||||
dyids = content.match(/(?<=t.bilibili.com\/)[0-9]+/g) || [],
|
||||
dyids_set = [...new Set(dyids)],
|
||||
content = (await bili.getOneArticleByCv(id) || "").split("推荐文章")[0],
|
||||
dyids = content.match(/[0-9]{18}/g) || [],
|
||||
short_ids = content.match(/(?<=b23.tv\/)[a-zA-Z0-9]{7}/g) || [],
|
||||
short_id_set = [...new Set(short_ids)],
|
||||
short_ids_to_dyids = await Promise.all(short_id_set.map(bili.shortDynamicIdToDyid)),
|
||||
dyid_set = [...new Set([...dyids, ...short_ids_to_dyids])],
|
||||
/**判断此专栏是否查看过的权重 */
|
||||
weight = dyids_set.length / 2;
|
||||
weight = dyid_set.length / 2;
|
||||
|
||||
let { length } = dyids_set,
|
||||
let { length } = dyid_set,
|
||||
/**初始权重 */
|
||||
_weight = 0,
|
||||
/**单个专栏中的dyid */
|
||||
_dyinfos = [];
|
||||
log.info('获取动态', `提取专栏(${cv})中提及的dyid(${length})`)
|
||||
/**遍历某专栏中的dyids */
|
||||
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 || {};
|
||||
log.info('获取动态', `提取专栏(${id})中提及的dyid(${length})`)
|
||||
|
||||
if (code !== 0) {
|
||||
log.error('获取动态', '获取动态数据出错,可能是访问太频繁 \n' + res)
|
||||
/**遍历某专栏中的dyids */
|
||||
for (const dyid of dyid_set) {
|
||||
if (typeof dyid === "string"
|
||||
&& 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 (
|
||||
((!check_if_duplicated || check_if_duplicated >= 2)
|
||||
&& is_liked)
|
||||
|| ((check_if_duplicated >= 1)
|
||||
&& await d_storage.searchDyid(dyid))
|
||||
) {
|
||||
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--})`)
|
||||
@@ -351,11 +506,17 @@ class Searcher {
|
||||
const fomatdata = dyinfos.map(o => {
|
||||
return {
|
||||
lottery_info_type: 'article',
|
||||
create_time: o.create_time,
|
||||
is_liked: o.is_liked,
|
||||
uids: [o.uid, o.origin_uid],
|
||||
uname: o.uname,
|
||||
ctrl: o.ctrl,
|
||||
dyid: o.dynamic_id,
|
||||
reserve_id: o.reserve_id,
|
||||
reserve_lottery_text: o.reserve_lottery_text,
|
||||
is_charge_lottery: o.is_charge_lottery,
|
||||
rid: o.rid_str,
|
||||
chat_type: o.chat_type,
|
||||
des: o.description,
|
||||
type: o.type,
|
||||
hasOfficialLottery: o.hasOfficialLottery
|
||||
@@ -365,7 +526,150 @@ class Searcher {
|
||||
|
||||
return fomatdata
|
||||
}
|
||||
|
||||
/**
|
||||
* 从特定格式的api响应数据中获取抽奖信息
|
||||
* @param {string} api
|
||||
* @returns {Promise<LotteryInfo[] | null>}
|
||||
*/
|
||||
getLotteryInfoByAPI(api) {
|
||||
return new Promise((resolve) => {
|
||||
if (api) {
|
||||
const { strToJson } = utils;
|
||||
log.info('获取动态', `开始获取链接(${api})中的抽奖信息`)
|
||||
if (api.startsWith("file://")) {
|
||||
utils.readLotteryInfoFile(api.substring(7)).then(resolve)
|
||||
} else {
|
||||
send({
|
||||
url: api,
|
||||
config: {
|
||||
redirect: true
|
||||
},
|
||||
method: 'GET',
|
||||
success: ({ body }) => {
|
||||
if (body.err_msg) {
|
||||
log.error("从API响应数据中获取抽奖信息", body.err_msg)
|
||||
resolve(null)
|
||||
} else {
|
||||
const raw_lottery_info = strToJson(body).lottery_info;
|
||||
|
||||
if (raw_lottery_info) {
|
||||
let { length } = raw_lottery_info;
|
||||
if (length) {
|
||||
const lottery_info = raw_lottery_info
|
||||
.reduce(async (pre, cur) => {
|
||||
let results = await pre
|
||||
, { dyid } = cur;
|
||||
|
||||
if (!check_if_duplicated || check_if_duplicated >= 2) {
|
||||
log.info('获取动态', `查看动态(${dyid})是否点赞 (${length--})`)
|
||||
const card = await bili.getOneDynamicByDyid(dyid)
|
||||
|
||||
if (card) {
|
||||
await utils.delay(get_dynamic_detail_wait)
|
||||
|
||||
const { is_liked } = parseDynamicCard(card)
|
||||
|
||||
if (is_liked) {
|
||||
log.info('获取动态', `动态(${dyid})已转发过`)
|
||||
} else {
|
||||
cur.is_liked = is_liked
|
||||
results.push(cur)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
results.push(cur)
|
||||
}
|
||||
|
||||
return results
|
||||
|
||||
}, Promise.resolve([]))
|
||||
|
||||
resolve(lottery_info)
|
||||
return
|
||||
}
|
||||
}
|
||||
log.error("从API响应数据中获取抽奖信息", "非Json数据或没有lottery_info或lottery为空")
|
||||
resolve(null)
|
||||
}
|
||||
},
|
||||
failure: err => {
|
||||
log.error("从API响应数据中获取抽奖信息", err)
|
||||
resolve(null)
|
||||
}
|
||||
})
|
||||
}
|
||||
} else {
|
||||
log.warn('获取动态', `链接为空`)
|
||||
resolve(null)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 从本地文件中获取抽奖信息
|
||||
* @param {string} txt
|
||||
* @returns {Promise<LotteryInfo[] | null>}
|
||||
*/
|
||||
async getLotteryInfoByTxT(txt) {
|
||||
log.info('获取动态', `开始获取${utils.lottery_dyids}`);
|
||||
const dyids = await utils.getLocalLotteryTxt(txt);
|
||||
let
|
||||
length = dyids.length,
|
||||
dyinfos = [];
|
||||
|
||||
for (const dyid of dyids) {
|
||||
if (typeof dyid === "string"
|
||||
&& dyid.length === utils.dyid_length) {
|
||||
|
||||
log.info('获取动态', `查看Txt中所提及动态(${dyid}) (${length--})`)
|
||||
const card = await bili.getOneDynamicByDyid(dyid)
|
||||
|
||||
if (card) {
|
||||
await utils.delay(get_dynamic_detail_wait)
|
||||
|
||||
const parsed_card = parseDynamicCard(card)
|
||||
, { is_liked } = parsed_card;
|
||||
|
||||
if (
|
||||
((!check_if_duplicated || check_if_duplicated >= 2)
|
||||
&& is_liked)
|
||||
|| ((check_if_duplicated >= 1)
|
||||
&& await d_storage.searchDyid(dyid))
|
||||
) {
|
||||
log.info('获取动态', `动态(${dyid})已转发过`)
|
||||
continue
|
||||
}
|
||||
|
||||
dyinfos.push(parsed_card);
|
||||
}
|
||||
} else {
|
||||
log.warn('获取动态', `动态(${dyid})无效 (${length--})`)
|
||||
}
|
||||
}
|
||||
const fomatdata = dyinfos.map(o => {
|
||||
return {
|
||||
lottery_info_type: 'txt',
|
||||
create_time: o.create_time,
|
||||
is_liked: o.is_liked,
|
||||
uids: [o.uid, o.origin_uid],
|
||||
uname: o.uname,
|
||||
ctrl: o.ctrl,
|
||||
dyid: o.dynamic_id,
|
||||
reserve_id: o.reserve_id,
|
||||
reserve_lottery_text: o.reserve_lottery_text,
|
||||
is_charge_lottery: o.is_charge_lottery,
|
||||
rid: o.rid_str,
|
||||
chat_type: o.chat_type,
|
||||
des: o.description,
|
||||
type: o.type,
|
||||
hasOfficialLottery: o.hasOfficialLottery
|
||||
};
|
||||
})
|
||||
log.info('获取动态', `成功获取txt信息`);
|
||||
|
||||
return fomatdata
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module.exports = { Searcher };
|
||||
module.exports = { Searcher, parseDynamicCard };
|
||||
|
||||
@@ -1,19 +1,485 @@
|
||||
const { config_file } = require('../utils');
|
||||
const my_config = require(config_file);
|
||||
|
||||
const config = {
|
||||
...my_config["default_config"],
|
||||
/**
|
||||
* 监视更转的用户uid
|
||||
*/
|
||||
UIDs: [],
|
||||
|
||||
/**
|
||||
* 监视的tag
|
||||
*/
|
||||
|
||||
TAGs: [],
|
||||
/**
|
||||
* 监视的专栏关键词
|
||||
*/
|
||||
Articles: [],
|
||||
|
||||
/**
|
||||
* @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} reserve_id
|
||||
* @property {string} reserve_lottery_text
|
||||
* @property {string} rid
|
||||
* @property {string} des
|
||||
* @property {number} type
|
||||
* @property {boolean} hasOfficialLottery 是否官方
|
||||
* @typedef {object} RespondBody
|
||||
* @property {string} err_msg 错误信息
|
||||
* @property {LotteryInfo[]} lottery_info
|
||||
*
|
||||
* - 从API接口中获取抽奖信息
|
||||
* 获取抽奖信息的链接字符串
|
||||
* @example
|
||||
* ["https://github.com/spiritLHL/sync_lottery"]
|
||||
*
|
||||
* - 从当前路径下符合要求的文件中获取
|
||||
* 文件名
|
||||
* @example
|
||||
* ["file://lottery_info_1.json"]
|
||||
*/
|
||||
APIs: [],
|
||||
|
||||
/**
|
||||
* lottery_dyids目录下抽奖动态文件名(如dyids.txt)
|
||||
* 一行一个dyids
|
||||
*/
|
||||
TxT: [],
|
||||
|
||||
/**
|
||||
* 抽奖参与顺序组合
|
||||
* * 0 - UIDs
|
||||
* * 1 - TAGs
|
||||
* * 2 - Articles
|
||||
* * 3 - APIs
|
||||
* * 4 - TxT
|
||||
* @example
|
||||
* [3,2,1,0]
|
||||
* [1,2,1,2,1]
|
||||
*/
|
||||
LotteryOrder: [2, 0, 1, 3],
|
||||
|
||||
/**
|
||||
* 保存抽奖信息至文件
|
||||
*/
|
||||
save_lottery_info_to_file: false,
|
||||
|
||||
/**
|
||||
* API发送数据类型 {LotteryInfo[]}
|
||||
* 上传抽奖信息的链接字符串
|
||||
*/
|
||||
set_lottery_info_url: "",
|
||||
|
||||
/**
|
||||
* 动态中的关键词(表示须同时满足以下条件)
|
||||
* 符合js正则表达式的字符串
|
||||
*/
|
||||
key_words: [
|
||||
"[抽奖送揪]|福利",
|
||||
"[转关评粉]|参与"
|
||||
],
|
||||
|
||||
/**
|
||||
* - '00' 关闭自动抽奖
|
||||
* - '10' 只转发官方抽奖
|
||||
* - '01' 只转发非官方抽奖
|
||||
* - '11' 都转
|
||||
*/
|
||||
model: '11',
|
||||
|
||||
/**
|
||||
* - '00'关闭自动评论
|
||||
* - '10'只评论官抽
|
||||
* - '01'只评论非官抽
|
||||
* - '11'都评论
|
||||
*/
|
||||
chatmodel: '01',
|
||||
|
||||
/**
|
||||
* 不参与预约抽奖
|
||||
*/
|
||||
disable_reserve_lottery: false,
|
||||
|
||||
/**
|
||||
* 不转发预约抽奖
|
||||
* - 预约抽奖可能与转发抽奖并存
|
||||
*/
|
||||
is_not_relay_reserve_lottery: false,
|
||||
|
||||
/**
|
||||
* 检查是否重复转发
|
||||
* - 不检查 -1
|
||||
* - 通过是否点赞判断(自动点赞) 0
|
||||
* - 检索本地dyids文件 1
|
||||
* - 通过是否点赞判断(不自动点赞)+检索本地dyids文件 2
|
||||
* - 通过是否点赞判断(自动点赞)+检索本地dyids文件 3
|
||||
*/
|
||||
check_if_duplicated: 1,
|
||||
|
||||
/**
|
||||
* 偷塔模式不检查是否重复转发
|
||||
* * 偷塔模式: 临近开奖时参与抽奖
|
||||
*/
|
||||
sneaktower: true,
|
||||
|
||||
/**
|
||||
* 屏蔽动态类型
|
||||
*
|
||||
* | 动态类型 | type值 |
|
||||
* | :------- |:----- |
|
||||
* | 转发 | `1` |
|
||||
* | 含图片 | `2` |
|
||||
* | 无图纯文字 | `4` |
|
||||
* | 视频 | `8` |
|
||||
* | 番剧 | `512` |
|
||||
* | 活动 | `2048` |
|
||||
* | 专栏 | `64` |
|
||||
*/
|
||||
block_dynamic_type: [0],
|
||||
|
||||
/**
|
||||
* - 动态创建时间
|
||||
* - 多少天前
|
||||
*/
|
||||
max_create_time: 60,
|
||||
|
||||
/**
|
||||
* 不加判断的转发所监视的uid转发的动态
|
||||
*/
|
||||
is_imitator: false,
|
||||
|
||||
/**
|
||||
* - 在uid里检索的页数
|
||||
*/
|
||||
uid_scan_page: 3,
|
||||
|
||||
/**
|
||||
* - 在tag里检索的页数
|
||||
*/
|
||||
tag_scan_page: 3,
|
||||
|
||||
/**
|
||||
* - 获取专栏数量
|
||||
*/
|
||||
article_scan_page: 3,
|
||||
|
||||
/**
|
||||
* - 专栏创建时间距离现在的最大天数
|
||||
*/
|
||||
article_create_time: 7,
|
||||
|
||||
/**
|
||||
* - 不检查专栏是否看过,若选择检查可以提高检测效率
|
||||
* - 默认false(检查)
|
||||
*/
|
||||
not_check_article: false,
|
||||
|
||||
/**
|
||||
* - 开奖时间距离现在的最大天数
|
||||
* - 默认不限制
|
||||
*/
|
||||
maxday: Infinity,
|
||||
|
||||
/**
|
||||
* - 循环等待时间(指所有操作完毕后的休眠时间)
|
||||
* - 单位毫秒
|
||||
*/
|
||||
lottery_loop_wait: 0,
|
||||
check_loop_wait: 0,
|
||||
clear_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,
|
||||
|
||||
/**
|
||||
* - 预约抽奖间隔
|
||||
* - 单位毫秒
|
||||
*/
|
||||
reserve_lottery_wait: 6000,
|
||||
|
||||
/**
|
||||
* - 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]],
|
||||
|
||||
/**
|
||||
* - 英文逗号分隔 如: 1,2,3
|
||||
*/
|
||||
blacklist: '',
|
||||
|
||||
/**
|
||||
* - 自动同步 https://gitee.com/shanmite/lottery-notice/raw/master/notice.json
|
||||
* - 使用公共黑名单
|
||||
*/
|
||||
use_public_blacklist: true,
|
||||
|
||||
/**
|
||||
* 屏蔽词
|
||||
*/
|
||||
blockword: ["脚本", "抽奖号", "钓鱼"],
|
||||
|
||||
/**
|
||||
* 转发并评论
|
||||
* - 评论内容与转发内容相同
|
||||
*/
|
||||
is_repost_then_chat: false,
|
||||
|
||||
/**
|
||||
* 转发评语
|
||||
*/
|
||||
relay: ['转发动态'],
|
||||
|
||||
/**
|
||||
* 评论内容
|
||||
*/
|
||||
chat: [
|
||||
'[OK]', '[星星眼]', '[歪嘴]', '[喜欢]', '[偷笑]', '[笑]', '[喜极而泣]', '[辣眼睛]', '[吃瓜]', '[奋斗]',
|
||||
'永不缺席 永不中奖 永不放弃!', '万一呢', '在', '冲吖~', '来了', '万一', '[保佑][保佑]', '从未中,从未停', '[吃瓜]', '[抠鼻][抠鼻]',
|
||||
'来力', '秋梨膏', '[呲牙]', '从不缺席', '分子', '可以', '恰', '不会吧', '1', '好',
|
||||
'rush', '来来来', 'ok', '冲', '凑热闹', '我要我要[打call]', '我还能中!让我中!!!', '大家都散了吧,已经抽完了,是我的', '我是天选之子', '给我中一次吧!',
|
||||
'坚持不懈,迎难而上,开拓创新!', '[OK][OK]', '我来抽个奖', '中中中中中中', '[doge][doge][doge]', '我我我',
|
||||
],
|
||||
|
||||
/**
|
||||
* 是否抄热评
|
||||
*/
|
||||
is_copy_chat: false,
|
||||
|
||||
/**
|
||||
* 热评屏蔽词
|
||||
*/
|
||||
copy_blockword: [],
|
||||
|
||||
/**
|
||||
* - 抽奖UP用户分组id(网页端点击分区后地址栏中的tagid)
|
||||
* - 自动获取
|
||||
*/
|
||||
partition_id: 0,
|
||||
|
||||
/**
|
||||
* - 是否不为抽奖UP单独设置关注分区
|
||||
*/
|
||||
is_not_create_partition: false,
|
||||
|
||||
/**
|
||||
* 是否异常
|
||||
*/
|
||||
is_exception: false,
|
||||
|
||||
/**
|
||||
* 是否关注已达上限
|
||||
*/
|
||||
is_outof_maxfollow: false,
|
||||
|
||||
/**
|
||||
* - 中奖通知关键词(满足一个就推送)
|
||||
* - 符合js正则表达式的字符串
|
||||
* - 若以 ~ 开头则表示为黑名单规则
|
||||
* - 优先级递增
|
||||
*/
|
||||
notice_key_words: [
|
||||
"~预约成功|预约主题",
|
||||
"中奖|获得|填写|写上|提供|收货地址|支付宝账号|码|大会员",
|
||||
"~你的账号在新设备或平台登录成功",
|
||||
"~你预约的直播已开始"
|
||||
],
|
||||
|
||||
/**
|
||||
* 是否发送运行状态通知
|
||||
*/
|
||||
notice_running_state: false,
|
||||
|
||||
/**
|
||||
* - 获取私信页数
|
||||
*/
|
||||
check_session_pages: 16,
|
||||
|
||||
/**
|
||||
* - 清理白名单uid或dyid
|
||||
* - 英文逗号分隔 如: 1,2,3
|
||||
*/
|
||||
clear_white_list: '',
|
||||
|
||||
/**
|
||||
* - 取关分区
|
||||
* - 默认为: 此处存放因抽奖临时关注的up
|
||||
*/
|
||||
clear_partition: '',
|
||||
|
||||
/**
|
||||
* 清理多少天之前的动态或关注
|
||||
*/
|
||||
clear_max_day: 30,
|
||||
|
||||
/**
|
||||
* - 快速移除关注
|
||||
* - 不加判断只去除关注
|
||||
*/
|
||||
clear_quick_remove_attention: false,
|
||||
|
||||
/**
|
||||
* - 快速移除关注
|
||||
* - 不加判断只去除关注
|
||||
* - 移除粉丝数小于指定数量的
|
||||
*/
|
||||
clear_quick_remove_attention_fans_number_smallest: Infinity,
|
||||
|
||||
/**
|
||||
* 是否移除动态
|
||||
*/
|
||||
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}`];
|
||||
if (new_config) {
|
||||
Object.entries(new_config)
|
||||
.forEach(([k, v]) => this[k] = v)
|
||||
}
|
||||
this.init()
|
||||
this.setObject(this.raw_config()[`config_${n}`])
|
||||
},
|
||||
init () {
|
||||
|
||||
init() {
|
||||
this.setObject(this.raw_config()["default_config"])
|
||||
},
|
||||
|
||||
setObject(o = {}) {
|
||||
Object.entries(o).forEach(([k, v]) => this[k] = v)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
const { env_file } = require("../utils");
|
||||
|
||||
const env = {
|
||||
/**
|
||||
* 原始环境
|
||||
* @returns {Object}
|
||||
*/
|
||||
raw_env() {
|
||||
delete require.cache[env_file];
|
||||
return require(env_file)
|
||||
},
|
||||
init() {
|
||||
const raw_env = this.raw_env()
|
||||
this.setEnv({
|
||||
...raw_env["account_parm"],
|
||||
...raw_env["push_parm"]
|
||||
})
|
||||
},
|
||||
/**
|
||||
* @returns {Object[]}
|
||||
*/
|
||||
get_multiple_account() {
|
||||
return this.raw_env()["multiple_account_parm"]
|
||||
},
|
||||
setEnv(o) {
|
||||
process.env = {
|
||||
...process.env,
|
||||
...o
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module.exports = env;
|
||||
@@ -1,8 +1,6 @@
|
||||
const { getRemoteConfig, createDir, createFile } = require("../utils");
|
||||
const { getRemoteConfig, getRandomOne, createDir, createFile, dyids_dir } = require("../utils");
|
||||
const config = require("../data/config");
|
||||
|
||||
const key_map = new Map([['DedeUserID', 'myUID'], ['bili_jct', 'csrf']]);
|
||||
|
||||
let global_var = {
|
||||
inner: {},
|
||||
get(key) {
|
||||
@@ -15,13 +13,40 @@ let global_var = {
|
||||
* 全局变量初始化
|
||||
* 更新config
|
||||
* @param {string} cookie
|
||||
* @param {number} n
|
||||
* @param {string} num
|
||||
*/
|
||||
async init(cookie, n) {
|
||||
async init(cookie, num) {
|
||||
if (cookie) {
|
||||
config.updata(process.env.NUMBER);
|
||||
const
|
||||
key_map = new Map([
|
||||
['DedeUserID', 'myUID'],
|
||||
['bili_jct', 'csrf']]),
|
||||
LotteryOrderMap = new Map([
|
||||
[0, "UIDs"],
|
||||
[1, "TAGs"],
|
||||
[2, "Articles"],
|
||||
[3, "APIs"],
|
||||
[4, "TxT"],
|
||||
]);
|
||||
|
||||
this.set('cookie', cookie);
|
||||
config.updata(num);
|
||||
|
||||
if (!/buvid3/.test(cookie)) {
|
||||
const charset = "0123456789ABCDEF".split("");
|
||||
const buvid3 = "x".repeat(8).split("").map(() => getRandomOne(charset)).join("")
|
||||
+ "-"
|
||||
+ "x".repeat(4).split("").map(() => getRandomOne(charset)).join("")
|
||||
+ "-"
|
||||
+ "x".repeat(4).split("").map(() => getRandomOne(charset)).join("")
|
||||
+ "-"
|
||||
+ "x".repeat(4).split("").map(() => getRandomOne(charset)).join("")
|
||||
+ "-"
|
||||
+ "x".repeat(17).split("").map(() => getRandomOne(charset)).join("")
|
||||
+ "infoc";
|
||||
this.set('cookie', cookie + ";" + buvid3);
|
||||
} else {
|
||||
this.set('cookie', cookie);
|
||||
}
|
||||
|
||||
cookie.split(/\s*;\s*/).forEach(item => {
|
||||
const _item = item.split('=');
|
||||
@@ -29,18 +54,20 @@ let global_var = {
|
||||
this.set(key_map.get(_item[0]), _item[1]);
|
||||
});
|
||||
|
||||
const { UIDs = [], TAGs = [], Articles = [] } = config;
|
||||
this.set('Lottery', [
|
||||
...UIDs.map(it => ['UIDs', it]),
|
||||
...TAGs.map(it => ['TAGs', it]),
|
||||
...Articles.map(it => ['Articles', it])
|
||||
]);
|
||||
const { LotteryOrder } = config;
|
||||
this.set('Lottery',
|
||||
LotteryOrder
|
||||
.map(it => LotteryOrderMap.get(it))
|
||||
.filter(it => typeof it === "string")
|
||||
.map(lottery_option => config[lottery_option].map(it => [lottery_option, it]))
|
||||
.flat()
|
||||
);
|
||||
this.set('remoteconfig', await getRemoteConfig());
|
||||
}
|
||||
await createDir('dyids');
|
||||
await createFile(n < 2 ? 'dyid.txt' : `dyid${n}.txt`, '', 'a')
|
||||
await createFile(dyids_dir, num < 2 ? 'dyid.txt' : `dyid${num}.txt`, '', 'a')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
module.exports = global_var;
|
||||
module.exports = global_var;
|
||||
|
||||
@@ -24,6 +24,9 @@ let BARK_PUSH = '';
|
||||
//注:此处设置github action用户填写到Settings-Secrets里面(Name输入BARK_SOUND , Value输入app提供的铃声名称,例如:birdsong)
|
||||
let BARK_SOUND = '';
|
||||
|
||||
// =======================================pushdeer通知设置区域===========================================
|
||||
let PUSHDEER_URL = '';
|
||||
let PUSHDEER_PUSHKEY = '';
|
||||
|
||||
// =======================================telegram机器人通知设置区域===========================================
|
||||
//此处填你telegram bot 的Token,例如:1077xxx4424:AAFjv0FcqxxxxxxgEMGfi22B4yh15R5uw
|
||||
@@ -43,6 +46,12 @@ let DD_BOT_TOKEN = '';
|
||||
//密钥,机器人安全设置页面,加签一栏下面显示的SEC开头的字符串
|
||||
let DD_BOT_SECRET = '';
|
||||
|
||||
// ================================企业微信应用通知设置区域====================================
|
||||
// 此处填你企业微信应用消息的值(详见文档 https://work.weixin.qq.com/api/doc/90000/90135/90236)
|
||||
// 环境变量名 QYWX_AM 依次填入 corpid,corpsecret,touser(注:多个成员ID使用|隔开),agentid,消息类型(选填,不填默认文本消息类型)
|
||||
// 注意用,号隔开(英文输入法的逗号),例如:wwcff56746d9adwers,B-791548lnzXBE6_BWfxdf3kSTMJr9vFEPKAbh6WERQ,mingcheng,1000001,2COXgjH2UIfERF2zxrtUOKgQ9XklUqMdGSWLBoW_lSDAdafat
|
||||
let QYWX_AM = '';
|
||||
|
||||
// =======================================企业微信机器人通知设置区域===========================================
|
||||
//此处填你企业微信机器人的 webhook(详见文档 https://work.weixin.qq.com/api/doc/90000/90136/91770),例如:693a91f6-7xxx-4bc4-97a0-0ec2sifa5aaa
|
||||
//注:此处设置github action用户填写到Settings-Secrets里面(Name输入QYWX_KEY)
|
||||
@@ -60,6 +69,10 @@ let IGOT_PUSH_KEY = '';
|
||||
let PUSH_PLUS_TOKEN = '';
|
||||
let PUSH_PLUS_USER = '';
|
||||
|
||||
// ===========================================QMSG===========================================
|
||||
let QMSG_KEY = '';
|
||||
let QMSG_QQ = '';
|
||||
|
||||
// ===========================================邮件推送===============================================
|
||||
let SMTP_HOST = '';
|
||||
let SMTP_PORT = '';
|
||||
@@ -84,7 +97,6 @@ if (process.env.QQ_MODE) {
|
||||
QQ_MODE = process.env.QQ_MODE;
|
||||
}
|
||||
|
||||
|
||||
if (process.env.BARK_PUSH) {
|
||||
if (process.env.BARK_PUSH.indexOf('https') > -1 || process.env.BARK_PUSH.indexOf('http') > -1) {
|
||||
//兼容BARK自建用户
|
||||
@@ -101,15 +113,29 @@ if (process.env.BARK_PUSH) {
|
||||
BARK_PUSH = `https://api.day.app/${BARK_PUSH}`
|
||||
}
|
||||
}
|
||||
|
||||
if (process.env.PUSHDEER_URL) {
|
||||
PUSHDEER_URL = process.env.PUSHDEER_URL
|
||||
} else {
|
||||
PUSHDEER_URL = "https://api2.pushdeer.com/message/push";
|
||||
}
|
||||
|
||||
if (process.env.PUSHDEER_PUSHKEY) {
|
||||
PUSHDEER_PUSHKEY = process.env.PUSHDEER_PUSHKEY;
|
||||
}
|
||||
|
||||
if (process.env.TG_BOT_TOKEN) {
|
||||
TG_BOT_TOKEN = process.env.TG_BOT_TOKEN;
|
||||
}
|
||||
|
||||
if (process.env.TG_USER_ID) {
|
||||
TG_USER_ID = process.env.TG_USER_ID;
|
||||
}
|
||||
|
||||
if (process.env.TG_PROXY_HOST) {
|
||||
TG_PROXY_HOST = process.env.TG_PROXY_HOST;
|
||||
}
|
||||
|
||||
if (process.env.TG_PROXY_PORT) {
|
||||
TG_PROXY_PORT = process.env.TG_PROXY_PORT;
|
||||
}
|
||||
@@ -121,6 +147,10 @@ if (process.env.DD_BOT_TOKEN) {
|
||||
}
|
||||
}
|
||||
|
||||
if (process.env.QYWX_AM) {
|
||||
QYWX_AM = process.env.QYWX_AM;
|
||||
}
|
||||
|
||||
if (process.env.QYWX_KEY) {
|
||||
QYWX_KEY = process.env.QYWX_KEY;
|
||||
}
|
||||
@@ -136,6 +166,14 @@ if (process.env.PUSH_PLUS_USER) {
|
||||
PUSH_PLUS_USER = process.env.PUSH_PLUS_USER;
|
||||
}
|
||||
|
||||
if (process.env.QMSG_KEY) {
|
||||
QMSG_KEY = process.env.QMSG_KEY;
|
||||
}
|
||||
|
||||
if (process.env.QMSG_QQ) {
|
||||
QMSG_QQ = process.env.QMSG_QQ;
|
||||
}
|
||||
|
||||
if (process.env.SMTP_HOST) {
|
||||
SMTP_HOST = process.env.SMTP_HOST;
|
||||
}
|
||||
@@ -152,12 +190,13 @@ if (process.env.SMTP_TO_USER) {
|
||||
SMTP_TO_USER = process.env.SMTP_TO_USER;
|
||||
}
|
||||
|
||||
|
||||
//==========================云端环境变量的判断与接收=========================
|
||||
|
||||
|
||||
async function sendNotify(text, desp, params = {}) {
|
||||
//提供10种通知方式
|
||||
if (process.env.NOTE) {
|
||||
desp = `帐号备注: ${process.env.NOTE}\n${desp}`
|
||||
}
|
||||
//提供多种通知方式
|
||||
await Promise.all([
|
||||
//微信server酱
|
||||
serverNotify(text, desp),
|
||||
@@ -167,16 +206,22 @@ async function sendNotify(text, desp, params = {}) {
|
||||
pushPlusNotify(text, desp),
|
||||
//iOS Bark APP
|
||||
barkNotify(text, desp, params),
|
||||
// Pushdeer
|
||||
pushdeerNotify(text, desp),
|
||||
//telegram 机器人
|
||||
tgBotNotify(text, desp),
|
||||
//钉钉机器人
|
||||
ddBotNotify(text, desp),
|
||||
//企业微信应用
|
||||
qywxAmNotify(text, desp),
|
||||
//企业微信机器人
|
||||
qywxBotNotify(text, desp),
|
||||
//iGot
|
||||
iGotNotify(text, desp, params),
|
||||
//QQ酷推
|
||||
coolPush(text, desp),
|
||||
// Qmsg
|
||||
qmsg(text, desp),
|
||||
//电子邮件
|
||||
email(text, desp)
|
||||
])
|
||||
@@ -216,8 +261,8 @@ function serverNotify(text, desp) {
|
||||
}
|
||||
},
|
||||
failure: err => {
|
||||
log.error('发送通知', 'server酱 发送通知调用API失败!!')
|
||||
throw new Error(err);
|
||||
log.error('发送通知', 'server酱 发送通知调用API失败!!' + err)
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
@@ -258,8 +303,8 @@ function serverNotifyTurbo(text, desp) {
|
||||
}
|
||||
},
|
||||
failure: err => {
|
||||
log.error('发送通知', 'server酱(Turbo版) 发送通知调用API失败!!')
|
||||
throw new Error(err);
|
||||
log.error('发送通知', 'server酱(Turbo版) 发送通知调用API失败!!' + err)
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
@@ -314,8 +359,8 @@ function coolPush(text, desp) {
|
||||
}
|
||||
},
|
||||
failure: err => {
|
||||
log.error('发送通知', `酷推 发送${pushMode(QQ_MODE)}通知调用API失败!!`)
|
||||
throw new Error(err);
|
||||
log.error('发送通知', `酷推 发送${pushMode(QQ_MODE)}通知调用API失败!!${err}`)
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
@@ -356,9 +401,8 @@ function barkNotify(text, desp, params = {}) {
|
||||
}
|
||||
},
|
||||
failure: err => {
|
||||
log.error('发送通知', 'Bark APP发送通知调用API失败!!');
|
||||
log.error('发送通知', 'Bark APP发送通知调用API失败!!' + err);
|
||||
resolve();
|
||||
throw new Error(err)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
@@ -368,6 +412,47 @@ function barkNotify(text, desp, params = {}) {
|
||||
})
|
||||
}
|
||||
|
||||
function pushdeerNotify(text, desp) {
|
||||
return new Promise(resolve => {
|
||||
if (PUSHDEER_URL && PUSHDEER_PUSHKEY) {
|
||||
send({
|
||||
method: 'POST',
|
||||
url: PUSHDEER_URL,
|
||||
contents: {
|
||||
pushkey: PUSHDEER_PUSHKEY,
|
||||
text,
|
||||
desp,
|
||||
type: "markdown"
|
||||
},
|
||||
config: {
|
||||
retry: false
|
||||
},
|
||||
success: res => {
|
||||
try {
|
||||
const data = JSON.parse(res.body);
|
||||
if (data.code === 0) {
|
||||
log.info('发送通知', 'Pushdeer推送发送通知消息成功')
|
||||
} else {
|
||||
log.error('发送通知', `Pushdeer推送发送通知消息异常\n${JSON.stringify(data)}`)
|
||||
}
|
||||
} catch (error) {
|
||||
log.error('发送通知', error);
|
||||
} finally {
|
||||
resolve()
|
||||
}
|
||||
},
|
||||
failure: err => {
|
||||
log.error('发送通知', 'Pushdeer推送发送通知调用API失败!!' + err)
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
log.debug('发送通知', '您未提供Pushdeer推送所需的PUSHDEER_URL 和 PUSHDEER_PUSHKEY, 取消Pushdeer推送消息通知');
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function tgBotNotify(text, desp) {
|
||||
return new Promise(resolve => {
|
||||
if (TG_BOT_TOKEN && TG_USER_ID) {
|
||||
@@ -404,15 +489,14 @@ function tgBotNotify(text, desp) {
|
||||
}
|
||||
},
|
||||
failure: err => {
|
||||
log.error('发送通知', 'telegram发送通知消息失败!!')
|
||||
log.error('发送通知', 'telegram发送通知消息失败!!' + err)
|
||||
resolve()
|
||||
throw new Error(err)
|
||||
}
|
||||
}
|
||||
if (TG_PROXY_HOST && TG_PROXY_PORT) {
|
||||
options.proxy = {
|
||||
hostname: TG_PROXY_HOST,
|
||||
port: TG_PROXY_PORT * 1
|
||||
url: "http://" + TG_PROXY_HOST + ":" + TG_PROXY_PORT,
|
||||
auth_headers: []
|
||||
}
|
||||
}
|
||||
send(options)
|
||||
@@ -430,7 +514,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`,
|
||||
@@ -467,8 +551,8 @@ function ddBotNotify(text, desp) {
|
||||
}
|
||||
},
|
||||
failure: err => {
|
||||
log.error('发送通知', '钉钉发送通知消息失败!!')
|
||||
throw new Error(err);
|
||||
log.error('发送通知', '钉钉发送通知消息失败!!' + err)
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
} else if (DD_BOT_TOKEN) {
|
||||
@@ -506,9 +590,8 @@ function ddBotNotify(text, desp) {
|
||||
}
|
||||
},
|
||||
failure: err => {
|
||||
log.error('发送通知', '钉钉发送通知消息失败!!');
|
||||
log.error('发送通知', '钉钉发送通知消息失败!!' + err);
|
||||
resolve();
|
||||
throw new Error(err)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
@@ -518,6 +601,84 @@ function ddBotNotify(text, desp) {
|
||||
})
|
||||
}
|
||||
|
||||
function qywxAmNotify(text, desp) {
|
||||
return new Promise(resolve => {
|
||||
if (QYWX_AM) {
|
||||
const QYWX_AM_AY = QYWX_AM.split(',');
|
||||
send({
|
||||
method: 'POST',
|
||||
url: `https://qyapi.weixin.qq.com/cgi-bin/gettoken`,
|
||||
contents: {
|
||||
corpid: `${QYWX_AM_AY[0]}`,
|
||||
corpsecret: `${QYWX_AM_AY[1]}`,
|
||||
},
|
||||
config: {
|
||||
retry: false
|
||||
},
|
||||
headers: {
|
||||
accept: 'application/json, text/plain, */*',
|
||||
'content-type': 'application/json',
|
||||
},
|
||||
success: res => {
|
||||
try {
|
||||
const data = JSON.parse(res.body);
|
||||
let accesstoken = data.access_token;
|
||||
send({
|
||||
method: 'POST',
|
||||
url: `https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=${accesstoken}`,
|
||||
contents: {
|
||||
touser: `${QYWX_AM_AY[2]}`,
|
||||
agentid: `${QYWX_AM_AY[3]}`,
|
||||
safe: '0',
|
||||
msgtype: 'text',
|
||||
text: {
|
||||
content: `${text}\n\n${desp}`,
|
||||
},
|
||||
},
|
||||
config: {
|
||||
retry: false
|
||||
},
|
||||
headers: {
|
||||
accept: 'application/json, text/plain, */*',
|
||||
'content-type': 'application/json',
|
||||
},
|
||||
success: res => {
|
||||
try {
|
||||
const data = JSON.parse(res.body);
|
||||
if (data.errcode === 0) {
|
||||
log.info('发送通知', '企业微信应用发送通知消息完成。');
|
||||
} else {
|
||||
log.error('发送通知', `${data.errmsg}`);
|
||||
}
|
||||
} catch (e) {
|
||||
log.error('发送通知', e);
|
||||
} finally {
|
||||
resolve();
|
||||
}
|
||||
},
|
||||
failure: err => {
|
||||
log.error('发送通知', '企业微信应用发送通知消息失败!!' + err);
|
||||
resolve();
|
||||
}
|
||||
})
|
||||
} catch (e) {
|
||||
log.error('发送通知', e);
|
||||
} finally {
|
||||
resolve();
|
||||
}
|
||||
},
|
||||
failure: err => {
|
||||
log.error('发送通知', '企业微信应用发送通知消息失败!!' + err);
|
||||
resolve();
|
||||
}
|
||||
})
|
||||
} else {
|
||||
log.debug('发送通知', '您未提供企业微信应用所需的QYWX_AM,取消企业微信应用推送消息通知');
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function qywxBotNotify(text, desp) {
|
||||
return new Promise(resolve => {
|
||||
if (QYWX_KEY) {
|
||||
@@ -552,9 +713,8 @@ function qywxBotNotify(text, desp) {
|
||||
}
|
||||
},
|
||||
failure: err => {
|
||||
log.error('发送通知', '企业微信发送通知消息失败!!');
|
||||
log.error('发送通知', '企业微信发送通知消息失败!!' + err);
|
||||
resolve();
|
||||
throw new Error(err)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
@@ -604,9 +764,8 @@ function iGotNotify(text, desp, params = {}) {
|
||||
}
|
||||
},
|
||||
failure: err => {
|
||||
log.error('发送通知', 'iGot 发送通知调用API失败!!')
|
||||
log.error('发送通知', 'iGot 发送通知调用API失败!!' + err)
|
||||
resolve();
|
||||
throw new Error(err)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
@@ -621,7 +780,7 @@ function pushPlusNotify(text, desp) {
|
||||
if (PUSH_PLUS_TOKEN) {
|
||||
send({
|
||||
method: 'POST',
|
||||
url: 'https://pushplus.hxtrip.com/send',
|
||||
url: 'http://www.pushplus.plus/send',
|
||||
contents: {
|
||||
token: PUSH_PLUS_TOKEN,
|
||||
title: text,
|
||||
@@ -650,9 +809,8 @@ function pushPlusNotify(text, desp) {
|
||||
}
|
||||
},
|
||||
failure: err => {
|
||||
log.error('发送通知', `push+发送${PUSH_PLUS_USER ? '一对多' : '一对一'}通知消息失败!!`)
|
||||
log.error('发送通知', `push+发送${PUSH_PLUS_USER ? '一对多' : '一对一'}通知消息失败!!${err}`)
|
||||
resolve();
|
||||
throw new Error(err)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
@@ -662,6 +820,49 @@ function pushPlusNotify(text, desp) {
|
||||
})
|
||||
}
|
||||
|
||||
async function qmsg(text, desp) {
|
||||
return new Promise(resolve => {
|
||||
if (QMSG_KEY) {
|
||||
send({
|
||||
method: 'POST',
|
||||
url: 'https://qmsg.zendee.cn/send/' + QMSG_KEY,
|
||||
contents: {
|
||||
msg: text + "\n\n" + desp,
|
||||
qq: QMSG_QQ
|
||||
},
|
||||
config: {
|
||||
retry: false
|
||||
},
|
||||
headers: {
|
||||
accept: 'application/json, text/plain, */*',
|
||||
'content-type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
success: res => {
|
||||
try {
|
||||
const data = JSON.parse(res.body);
|
||||
if (data.code === 200) {
|
||||
log.info('发送通知', `qmsg发送通知消息完成。`)
|
||||
} else {
|
||||
log.error('发送通知', `qmsg通知消息失败: ${data.reason}`)
|
||||
}
|
||||
} catch (e) {
|
||||
log.error('发送通知', e);
|
||||
} finally {
|
||||
resolve();
|
||||
}
|
||||
},
|
||||
failure: err => {
|
||||
log.error('发送通知', `qmsg通知消息失败!!` + err)
|
||||
resolve();
|
||||
}
|
||||
})
|
||||
} else {
|
||||
log.debug('发送通知', '您未提供qmsg推送所需的QMSG_KEY,取消qmsg推送消息通知');
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function email(text, desp) {
|
||||
if (SMTP_HOST && SMTP_PORT && SMTP_USER && SMTP_PASS && SMTP_TO_USER) {
|
||||
try {
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
const config = require("../data/config");
|
||||
const bili = require("../net/bili");
|
||||
const utils = require("../utils");
|
||||
|
||||
/**
|
||||
* 随机动态
|
||||
* @param {number} num
|
||||
* @returns
|
||||
*/
|
||||
async function randomDynamic(num) {
|
||||
let dynamics = []
|
||||
const
|
||||
{ create_dy_type, dy_contents, random_dynamic_wait } = config,
|
||||
hasShareVideo = create_dy_type === -1 || create_dy_type === 1,
|
||||
hasRandomCreate = create_dy_type === -1 || create_dy_type === 0 || typeof create_dy_type === 'undefined';
|
||||
|
||||
if (hasShareVideo) {
|
||||
dynamics = await bili.getTopRcmd()
|
||||
for (let index = 0; dynamics.length < num; index++) {
|
||||
dynamics.push(...await bili.getTopRcmd())
|
||||
}
|
||||
}
|
||||
|
||||
if (hasRandomCreate) {
|
||||
for (let index = 0; index < num; index++) {
|
||||
dynamics.push(utils.getRandomOne(dy_contents))
|
||||
}
|
||||
}
|
||||
|
||||
await utils.try_for_each(
|
||||
utils.shuffle(dynamics).slice(0, num),
|
||||
async (dynamic) => {
|
||||
await utils.delay(random_dynamic_wait);
|
||||
if (dynamic instanceof Array && dynamic.length === 2 && typeof dynamic[0] === "number") {
|
||||
await bili.shareVideo(...dynamic)
|
||||
} else {
|
||||
await bili.createDynamic(dynamic)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
module.exports = { randomDynamic }
|
||||
@@ -1,7 +1,7 @@
|
||||
const { isMe } = require('./check');
|
||||
const { clear } = require('./clear');
|
||||
const { start } = require('./lottery');
|
||||
const { update } = require('./update');
|
||||
const { account } = require("./account");
|
||||
const global_var = require('./data/global_var')
|
||||
const bili = require('./net/bili')
|
||||
const { log } = require('./utils')
|
||||
@@ -24,4 +24,4 @@ async function checkCookie(num) {
|
||||
}
|
||||
|
||||
|
||||
module.exports = { start, isMe, clear, update, checkCookie }
|
||||
module.exports = { start, isMe, clear, checkCookie, account }
|
||||
@@ -1,21 +1,25 @@
|
||||
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 { sendNotify } = require('./helper/notify');
|
||||
const { log } = utils;
|
||||
|
||||
async function createRandomDynamic(num) {
|
||||
if (config.create_dy) {
|
||||
log.info('随机动态', `准备创建${num}条随机动态`);
|
||||
const Dynamic = await Searcher.checkAllDynamic(global_var.get("myUID"), 1);
|
||||
if ((Dynamic.allModifyDynamicResArray[0] || { type: 0 }).type === 1) {
|
||||
for (let index = 0; index < num; index++) {
|
||||
await bili.createDynamic(utils.getRandomOne(config.dy_contents));
|
||||
await utils.delay(2000);
|
||||
}
|
||||
const
|
||||
{ allModifyDynamicResArray } = (await utils.retryfn(
|
||||
3,
|
||||
[null],
|
||||
() => Searcher.checkAllDynamic(global_var.get("myUID"), 1)
|
||||
)) || { allModifyDynamicResArray: [] },
|
||||
{ type, origin_type } = allModifyDynamicResArray[0] || {};
|
||||
if (type === 1 && origin_type !== 8) {
|
||||
await randomDynamic(num)
|
||||
} else {
|
||||
log.info('随机动态', '已有非抽奖动态故无需创建');
|
||||
}
|
||||
@@ -24,10 +28,10 @@ async function createRandomDynamic(num) {
|
||||
|
||||
/**
|
||||
* 抽奖主函数
|
||||
* @param {string} cookie
|
||||
* @param {string} num
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
function start() {
|
||||
function start(num) {
|
||||
return new Promise(resolve => {
|
||||
let times = utils.counter();
|
||||
/* 注册事件 */
|
||||
@@ -35,11 +39,10 @@ function start() {
|
||||
const lotterys = global_var.get("Lottery");
|
||||
if (lotterys.length === 0) {
|
||||
log.info('抽奖', '抽奖信息为空');
|
||||
resolve();
|
||||
event_bus.emit('Turn_off_the_Monitor', '抽奖信息为空')
|
||||
return;
|
||||
}
|
||||
if (times.value() === lotterys.length) {
|
||||
await createRandomDynamic(config.create_dy_num);
|
||||
log.info('抽奖', '所有动态转发完毕');
|
||||
times.clear();
|
||||
event_bus.emit('Turn_off_the_Monitor', '目前无抽奖信息,过一会儿再来看看吧')
|
||||
@@ -50,8 +53,14 @@ function start() {
|
||||
await (new Monitor(lottery)).init();
|
||||
});
|
||||
event_bus.on('Turn_off_the_Monitor', async (msg) => {
|
||||
await createRandomDynamic(config.create_dy_num);
|
||||
log.info('结束抽奖', '原因: ' + msg);
|
||||
if (config.notice_running_state) {
|
||||
sendNotify(
|
||||
`动态抽奖-帐号${num}结束抽奖`,
|
||||
`${log._cache.filter(it => /抽奖\]|Error|\s抽奖信息\]/.test(it)).join('\n')}`
|
||||
);
|
||||
}
|
||||
await createRandomDynamic(config.create_dy_num);
|
||||
event_bus.flush();
|
||||
resolve();
|
||||
})
|
||||
|
||||
@@ -1,15 +1,24 @@
|
||||
module.exports = Object.freeze({
|
||||
DYNAMIC_LIKE_THUMB: 'https://api.vc.bilibili.com/dynamic_like/v1/dynamic_like/thumb',
|
||||
DYNAMIC_MIX_RESERVE_ATTACH_CARD_BUTTON: 'https://api.vc.bilibili.com/dynamic_mix/v1/dynamic_mix/reserve_attach_card_button',
|
||||
DYNAMIC_REPOST_REPOST: 'https://api.vc.bilibili.com/dynamic_repost/v1/dynamic_repost/repost',
|
||||
DYNAMIC_REPOST_SHARE: 'https://api.vc.bilibili.com/dynamic_repost/v1/dynamic_repost/share',
|
||||
DYNAMIC_SVR_CREATE_DRAW: 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/create_draw',
|
||||
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_GET_DYNAMIC_DETAIL_V2: 'https://api.vc.bilibili.com/dynamic_svr/v2/dynamic_svr/get_dynamic_detail',
|
||||
DYNAMIC_SVR_GET_DYNAMIC_DETAIL_V3: 'https://api.vc.bilibili.com/dynamic_svr/v3/dynamic_svr/get_dynamic_detail',
|
||||
DYNAMIC_SVR_GET_DYNAMIC_DETAIL_V4: 'https://api.vc.bilibili.com/dynamic_svr/v4/dynamic_svr/get_dynamic_detail',
|
||||
DYNAMIC_SVR_GET_DYNAMIC_DETAIL_V5: 'https://api.vc.bilibili.com/dynamic_svr/v5/dynamic_svr/get_dynamic_detail',
|
||||
DYNAMIC_SVR_GET_DYNAMIC_DETAIL_V6: 'https://api.vc.bilibili.com/dynamic_svr/v6/dynamic_svr/get_dynamic_detail',
|
||||
DYNAMIC_SVR_GET_DYNAMIC_DETAIL_V7: 'https://api.vc.bilibili.com/dynamic_svr/v7/dynamic_svr/get_dynamic_detail',
|
||||
DYNAMIC_SVR_RM_DYNAMIC: 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/rm_dynamic',
|
||||
DYNAMIC_SVR_SPACE_HISTORY: 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/space_history',
|
||||
FEED_GET_ATTENTION_LIST: 'https://api.vc.bilibili.com/feed/v1/feed/get_attention_list',
|
||||
FEED_SETUSERFOLLOW: 'https://api.vc.bilibili.com/feed/v1/feed/SetUserFollow',
|
||||
FETCH_SESSION_MSGS: 'https://api.vc.bilibili.com/svr_sync/v1/svr_sync/fetch_session_msgs',
|
||||
LOTTERY_SVR_LOTTERY_NOTICE: 'https://api.vc.bilibili.com/lottery_svr/v1/lottery_svr/lottery_notice',
|
||||
MSGFEED_AT: 'https://api.bilibili.com/x/msgfeed/at',
|
||||
MSGFEED_REPLAY: 'https://api.bilibili.com/x/msgfeed/reply',
|
||||
MSGFEED_UNREAD: 'https://api.bilibili.com/x/msgfeed/unread',
|
||||
READ_CV: 'https://www.bilibili.com/read/cv{{cv}}',
|
||||
RELATION_BATCH_MODIFY: 'https://api.bilibili.com/x/relation/batch/modify',
|
||||
@@ -23,10 +32,15 @@ module.exports = Object.freeze({
|
||||
SESSION_SVR_GET_SESSIONS: 'https://api.vc.bilibili.com/session_svr/v1/session_svr/get_sessions',
|
||||
SESSION_SVR_SINGLE_UNREAD: 'https://api.vc.bilibili.com/session_svr/v1/session_svr/single_unread',
|
||||
SESSION_SVR_UPDATE_ACK: 'https://api.vc.bilibili.com/session_svr/v1/session_svr/update_ack',
|
||||
SHORTLINK: 'https://b23.tv/{{short_id}}',
|
||||
SPACE_MYINFO: 'https://api.bilibili.com/x/space/myinfo',
|
||||
TAG_INFO: 'https://api.bilibili.com/x/tag/info',
|
||||
TOP_FEED_RCMD: "https://api.bilibili.com/x/web-interface/index/top/feed/rcmd",
|
||||
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',
|
||||
V2_REPLAY: "https://api.bilibili.com/x/v2/reply",
|
||||
WEB_INTERFACE_CARD: 'https://api.bilibili.com/x/web-interface/card',
|
||||
WEB_INTERFACE_NAV_STAT: "https://api.bilibili.com/x/web-interface/nav/stat",
|
||||
WEB_INTERFACE_SEARCH_TYPE: 'https://api.bilibili.com/x/web-interface/search/type',
|
||||
})
|
||||
@@ -1,4 +1,3 @@
|
||||
//@ts-check
|
||||
/**
|
||||
* @typedef {import("http").IncomingHttpHeaders} HttpHeaders 头部信息
|
||||
*
|
||||
@@ -21,12 +20,16 @@
|
||||
* @property {boolean} [redirect] 是否重定向
|
||||
* @property {number} [retry_times] 重试次数
|
||||
*
|
||||
* @typedef ProxyConfig
|
||||
* @property {string} url https?://{IP}:{PORT}
|
||||
* @property {[[string, string]]} auth_headers [[k,v],[k,v]]
|
||||
*
|
||||
* @typedef {object} RequestOptions Http请求选项
|
||||
* @property {string} [method] 请求方法
|
||||
* @property {string} url 完整链接
|
||||
* @property {boolean} [stream] 是否流式数据
|
||||
* @property {RequestConfig} [config] 设置
|
||||
* @property {string} [proxy] 代理 IP:PORT
|
||||
* @property {ProxyConfig} [proxy] HTTP代理 IP:PORT
|
||||
* @property {Object.<string, string|number>} [query] 查询选项
|
||||
* @property {Object.<string, string|number> | string} [contents] 内容
|
||||
* @property {HttpHeaders} [headers] 请求头
|
||||
@@ -35,7 +38,9 @@
|
||||
*/
|
||||
|
||||
const { request: http_request } = require('http');
|
||||
const { HttpProxyAgent } = require('http-proxy-agent');
|
||||
const { request: https_request } = require('https');
|
||||
const { HttpsProxyAgent } = require('https-proxy-agent');
|
||||
const { stringify } = require('querystring');
|
||||
|
||||
/**默认编码 */
|
||||
@@ -65,11 +70,15 @@ 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:') ? https_request : http_request;
|
||||
/**
|
||||
* @type {import("https").RequestOptions}
|
||||
*/
|
||||
let options = {
|
||||
timeout,
|
||||
method: method.toUpperCase(),
|
||||
host: thisURL.host,
|
||||
hostname: thisURL.hostname,
|
||||
port: thisURL.port,
|
||||
path: thisURL.pathname + thisURL.search + thisURL.hash,
|
||||
headers,
|
||||
};
|
||||
@@ -80,9 +89,13 @@ function send(detail) {
|
||||
options.headers['content-length'] = Buffer.byteLength(content, 'utf-8').toString();
|
||||
}
|
||||
if (proxy) {
|
||||
options.headers.host = thisURL.host;
|
||||
options.path = thisURL.href;
|
||||
[options.hostname, options.port] = proxy.split(':');
|
||||
options.agent = (thisURL.protocol === 'https:')
|
||||
? new HttpsProxyAgent(proxy.url)
|
||||
: new HttpProxyAgent(proxy.url);
|
||||
for (const ah of proxy.auth_headers) {
|
||||
options.headers[ah[0]] = ah[1]
|
||||
}
|
||||
options.rejectUnauthorized = false
|
||||
}
|
||||
const req = request(options, res => {
|
||||
let protodata = '';
|
||||
|
||||
@@ -1,14 +1,26 @@
|
||||
const { send } = require('./net/http')
|
||||
const { strToJson, download } = require('./utils')
|
||||
const { strToJson, download, try_for_each } = require('./utils')
|
||||
const { version, checkVersion, log } = require('./utils')
|
||||
|
||||
const
|
||||
platform = new Map([
|
||||
['win32', 'win'],
|
||||
['linux', 'linux'],
|
||||
['darwin', 'macos']
|
||||
]).get(process.platform),
|
||||
arch = new Map([
|
||||
['x64', 'x64'],
|
||||
['arm', 'armv7'],
|
||||
['arm64', 'arm64']
|
||||
]).get(process.arch);
|
||||
|
||||
/**
|
||||
* 获取下载链接
|
||||
* @param {string} owner
|
||||
* @param {string} repo
|
||||
* @returns {Promise<{ download_url: string, text: string }>}
|
||||
* @returns {Promise<{ tag_name:string, assets:Object, text:string }>}
|
||||
*/
|
||||
function getLatestReleaseDownloadUrl(owner, repo) {
|
||||
function getLatestRelease(owner, repo) {
|
||||
return new Promise((resolve, reject) => {
|
||||
send({
|
||||
url: `https://api.github.com/repos/${owner}/${repo}/releases/latest`,
|
||||
@@ -19,29 +31,9 @@ function getLatestReleaseDownloadUrl(owner, repo) {
|
||||
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)
|
||||
if (platform) {
|
||||
try {
|
||||
const download_url = assets
|
||||
.filter(({ name }) => name.includes(platform))
|
||||
.map(({ browser_download_url }) => browser_download_url)[0]
|
||||
resolve({ download_url, text })
|
||||
} catch (err) {
|
||||
reject(err)
|
||||
}
|
||||
} else {
|
||||
reject(`未找到能在此平台(${process.platform})上运行的版本`)
|
||||
}
|
||||
} else {
|
||||
reject('当前已是最新版本')
|
||||
}
|
||||
const release = strToJson(body);
|
||||
if (release.tag_name) {
|
||||
resolve(release)
|
||||
} else {
|
||||
reject(body)
|
||||
}
|
||||
@@ -53,20 +45,47 @@ function getLatestReleaseDownloadUrl(owner, repo) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} releases
|
||||
* @return {boolean}
|
||||
*/
|
||||
function checkPlatform(releases) {
|
||||
return releases.includes(platform)
|
||||
&& releases.includes(arch)
|
||||
}
|
||||
|
||||
/**
|
||||
* 半自动更新
|
||||
*/
|
||||
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')
|
||||
const { tag_name, assets, body: text } = await getLatestRelease('shanmiteko', 'LotteryAutoScript')
|
||||
if (checkVersion(version) < checkVersion(tag_name)) {
|
||||
const download_url = assets
|
||||
.filter(({ name }) => checkPlatform(name))
|
||||
.map(({ browser_download_url }) => browser_download_url)
|
||||
if (download_url.length) {
|
||||
await try_for_each(download_url.entries(), async ([i, url]) => {
|
||||
let proxy_url = "https://ghproxy.com/";
|
||||
proxy_url += url
|
||||
log.warn('自动下载', `切换代理${proxy_url}`)
|
||||
await download(proxy_url, `latest_version${i}.zip`)
|
||||
.catch(async err => {
|
||||
log.error('自动下载', err)
|
||||
proxy_url = url
|
||||
log.warn('自动下载', `使用原始链接${proxy_url}`)
|
||||
await download(proxy_url, `latest_version${i}.zip`)
|
||||
})
|
||||
return false
|
||||
})
|
||||
log.info('自动下载', '成功下载到当前目录')
|
||||
log.info('更新说明', '\n' + text + '\n')
|
||||
} else {
|
||||
throw `未找到能在此平台(${process.platform})-(${process.arch})上运行的版本,建议以源码运行`
|
||||
}
|
||||
} else {
|
||||
throw '当前已是最新版本'
|
||||
}
|
||||
} catch (error) {
|
||||
log.error('更新脚本', error)
|
||||
}
|
||||
|
||||
@@ -13,8 +13,12 @@ const utils = {
|
||||
env_file: path.join(process.cwd(), "env.js"),
|
||||
/**配置文件 */
|
||||
config_file: path.join(process.cwd(), "my_config.js"),
|
||||
/**dyid存储文件 */
|
||||
/**dyids存放目录 */
|
||||
dyids_dir: path.join(process.cwd(), "dyids"),
|
||||
/**lottery_info存放目录 */
|
||||
lottery_info_dir: path.join(process.cwd(), "lottery_info"),
|
||||
/**本地抽奖信息存放目录 */
|
||||
lottery_dyids: path.join(process.cwd(), "lottery_dyids"),
|
||||
/**dyid长度 */
|
||||
dyid_length: 18,
|
||||
/**
|
||||
@@ -59,6 +63,26 @@ const utils = {
|
||||
if (await fn(item)) break
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @template T
|
||||
* @param {number} max_times
|
||||
* @param {Array<T>} unexpected
|
||||
* @param {() => Promise<T>} fn
|
||||
* @return {Promise<T | null>}
|
||||
*/
|
||||
async retryfn(max_times, unexpected, fn) {
|
||||
let ret = null;
|
||||
for (let times = 0; times < max_times; times++) {
|
||||
ret = await fn()
|
||||
if (unexpected.includes(ret)) {
|
||||
utils.log.warn('自动重试', `将在 ${times + 1} 分钟后再次尝试(${times + 1}/${max_times})`)
|
||||
await utils.delay(60 * 1000 * (times + 1))
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
/**
|
||||
* 函数柯里化
|
||||
* @template T
|
||||
@@ -79,16 +103,12 @@ 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(() => {
|
||||
resolve();
|
||||
}, time);
|
||||
});
|
||||
return new Promise(resolve => setTimeout(resolve, time));
|
||||
},
|
||||
/**
|
||||
* 计数器 0..Infinity
|
||||
@@ -143,7 +163,7 @@ const utils = {
|
||||
return array;
|
||||
},
|
||||
/**
|
||||
* 关键词判断
|
||||
* 关键词判断 优先级递增
|
||||
* @param {string} text
|
||||
* @param {string[]} key_words startwith '~' 表示黑名单
|
||||
* @return {boolean}
|
||||
@@ -166,40 +186,120 @@ const utils = {
|
||||
},
|
||||
/**日志 */
|
||||
log: {
|
||||
level: 3,
|
||||
_level: 3,
|
||||
_colors: [
|
||||
chalk.hex('#64B3FF'), chalk.grey, chalk.hex('#FFA500'),
|
||||
chalk.hex('#0070BB'), chalk.hex('#48BB31'), chalk.hex('#BBBB23'), chalk.hex('#FF0006')
|
||||
],
|
||||
_iso_time: () => new Date(Date.now() + 288e5).toISOString().slice(0, -1) + '+08',
|
||||
_cache: [],
|
||||
/**
|
||||
* 初始化默认level为3
|
||||
*/
|
||||
init() {
|
||||
let _level = Number(process.env.LOTTERY_LOG_LEVEL);
|
||||
this.level = isNaN(_level) ? 3 : _level;
|
||||
this._level = isNaN(_level) ? 3 : _level;
|
||||
},
|
||||
/**
|
||||
* @param {String|Array<String>} msg
|
||||
* @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) {
|
||||
this.proPrint(msg.map(it => it.split('').map(l => chalk.hex("#89cff0")(l)).join('')), '\n')
|
||||
},
|
||||
/**
|
||||
* @param {number} done
|
||||
* @param {number} total
|
||||
* @param {number} size
|
||||
*/
|
||||
progress_bar(done, total, size = 30) {
|
||||
let perc = done >= total ? 1 : done / total,
|
||||
bar = ~~(perc * size),
|
||||
status_bar = `\r[${"=".repeat(bar) + ">" + " ".repeat(size - bar)}] ${(perc * 100 + ' ').slice(0, 4)}%`
|
||||
process.stdout.write(status_bar)
|
||||
},
|
||||
debug(context, msg) {
|
||||
if (this.level > 3) {
|
||||
if (this._level > 3) {
|
||||
if (msg instanceof Object) msg = JSON.stringify(msg, null, 4);
|
||||
this.proPrint([chalk.hex('#64B3FF')(`[${new Date(Date.now() + 288e5).toISOString()}]`), chalk.grey("[Debug]"), chalk.hex('#FFA500')(`[${context}]`), chalk.hex('#0070BB')(`[\n${msg}\n]`)])
|
||||
let color_text_pair = [
|
||||
[this._colors[0], `[${this._iso_time()}]`],
|
||||
[this._colors[1], "[Debug]"],
|
||||
[this._colors[2], `[帐号${process.env["NUMBER"]} ${context}]`],
|
||||
[this._colors[3], `[\n${msg}\n]`],
|
||||
];
|
||||
this.proPrint(color_text_pair.map(([color, text]) => color(text)))
|
||||
}
|
||||
},
|
||||
info(context, msg) {
|
||||
if (this.level > 2)
|
||||
this.proPrint([chalk.hex('#64B3FF')(`[${new Date(Date.now() + 288e5).toISOString()}]`), chalk.grey("[Info]"), chalk.hex('#FFA500')(`[${context}]`), chalk.hex('#48BB31')(`[${msg}]`)])
|
||||
if (this._level > 2) {
|
||||
let color_text_pair = [
|
||||
[this._colors[0], `[${this._iso_time()}]`],
|
||||
[this._colors[1], "[Info]"],
|
||||
[this._colors[2], `[帐号${process.env["NUMBER"]} ${context}]`],
|
||||
[this._colors[4], `[${msg}]`],
|
||||
];
|
||||
this._cache.push(color_text_pair.map(it => it[1]).join(' '));
|
||||
this.proPrint(color_text_pair.map(([color, text]) => color(text)))
|
||||
}
|
||||
},
|
||||
warn(context, msg) {
|
||||
if (this.level > 1)
|
||||
this.proPrint([chalk.hex('#64B3FF')(`[${new Date(Date.now() + 288e5).toISOString()}]`), chalk.grey("[Warn]"), chalk.hex('#FFA500')(`[${context}]`), chalk.hex('#BBBB23')(`[\n${msg}\n]`)])
|
||||
if (this._level > 1) {
|
||||
let color_text_pair = [
|
||||
[this._colors[0], `[${this._iso_time()}]`],
|
||||
[this._colors[1], "[Warn]"],
|
||||
[this._colors[2], `[帐号${process.env["NUMBER"]} ${context}]`],
|
||||
[this._colors[5], `[\n${msg}\n]`],
|
||||
];
|
||||
this._cache.push(color_text_pair.map(it => it[1]).join(' '));
|
||||
this.proPrint(color_text_pair.map(([color, text]) => color(text)))
|
||||
}
|
||||
},
|
||||
error(context, msg) {
|
||||
if (this.level > 0)
|
||||
this.proPrint([chalk.hex('#64B3FF')(`[${new Date(Date.now() + 288e5).toISOString()}]`), chalk.grey("[Error]"), chalk.hex('#FFA500')(`[${context}]`), chalk.hex('#FF0006')(`[\n${msg}\n]`)])
|
||||
if (this._level > 0) {
|
||||
let color_text_pair = [
|
||||
[this._colors[0], `[${this._iso_time()}]`],
|
||||
[this._colors[1], "[Error]"],
|
||||
[this._colors[2], `[帐号${process.env["NUMBER"]} ${context}]`],
|
||||
[this._colors[6], `[\n${msg}\n]`],
|
||||
];
|
||||
this._cache.push(color_text_pair.map(it => it[1]).join(' '));
|
||||
this.proPrint(color_text_pair.map(([color, text]) => color(text)))
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 验证码识别
|
||||
* @param {string} url
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
ocr(url) {
|
||||
return new Promise((resolve) => {
|
||||
send({
|
||||
method: 'POST',
|
||||
url: 'http://127.0.0.1:9898/ocr/url/text',
|
||||
headers: {
|
||||
"content-type": 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
},
|
||||
contents: { url },
|
||||
success: res => {
|
||||
resolve(res.body)
|
||||
},
|
||||
failure: () => {
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 下载文件
|
||||
* @param {string} url
|
||||
@@ -215,12 +315,13 @@ const utils = {
|
||||
redirect: true,
|
||||
retry: false
|
||||
},
|
||||
success: ({ resStream }) => {
|
||||
success: ({ headers, resStream }) => {
|
||||
const total_len = Number(headers["content-length"]) || 16000000;
|
||||
let recv_length = 0;
|
||||
const wtbs = fs.createWriteStream(file_name);
|
||||
resStream.on('data', chuck => {
|
||||
recv_length += chuck.length
|
||||
utils.log.proPrint(`已收到:${recv_length} Bytes`)
|
||||
utils.log.progress_bar(recv_length, total_len)
|
||||
})
|
||||
resStream.pipe(wtbs)
|
||||
wtbs.on('finish', () => {
|
||||
@@ -228,7 +329,7 @@ const utils = {
|
||||
resolve()
|
||||
}).on('error', error => {
|
||||
wtbs.destroy()
|
||||
resolve(error)
|
||||
reject(error)
|
||||
})
|
||||
},
|
||||
failure: error => {
|
||||
@@ -248,21 +349,20 @@ const utils = {
|
||||
url: 'https://gitee.com/shanmite/lottery-notice/raw/master/notice.json',
|
||||
headers: {
|
||||
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36',
|
||||
accept: 'text/plain; charset=utf-8',
|
||||
referer: 'https://gitee.com/shanmite/lottery-notice/blob/master/notice.json',
|
||||
},
|
||||
success: res => {
|
||||
try {
|
||||
const body = JSON.parse(res.body);
|
||||
const body = JSON.parse(Buffer.from(res.body, "base64").toString());
|
||||
if (body.node_msg) utils.log.info('公告', '\n' + body.node_msg + '\n');
|
||||
resolve(body.config)
|
||||
} catch (error) {
|
||||
resolve(JSON.parse('{}'))
|
||||
utils.log.error('获取远程设置', '获取远程设置错误: ' + error);
|
||||
resolve({})
|
||||
}
|
||||
},
|
||||
failure: err => {
|
||||
utils.log.error('获取远程设置', '获取远程设置错误: ' + err);
|
||||
resolve(JSON.parse('{}'));
|
||||
resolve({})
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -297,13 +397,14 @@ const utils = {
|
||||
},
|
||||
/**
|
||||
* CreateFile
|
||||
* @param {string} filepath 相对于dyids的文件路径
|
||||
* @param {string} basename
|
||||
* @param {string} filename
|
||||
* @param {string} [defaultValue] 写入默认值
|
||||
* @param {string} flag
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
createFile(filepath, defaultValue, flag) {
|
||||
const fpath = path.join(utils.dyids_dir, filepath);
|
||||
createFile(basename, filename, defaultValue, flag) {
|
||||
const fpath = path.join(basename, filename);
|
||||
const buffer = Buffer.from(defaultValue);
|
||||
return new Promise((resolve, rejects) => {
|
||||
fs.open(fpath, flag, (err, fd) => {
|
||||
@@ -338,6 +439,67 @@ const utils = {
|
||||
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' })
|
||||
},
|
||||
/**
|
||||
* 追加lotteryinfo
|
||||
* @param {string} from
|
||||
* @param {import("./core/searcher").LotteryInfo[]} lottery_info
|
||||
* @return {Promise<void>}
|
||||
*/
|
||||
async appendLotteryInfoFile(from, lottery_info) {
|
||||
let all_lottery_info = {};
|
||||
try {
|
||||
all_lottery_info = utils.strToJson(fs.readFileSync(path.join(utils.lottery_info_dir, `lottery_info_${Number(process.env.NUMBER)}.json`)).toString())
|
||||
} catch (_) {
|
||||
all_lottery_info = {}
|
||||
}
|
||||
await utils.createDir(utils.lottery_info_dir);
|
||||
if (all_lottery_info[from] instanceof Array) {
|
||||
all_lottery_info[from].push(...lottery_info)
|
||||
} else {
|
||||
all_lottery_info[from] = lottery_info
|
||||
}
|
||||
await utils.createFile(utils.lottery_info_dir, `lottery_info_${Number(process.env.NUMBER)}.json`, JSON.stringify(all_lottery_info), "w")
|
||||
},
|
||||
/**
|
||||
* 读取lottery_info
|
||||
* @param {string} filename
|
||||
* @return {Promise<import("./core/searcher").LotteryInfo[]>}
|
||||
*/
|
||||
readLotteryInfoFile(filename) {
|
||||
return new Promise((resolve) => {
|
||||
fs.readFile(path.join(utils.lottery_info_dir, filename), (err, data) => {
|
||||
if (err) {
|
||||
resolve([])
|
||||
} else {
|
||||
let all_lottery_info = utils.strToJson(data.toString('utf8'));
|
||||
resolve(Object.values(all_lottery_info).flat())
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 清空lottery_info file
|
||||
*/
|
||||
async clearLotteryInfo() {
|
||||
await utils.createDir(utils.lottery_info_dir);
|
||||
await utils.createFile(utils.lottery_info_dir, `lottery_info_${Number(process.env.NUMBER)}.json`, "{}", "w")
|
||||
},
|
||||
/**
|
||||
* 获取含抽奖dyids
|
||||
* @param {string} filename
|
||||
* @returns {Promise<Array<String>>}
|
||||
*/
|
||||
getLocalLotteryTxt(filename) {
|
||||
return new Promise((resolve) => {
|
||||
fs.readFile(path.join(utils.lottery_dyids, filename), (err, data) => {
|
||||
if (err) {
|
||||
resolve([])
|
||||
} else {
|
||||
resolve(data.toString("utf8").split(/[^0123456789]+/))
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const { version: ve, env_file, config_file, log, hasEnv, delay, hasFileOrDir } = require("./lib/utils");
|
||||
const { version: ve, env_file, config_file, log, hasEnv, delay, hasFileOrDir, clearLotteryInfo } = require("./lib/utils");
|
||||
|
||||
const metainfo = [
|
||||
` _ _ _ _____ _ _ `,
|
||||
@@ -10,8 +10,7 @@ const metainfo = [
|
||||
` __/ | | | `,
|
||||
` |___/ |_| `,
|
||||
` `,
|
||||
` Verison: v${ve}`,
|
||||
` Written By shanmite`,
|
||||
` This: v${ve} Nodejs: ${process.version} Written By shanmite`,
|
||||
]
|
||||
/**多账号存储 */
|
||||
let multiple_account = [];
|
||||
@@ -34,6 +33,7 @@ async function main() {
|
||||
process.env.COOKIE = acco.COOKIE;
|
||||
process.env.NUMBER = acco.NUMBER;
|
||||
process.env.CLEAR = acco.CLEAR;
|
||||
process.env.NOTE = acco.NOTE;
|
||||
const err_msg = await main();
|
||||
if (err_msg) {
|
||||
return err_msg
|
||||
@@ -46,27 +46,31 @@ async function main() {
|
||||
process.env.ENABLE_MULTIPLE_ACCOUNT = ENABLE_MULTIPLE_ACCOUNT;
|
||||
} else if (COOKIE) {
|
||||
const global_var = require("./lib/data/global_var");
|
||||
await global_var.init(COOKIE, Number(NUMBER));
|
||||
await global_var.init(COOKIE, NUMBER);
|
||||
|
||||
/**引入基础功能 */
|
||||
const { start, isMe, clear, update, checkCookie } = require("./lib/index");
|
||||
const { start, isMe, clear, account, checkCookie } = require("./lib/index");
|
||||
|
||||
log.info('main', '当前为第' + NUMBER + '个账号');
|
||||
log._cache.length = 0
|
||||
|
||||
if (await checkCookie(NUMBER)) {
|
||||
const mode = process.env.lottery_mode;
|
||||
const help_msg = "用法: lottery [OPTIONS]\n\nOPTIONS:\n\tstart 启动抽奖\n\tcheck 中奖检查\n\tclear 清理动态和关注\n\tupdate 检查更新\n\thelp 帮助信息";
|
||||
const { lottery_loop_wait, check_loop_wait, clear_loop_wait, update_loop_wait } = require("./lib/data/config");
|
||||
const help_msg = "用法: lottery [OPTIONS]\n\nOPTIONS:\n\tstart 启动抽奖\n\tcheck 中奖检查\n\tacount 查看帐号信息\n\tclear 清理动态和关注\n\tupdate 检查更新\n\thelp 帮助信息";
|
||||
const { lottery_loop_wait, check_loop_wait, clear_loop_wait, save_lottery_info_to_file } = require("./lib/data/config");
|
||||
switch (mode) {
|
||||
case 'start':
|
||||
log.info('抽奖', '开始运行');
|
||||
loop_wait = lottery_loop_wait;
|
||||
await start();
|
||||
if (save_lottery_info_to_file) {
|
||||
await clearLotteryInfo()
|
||||
}
|
||||
await start(NUMBER);
|
||||
break;
|
||||
case 'check':
|
||||
log.info('中奖检测', '检查是否中奖');
|
||||
loop_wait = check_loop_wait;
|
||||
await isMe();
|
||||
await isMe(NUMBER);
|
||||
break;
|
||||
case 'clear':
|
||||
if (CLEAR) {
|
||||
@@ -75,35 +79,41 @@ async function main() {
|
||||
await clear();
|
||||
}
|
||||
break;
|
||||
case 'update':
|
||||
log.info('检查更新', '开始')
|
||||
loop_wait = update_loop_wait;
|
||||
await update()
|
||||
break;
|
||||
case 'help':
|
||||
return help_msg
|
||||
case 'account':
|
||||
log.info('检查帐号信息', '开始运行');
|
||||
await account();
|
||||
break;
|
||||
case undefined:
|
||||
return "未提供以下参数\n\t[OPTIONS]\n\n" + help_msg
|
||||
default:
|
||||
return `提供了错误的[OPTIONS] -> ${mode}\n\n` + help_msg
|
||||
}
|
||||
} else {
|
||||
return 'Cookie已失效, 切换账号时不要点击退出账号而应直接删除Cookie退出'
|
||||
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')) {
|
||||
@@ -112,20 +122,44 @@ async function main() {
|
||||
} else {
|
||||
log.init();
|
||||
log.error('环境变量初始化', '未在当前目录下找到env.js文件或者在环境变量中设置所需参数');
|
||||
return
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化设置
|
||||
* @returns {boolean} 出错true
|
||||
*/
|
||||
function initConfig() {
|
||||
if (hasFileOrDir(config_file)) {
|
||||
require("./lib/data/config");
|
||||
const config = require("./lib/data/config");
|
||||
config.init();
|
||||
log.info('配置文件初始化', '成功加载my_config.js文件');
|
||||
} else {
|
||||
log.error('配置文件初始化', '未在当前目录下找到my_config.js文件');
|
||||
return
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
(async function () {
|
||||
log.rainbow(metainfo)
|
||||
|
||||
if (initEnv() || initConfig()) return;
|
||||
|
||||
/**OPTIONS */
|
||||
process.env.lottery_mode = process.argv[2]
|
||||
|
||||
if (process.env.lottery_mode === "update") {
|
||||
log.info('检查更新', '开始')
|
||||
await require("./lib/update").update()
|
||||
log.info('检查更新', '请手动解压替换可执行文件')
|
||||
return
|
||||
}
|
||||
|
||||
const err_msg = await main();
|
||||
if (err_msg) {
|
||||
log.error('错误', err_msg);
|
||||
@@ -135,6 +169,7 @@ async function main() {
|
||||
while (loop_wait) {
|
||||
log.info('程序休眠', `${loop_wait / 1000}秒后再次启动`)
|
||||
await delay(loop_wait)
|
||||
if (initEnv() || initConfig()) return;
|
||||
await main()
|
||||
}
|
||||
log.info('结束运行', '未在config.js中设置休眠时间')
|
||||
|
||||
@@ -1,41 +1,93 @@
|
||||
module.exports = {
|
||||
module.exports = Object.freeze({
|
||||
/**
|
||||
* 默认设置(公用)
|
||||
* 修改公用设置可填写到最下方
|
||||
* 单独设置区将会覆盖公共设置
|
||||
*/
|
||||
default_config: {
|
||||
/**
|
||||
* 监视更转的用户uid
|
||||
*/
|
||||
UIDs: [
|
||||
31252386,
|
||||
689277291,
|
||||
241675899
|
||||
],
|
||||
|
||||
/**
|
||||
* 监视的专栏关键词
|
||||
*/
|
||||
Articles: [
|
||||
'抽奖合集'
|
||||
],
|
||||
UIDs: [],
|
||||
|
||||
/**
|
||||
* 监视的tag
|
||||
*/
|
||||
TAGs: [
|
||||
'互动抽奖',
|
||||
'转发抽奖',
|
||||
'动态抽奖',
|
||||
'抽奖',
|
||||
],
|
||||
TAGs: [],
|
||||
|
||||
/**
|
||||
* 监视的专栏关键词
|
||||
*/
|
||||
Articles: [],
|
||||
|
||||
/**
|
||||
* @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} reserve_id
|
||||
* @property {string} reserve_lottery_text
|
||||
* @property {string} rid
|
||||
* @property {string} des
|
||||
* @property {number} type
|
||||
* @property {boolean} hasOfficialLottery 是否官方
|
||||
* @typedef {object} RespondBody
|
||||
* @property {string} err_msg 错误信息
|
||||
* @property {LotteryInfo[]} lottery_info
|
||||
*
|
||||
* - 从API接口中获取抽奖信息
|
||||
* 获取抽奖信息的链接字符串
|
||||
* @example
|
||||
* ["https://github.com/spiritLHL/sync_lottery"]
|
||||
*
|
||||
* - 从当前路径下符合要求的文件中获取
|
||||
* 文件名
|
||||
* @example
|
||||
* ["file://lottery_info_1.json"]
|
||||
*/
|
||||
APIs: ["file://lottery_info_1.json"],
|
||||
|
||||
/**
|
||||
* lottery_dyids目录下抽奖动态文件名(如dyids.txt)
|
||||
* 一行一个dyids(非数字字符分割即可)
|
||||
*/
|
||||
TxT: ["dyids.txt"],
|
||||
|
||||
/**
|
||||
* 抽奖参与顺序组合
|
||||
* * 0 - UIDs
|
||||
* * 1 - TAGs
|
||||
* * 2 - Articles
|
||||
* * 3 - APIs
|
||||
* * 4 - TxT
|
||||
* @example
|
||||
* [3,2,1,0]
|
||||
* [1,2,1,2,1]
|
||||
*/
|
||||
LotteryOrder: [2, 0, 1, 3],
|
||||
|
||||
/**
|
||||
* 保存抽奖信息至文件
|
||||
*/
|
||||
save_lottery_info_to_file: false,
|
||||
|
||||
/**
|
||||
* API发送数据类型 {LotteryInfo[]}
|
||||
* 上传抽奖信息的链接字符串
|
||||
*/
|
||||
set_lottery_info_url: "",
|
||||
|
||||
/**
|
||||
* 动态中的关键词(表示须同时满足以下条件)
|
||||
* 符合js正则表达式的字符串
|
||||
*/
|
||||
key_words: [
|
||||
"[抽奖]",
|
||||
"[转关].*[转关]"
|
||||
"[抽奖送揪]|福利",
|
||||
"[转关评粉]|参与"
|
||||
],
|
||||
|
||||
/**
|
||||
@@ -54,6 +106,54 @@ module.exports = {
|
||||
*/
|
||||
chatmodel: '01',
|
||||
|
||||
/**
|
||||
* 不参与预约抽奖
|
||||
*/
|
||||
disable_reserve_lottery: false,
|
||||
|
||||
/**
|
||||
* 不转关预约抽奖
|
||||
* - 预约抽奖可能与转发抽奖并存
|
||||
*/
|
||||
is_not_relay_reserve_lottery: false,
|
||||
|
||||
/**
|
||||
* 检查是否重复转发
|
||||
* - 不检查 -1
|
||||
* - 通过是否点赞判断(自动点赞) 0
|
||||
* - 检索本地dyids文件 1
|
||||
* - 通过是否点赞判断(不自动点赞)+检索本地dyids文件 2
|
||||
* - 通过是否点赞判断(自动点赞)+检索本地dyids文件 3
|
||||
*/
|
||||
check_if_duplicated: 1,
|
||||
|
||||
/**
|
||||
* 偷塔模式不检查是否重复转发
|
||||
* * 偷塔模式: 临近开奖时参与抽奖
|
||||
*/
|
||||
sneaktower: true,
|
||||
|
||||
/**
|
||||
* 屏蔽动态类型
|
||||
*
|
||||
* | 动态类型 | type值 |
|
||||
* | :------- |:----- |
|
||||
* | 转发 | `1` |
|
||||
* | 含图片 | `2` |
|
||||
* | 无图纯文字 | `4` |
|
||||
* | 视频 | `8` |
|
||||
* | 番剧 | `512` |
|
||||
* | 活动 | `2048` |
|
||||
* | 专栏 | `64` |
|
||||
*/
|
||||
block_dynamic_type: [0],
|
||||
|
||||
/**
|
||||
* - 动态创建时间
|
||||
* - 多少天前
|
||||
*/
|
||||
max_create_time: 60,
|
||||
|
||||
/**
|
||||
* 不加判断的转发所监视的uid转发的动态
|
||||
*/
|
||||
@@ -74,6 +174,17 @@ module.exports = {
|
||||
*/
|
||||
article_scan_page: 3,
|
||||
|
||||
/**
|
||||
* - 专栏创建时间距离现在的最大天数
|
||||
*/
|
||||
article_create_time: 7,
|
||||
|
||||
/**
|
||||
* - 不检查专栏是否看过,若选择检查可以提高检测效率
|
||||
* - 默认false(检查)
|
||||
*/
|
||||
not_check_article: false,
|
||||
|
||||
/**
|
||||
* - 开奖时间距离现在的最大天数
|
||||
* - 默认不限制
|
||||
@@ -87,7 +198,6 @@ module.exports = {
|
||||
lottery_loop_wait: 0,
|
||||
check_loop_wait: 0,
|
||||
clear_loop_wait: 0,
|
||||
update_loop_wait: 0,
|
||||
|
||||
/**
|
||||
* - 转发间隔时间
|
||||
@@ -100,7 +210,49 @@ 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,
|
||||
|
||||
/**
|
||||
* - 预约抽奖间隔
|
||||
* - 单位毫秒
|
||||
*/
|
||||
reserve_lottery_wait: 6000,
|
||||
|
||||
/**
|
||||
* - up主粉丝数限制
|
||||
@@ -118,15 +270,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
|
||||
@@ -135,29 +293,51 @@ 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
|
||||
* - 动态dyid或UID
|
||||
* - 英文逗号分隔 如: 1,2,3
|
||||
*/
|
||||
blacklist: '',
|
||||
|
||||
/**
|
||||
* - 自动同步 https://gitee.com/shanmite/lottery-notice/raw/master/notice.json
|
||||
* - 使用公共黑名单
|
||||
*/
|
||||
use_public_blacklist: true,
|
||||
|
||||
/**
|
||||
* 屏蔽词
|
||||
*/
|
||||
blockword: ["脚本抽奖", "恭喜", "结果", "抽奖号", "钓鱼", "涨粉"],
|
||||
blockword: ["脚本", "抽奖号", "钓鱼"],
|
||||
|
||||
/**
|
||||
* 转发并评论
|
||||
* - 评论内容与转发内容相同
|
||||
*/
|
||||
is_repost_then_chat: false,
|
||||
|
||||
/**
|
||||
* 转发评语
|
||||
* 支持变量${uname}
|
||||
*/
|
||||
relay: ['转发动态'],
|
||||
|
||||
/**
|
||||
* 评论内容
|
||||
* 支持变量${uname}
|
||||
* @example
|
||||
* "祝${uname}早日百大!"
|
||||
*/
|
||||
chat: [
|
||||
'[OK]', '[星星眼]', '[歪嘴]', '[喜欢]', '[偷笑]', '[笑]', '[喜极而泣]', '[辣眼睛]', '[吃瓜]', '[奋斗]',
|
||||
@@ -167,6 +347,16 @@ module.exports = {
|
||||
'坚持不懈,迎难而上,开拓创新!', '[OK][OK]', '我来抽个奖', '中中中中中中', '[doge][doge][doge]', '我我我',
|
||||
],
|
||||
|
||||
/**
|
||||
* 是否抄热评
|
||||
*/
|
||||
is_copy_chat: false,
|
||||
|
||||
/**
|
||||
* 热评屏蔽词
|
||||
*/
|
||||
copy_blockword: ["三不原则"],
|
||||
|
||||
/**
|
||||
* - 抽奖UP用户分组id(网页端点击分区后地址栏中的tagid)
|
||||
* - 自动获取
|
||||
@@ -174,20 +364,43 @@ module.exports = {
|
||||
partition_id: 0,
|
||||
|
||||
/**
|
||||
* 是否关注异常
|
||||
* - 是否不为抽奖UP单独设置关注分区
|
||||
*/
|
||||
is_not_create_partition: false,
|
||||
|
||||
/**
|
||||
* 是否异常
|
||||
*/
|
||||
is_exception: false,
|
||||
|
||||
/**
|
||||
* 是否关注已达上限
|
||||
*/
|
||||
is_outof_maxfollow: false,
|
||||
|
||||
/**
|
||||
* - 中奖通知关键词(满足一个就推送)
|
||||
* - 符合js正则表达式的字符串
|
||||
* - 若以 ~ 开头则表示为黑名单规则
|
||||
* - 优先级递增
|
||||
*/
|
||||
notice_key_words: [
|
||||
"~预约成功|预约主题",
|
||||
"中奖|获得|填写|写上|提供|收货地址|支付宝账号|码|大会员",
|
||||
"~有奖预约通知"
|
||||
"~你的账号在新设备或平台登录成功",
|
||||
"~你预约的直播已开始"
|
||||
],
|
||||
|
||||
/**
|
||||
* 是否发送运行状态通知
|
||||
*/
|
||||
notice_running_state: false,
|
||||
|
||||
/**
|
||||
* - 获取私信页数
|
||||
*/
|
||||
check_session_pages: 16,
|
||||
|
||||
/**
|
||||
* - 清理白名单uid或dyid
|
||||
* - 英文逗号分隔 如: 1,2,3
|
||||
@@ -197,6 +410,7 @@ module.exports = {
|
||||
/**
|
||||
* - 取关分区
|
||||
* - 默认为: 此处存放因抽奖临时关注的up
|
||||
* - 可用逗号分割以取关多分区
|
||||
*/
|
||||
clear_partition: '',
|
||||
|
||||
@@ -211,6 +425,13 @@ module.exports = {
|
||||
*/
|
||||
clear_quick_remove_attention: false,
|
||||
|
||||
/**
|
||||
* - 快速移除关注
|
||||
* - 不加判断只去除关注
|
||||
* - 移除粉丝数小于指定数量的
|
||||
*/
|
||||
clear_quick_remove_attention_fans_number_smallest: Infinity,
|
||||
|
||||
/**
|
||||
* 是否移除动态
|
||||
*/
|
||||
@@ -222,7 +443,7 @@ module.exports = {
|
||||
clear_remove_attention: true,
|
||||
|
||||
/**
|
||||
* 清除动态延时(毫秒)
|
||||
* 清除延时(毫秒)
|
||||
*/
|
||||
clear_remove_delay: 8000,
|
||||
|
||||
@@ -236,17 +457,43 @@ module.exports = {
|
||||
* | 含图片 | `2` |
|
||||
* | 无图纯文字 | `4` |
|
||||
* | 视频 | `8` |
|
||||
* | 番剧 | `512` |
|
||||
* | 活动 | `2048` |
|
||||
* | 专栏 | `64` |
|
||||
*
|
||||
* @example
|
||||
* 1
|
||||
* [1,2,4]
|
||||
*/
|
||||
clear_dynamic_type: 1
|
||||
clear_dynamic_type: [1]
|
||||
},
|
||||
|
||||
/**
|
||||
* 针对某一账号的特别设置
|
||||
* config_[数字] 依次类推
|
||||
*/
|
||||
config_1: {},
|
||||
config_1: {
|
||||
/**
|
||||
* 手动添加抽奖号UID
|
||||
* - 抽奖动态下的二级小号
|
||||
*/
|
||||
UIDs: [],
|
||||
|
||||
TAGs: [
|
||||
'互动抽奖',
|
||||
'转发抽奖',
|
||||
'动态抽奖',
|
||||
'抽奖',
|
||||
],
|
||||
|
||||
Articles: [
|
||||
'抽奖合集'
|
||||
],
|
||||
|
||||
APIs: [],
|
||||
|
||||
save_lottery_info_to_file: true,
|
||||
},
|
||||
config_2: {},
|
||||
config_3: {}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
{
|
||||
"name": "lottery-auto-script",
|
||||
"version": "2.1.1",
|
||||
"version": "2.8.4",
|
||||
"description": "自动参与B站动态抽奖",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"start": "node main.js start",
|
||||
"test": "node test/index.js",
|
||||
"clear": "node main.js clear",
|
||||
"check": "node main.js check",
|
||||
"update": "node main.js update",
|
||||
"pkg_x64": "PowerShell .\\script\\pkg\\pkg.ps1",
|
||||
"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"
|
||||
"account": "node main.js account",
|
||||
"help": "node main.js help",
|
||||
"pkg": "bash script/build/pkg.sh",
|
||||
"changelog": "bash script/build/changelog.sh"
|
||||
},
|
||||
"files": [
|
||||
"lib",
|
||||
@@ -22,14 +24,6 @@
|
||||
"README.md"
|
||||
],
|
||||
"bin": "main.js",
|
||||
"pkg": {
|
||||
"targets": [
|
||||
"linux-x64",
|
||||
"win-x64",
|
||||
"macos-x64"
|
||||
],
|
||||
"outputPath": "dist"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/shanmiteko/AutoScript.git"
|
||||
@@ -45,11 +39,13 @@
|
||||
},
|
||||
"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",
|
||||
"http-proxy-agent": "^7.0.0",
|
||||
"https-proxy-agent": "^7.0.0",
|
||||
"nodemailer": "^6.7.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# version: <major.minor.patch>
|
||||
level=patch
|
||||
|
||||
npm version $level \
|
||||
--no-commit-hooks \
|
||||
--no-git-tag-version
|
||||
|
||||
OLD_VERSION_ARRAY=($(npm view lottery-auto-script version | tr '.' ' '))
|
||||
major=${OLD_VERSION_ARRAY[0]}
|
||||
minor=${OLD_VERSION_ARRAY[1]}
|
||||
patch=${OLD_VERSION_ARRAY[2]}
|
||||
|
||||
case "${level}" in
|
||||
"major")
|
||||
((major += 1))
|
||||
minor=0
|
||||
patch=0
|
||||
;;
|
||||
"minor")
|
||||
((minor += 1))
|
||||
patch=0
|
||||
;;
|
||||
*)
|
||||
((patch += 1))
|
||||
;;
|
||||
esac
|
||||
|
||||
NEW_VERSION="$major.$minor.$patch"
|
||||
|
||||
echo "New Version: $NEW_VERSION"
|
||||
|
||||
GIT_LOG="$(git log --pretty=format:"* %h %s" | sed -e '/CHANGELOG/,$d' | sed ':a;N;s/\n/\\n/g;ta')"
|
||||
|
||||
sed -i "/# CHANGELOG/a\## 主要变化($NEW_VERSION)\n$GIT_LOG\n\n_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_\n" CHANGELOG.md
|
||||
|
||||
git add .
|
||||
git commit -m "docs: 更新CHANGELOG"
|
||||
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
ROOT=$PWD
|
||||
README="README.md"
|
||||
TEMPLATE_CONFIG_FILE="my_config.example.js"
|
||||
TEMPLATE_ENV_FILE="env.example.js"
|
||||
CONFIG_FILE="my_config.js"
|
||||
ENV_FILE="env.js"
|
||||
TARGET_DIR="dist"
|
||||
BIN_NAME="lottery"
|
||||
|
||||
create_win_bat() {
|
||||
echo "@echo off && lottery $1 && pause"
|
||||
}
|
||||
|
||||
if [ -d "$TARGET_DIR" ]; then
|
||||
rm -rf "$TARGET_DIR"
|
||||
fi
|
||||
|
||||
if [[ -z "$1" ]]; then
|
||||
$1=node18-linux-x64
|
||||
fi
|
||||
|
||||
mkdir -p $TARGET_DIR
|
||||
npm install
|
||||
|
||||
if [[ "$1" == *"arm"* ]]; then
|
||||
OUTFILE="$TARGET_DIR/lottery-auto-script-node18-$1"
|
||||
sudo podman run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
||||
podman run -it \
|
||||
--rm \
|
||||
-v ${PWD}:/root/lottery \
|
||||
shanmite/pkg-arm64 -t "node18.5.0-$1" -o "$OUTFILE" .
|
||||
elif [[ "$1" == *"x64"* ]]; then
|
||||
OUTFILE="$TARGET_DIR/lottery-auto-script-$1"
|
||||
npx pkg -t "$1" -o "$OUTFILE" .
|
||||
fi
|
||||
|
||||
for file in "$TARGET_DIR/"*; do
|
||||
TMPDIR="${file%.exe}"
|
||||
TMPDIR_NAME="${TMPDIR##*/}"
|
||||
REMANE_FILE="$TARGET_DIR/$BIN_NAME"
|
||||
mv $file $REMANE_FILE
|
||||
mkdir -p "$TMPDIR.d/"
|
||||
mv $REMANE_FILE "$TMPDIR.d/"
|
||||
cp $README "$TMPDIR.d/"
|
||||
cp $TEMPLATE_CONFIG_FILE "$TMPDIR.d/$CONFIG_FILE"
|
||||
cp $TEMPLATE_ENV_FILE "$TMPDIR.d/$ENV_FILE"
|
||||
if [ "$(echo $file | grep '.exe')" ]; then
|
||||
BATS=("start" "check" "clear" "account" "update")
|
||||
for item in "${BATS[@]}"; do
|
||||
create_win_bat "${item}" >"$TMPDIR.d/$item.bat"
|
||||
done
|
||||
mv "$TMPDIR.d/$BIN_NAME" "$TMPDIR.d/$BIN_NAME.exe"
|
||||
else
|
||||
ZIP_NAME=latest_version0
|
||||
cat >"$TMPDIR.d/update.sh" <<-EOF
|
||||
#!/bin/bash
|
||||
./lottery update
|
||||
ZIP_NAME=$ZIP_NAME
|
||||
if [[ -r "\$ZIP_NAME.zip" ]]; then
|
||||
unzip \$ZIP_NAME.zip
|
||||
rm \$ZIP_NAME.zip
|
||||
chmod u+x lottery
|
||||
fi
|
||||
EOF
|
||||
fi
|
||||
cd $TMPDIR.d
|
||||
zip -r "$TMPDIR_NAME.zip" .
|
||||
mv "$TMPDIR_NAME.zip" ../
|
||||
cd $ROOT
|
||||
done
|
||||
@@ -1,10 +1,35 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# docker环境预安装
|
||||
REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'" "fedora" "arch")
|
||||
RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS" "Fedora" "Arch")
|
||||
PACKAGE_UPDATE=("! apt-get update && apt-get --fix-broken install -y && apt-get update" "apt-get update" "yum -y update" "yum -y update" "yum -y update" "pacman -Sy")
|
||||
PACKAGE_INSTALL=("apt-get -y install" "apt-get -y install" "yum -y install" "yum -y install" "yum -y install" "pacman -Sy --noconfirm --needed")
|
||||
PACKAGE_REMOVE=("apt-get -y remove" "apt-get -y remove" "yum -y remove" "yum -y remove" "yum -y remove" "pacman -Rsc --noconfirm")
|
||||
PACKAGE_UNINSTALL=("apt-get -y autoremove" "apt-get -y autoremove" "yum -y autoremove" "yum -y autoremove" "yum -y autoremove" "")
|
||||
CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')" "$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)")
|
||||
SYS="${CMD[0]}"
|
||||
[[ -n $SYS ]] || exit 1
|
||||
for ((int = 0; int < ${#REGEX[@]}; int++)); do
|
||||
if [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]]; then
|
||||
SYSTEM="${RELEASE[int]}"
|
||||
[[ -n $SYSTEM ]] && break
|
||||
fi
|
||||
done
|
||||
if ! systemctl is-active docker >/dev/null 2>&1; then
|
||||
if [ $SYSTEM = "CentOS" ]; then
|
||||
${PACKAGE_INSTALL[int]} yum-utils
|
||||
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo &&
|
||||
${PACKAGE_INSTALL[int]} docker-ce docker-ce-cli containerd.io
|
||||
systemctl enable --now docker
|
||||
else
|
||||
${PACKAGE_INSTALL[int]} docker.io
|
||||
fi
|
||||
fi
|
||||
|
||||
# 脚本根目录
|
||||
SCRIPT_FOLDER=lottery
|
||||
# dyid存放目录
|
||||
DYID_FOLDER=dyids
|
||||
# 设置环境变量文件
|
||||
ENV_FILE=env.js
|
||||
# 自定义设置文件
|
||||
@@ -26,20 +51,14 @@ 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"
|
||||
curl -fsSL $ENV_EXAMPLE -o $ENV_FILE
|
||||
else
|
||||
echo "$ENV_FILE exists"
|
||||
echo "$ENV_FILE already existed"
|
||||
echo "create new_$ENV_FILE"
|
||||
curl -fsSL $ENV_EXAMPLE -o "new_$ENV_FILE"
|
||||
fi
|
||||
|
||||
# 新建配置文件
|
||||
@@ -47,41 +66,125 @@ if [ ! -f "$CONFIG_FILE" ]; then
|
||||
echo "create $CONFIG_FILE"
|
||||
curl -fsSL $CONFIG_EXAMPLE -o $CONFIG_FILE
|
||||
else
|
||||
echo "$CONFIG_FILE exists"
|
||||
echo "$CONFIG_FILE already existed"
|
||||
echo "create new_$CONFIG_FILE"
|
||||
curl -fsSL $CONFIG_EXAMPLE -o "new_$CONFIG_FILE"
|
||||
fi
|
||||
|
||||
echo "docker pull $DOCKER_REPO"
|
||||
docker -v && docker pull $DOCKER_REPO
|
||||
|
||||
echo "create start.sh"
|
||||
echo -e "#!/bin/bash\n\
|
||||
docker run \
|
||||
-v $PWD/$ENV_FILE:/lottery/$ENV_FILE \
|
||||
-v $PWD/$CONFIG_FILE:/lottery/$CONFIG_FILE \
|
||||
-v $PWD/$DYID_FOLDER/:/lottery/$DYID_FOLDER/ \
|
||||
$DOCKER_REPO \
|
||||
start" \
|
||||
> start.sh
|
||||
cat >start.sh <<EOF
|
||||
#!$(which env) bash
|
||||
NAME=shanmite-lottery-start
|
||||
if [[ -z "\$(docker ps -a | grep \$NAME)" ]]; then
|
||||
docker run \\
|
||||
-v $PWD/$ENV_FILE:/lottery/$ENV_FILE \\
|
||||
-v $PWD/$CONFIG_FILE:/lottery/$CONFIG_FILE \\
|
||||
--network host \\
|
||||
--name \$NAME \\
|
||||
$DOCKER_REPO \\
|
||||
start
|
||||
else
|
||||
echo "container \$NAME already existed"
|
||||
echo "history logs -> docker logs \$NAME"
|
||||
echo "close this -> docker stop \$NAME"
|
||||
echo "start \$NAME"
|
||||
docker start \$NAME
|
||||
fi
|
||||
EOF
|
||||
chmod +x start.sh
|
||||
|
||||
echo "create check.sh"
|
||||
echo -e "#!/bin/bash\n\
|
||||
docker run \
|
||||
-v $PWD/$ENV_FILE:/lottery/$ENV_FILE \
|
||||
-v $PWD/$CONFIG_FILE:/lottery/$CONFIG_FILE \
|
||||
-v $PWD/$DYID_FOLDER/:/lottery/$DYID_FOLDER/ \
|
||||
$DOCKER_REPO \
|
||||
check" \
|
||||
> check.sh
|
||||
cat >check.sh <<EOF
|
||||
#!$(which env) bash
|
||||
NAME=shanmite-lottery-check
|
||||
if [[ -z "\$(docker ps -a | grep \$NAME)" ]]; then
|
||||
docker run \\
|
||||
-v $PWD/$ENV_FILE:/lottery/$ENV_FILE \\
|
||||
-v $PWD/$CONFIG_FILE:/lottery/$CONFIG_FILE \\
|
||||
--network host \\
|
||||
--name \$NAME \\
|
||||
$DOCKER_REPO \\
|
||||
check
|
||||
else
|
||||
echo "container \$NAME already existed"
|
||||
echo "history logs -> docker logs \$NAME"
|
||||
echo "close this -> docker stop \$NAME"
|
||||
echo "start \$NAME"
|
||||
docker start \$NAME
|
||||
fi
|
||||
EOF
|
||||
chmod +x check.sh
|
||||
|
||||
echo "create account.sh"
|
||||
cat >account.sh <<EOF
|
||||
#!$(which env) bash
|
||||
NAME=shanmite-lottery-account
|
||||
if [[ -z "\$(docker ps -a | grep \$NAME)" ]]; then
|
||||
docker run \\
|
||||
-v $PWD/$ENV_FILE:/lottery/$ENV_FILE \\
|
||||
-v $PWD/$CONFIG_FILE:/lottery/$CONFIG_FILE \\
|
||||
--network host \\
|
||||
--name \$NAME \\
|
||||
$DOCKER_REPO \\
|
||||
account
|
||||
else
|
||||
echo "container \$NAME already existed"
|
||||
echo "history logs -> docker logs \$NAME"
|
||||
echo "close this -> docker stop \$NAME"
|
||||
echo "start \$NAME"
|
||||
docker start \$NAME
|
||||
fi
|
||||
EOF
|
||||
chmod +x account.sh
|
||||
|
||||
echo "create clear.sh"
|
||||
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
|
||||
cat >clear.sh <<EOF
|
||||
#!$(which env) bash
|
||||
NAME=shanmite-lottery-clear
|
||||
if [[ -z "\$(docker ps -a | grep \$NAME)" ]]; then
|
||||
docker run \\
|
||||
-v $PWD/$ENV_FILE:/lottery/$ENV_FILE \\
|
||||
-v $PWD/$CONFIG_FILE:/lottery/$CONFIG_FILE \\
|
||||
--network host \\
|
||||
--name \$NAME \\
|
||||
$DOCKER_REPO \\
|
||||
clear
|
||||
else
|
||||
echo "container \$NAME already existed"
|
||||
echo "history logs -> docker logs \$NAME"
|
||||
echo "close this -> docker stop \$NAME"
|
||||
echo "start \$NAME"
|
||||
docker start \$NAME
|
||||
fi
|
||||
EOF
|
||||
chmod +x clear.sh
|
||||
|
||||
echo "create debug.sh"
|
||||
cat >debug.sh <<EOF
|
||||
#!$(which env) bash
|
||||
NAME=shanmite-lottery-debug
|
||||
echo "create temporary debug container"
|
||||
docker run \\
|
||||
-it \\
|
||||
--network host \\
|
||||
--name \$NAME \\
|
||||
--entrypoint /bin/bash \\
|
||||
$DOCKER_REPO -c bash
|
||||
echo "remove temporary debug container"
|
||||
docker rm -v \$NAME
|
||||
EOF
|
||||
chmod +x debug.sh
|
||||
|
||||
echo "create remove_all.sh"
|
||||
cat >remove_all.sh <<EOF
|
||||
#!$(which env) bash
|
||||
echo "remove all containers about $DOCKER_REPO"
|
||||
docker rm -v \$(docker ps -a | awk '/shanmite\/lottery_auto_docker/ {print \$1}')
|
||||
echo "remove image $DOCKER_REPO"
|
||||
docker image rm -f shanmite/lottery_auto_docker
|
||||
echo "see you next time!"
|
||||
EOF
|
||||
chmod +x remove_all.sh
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
$README = "README.md"
|
||||
$TEMPLATE_CONFIG_FILE = "my_config.example.js"
|
||||
$TEMPLATE_ENV_FILE = "env.example.js"
|
||||
|
||||
$CONFIG_FILE = "my_config.js"
|
||||
$ENV_FILE = "env.js"
|
||||
|
||||
$TARGET_DIR = ".\dist"
|
||||
|
||||
$NAME = 'lottery-auto-script'
|
||||
|
||||
$TRIARR = @(
|
||||
@("$NAME-win.exe", "lottery.exe", "nlts-win-x64"),
|
||||
@("$NAME-linux", "lottery", "nlts-linux-x64"),
|
||||
@("$NAME-macos", "lottery", "nlts-macos-x64")
|
||||
)
|
||||
|
||||
if((Test-Path $TARGET_DIR) -eq "True") {
|
||||
Remove-Item -Path $TARGET_DIR -Recurse
|
||||
}
|
||||
|
||||
npx pkg .
|
||||
|
||||
Copy-Item -Path $TEMPLATE_ENV_FILE -Destination $TARGET_DIR -Force
|
||||
Copy-Item -Path $TEMPLATE_CONFIG_FILE -Destination $TARGET_DIR -Force
|
||||
Copy-Item -Path $README -Destination $TARGET_DIR -Force
|
||||
|
||||
Set-Location -Path $TARGET_DIR
|
||||
|
||||
Move-Item -Path $TEMPLATE_ENV_FILE -Destination $ENV_FILE -Force
|
||||
Move-Item -Path $TEMPLATE_CONFIG_FILE -Destination $CONFIG_FILE -Force
|
||||
|
||||
foreach ($TRI in $TRIARR) {
|
||||
$PROTO_BIN,$BIN,$DIR = $TRI
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $DIR
|
||||
|
||||
Move-Item -Path $PROTO_BIN -Destination $BIN -Force
|
||||
|
||||
Move-Item -Path $BIN -Destination $DIR -Force
|
||||
Copy-Item -Path $ENV_FILE -Destination $DIR -Force
|
||||
Copy-Item -Path $CONFIG_FILE -Destination $DIR -Force
|
||||
Copy-Item -Path $README -Destination $DIR -Force
|
||||
|
||||
if ($DIR -eq "nlts-win-x64") {
|
||||
New-Item -Path $DIR -Name "start.bat" -ItemType File -Value "@echo off && lottery start && pause" -Force
|
||||
New-Item -Path $DIR -Name "check.bat" -ItemType File -Value "@echo off && lottery check && pause" -Force
|
||||
New-Item -Path $DIR -Name "clear.bat" -ItemType File -Value "@echo off && lottery clear && pause" -Force
|
||||
New-Item -Path $DIR -Name "update.bat" -ItemType File -Value "@echo off && lottery update && pause" -Force
|
||||
}
|
||||
|
||||
Compress-Archive -Path $DIR -DestinationPath "$($DIR)-$(Get-Date -Format "yyyyMMd")" -Force
|
||||
}
|
||||
|
||||
Remove-Item -Path $ENV_FILE
|
||||
Remove-Item -Path $CONFIG_FILE
|
||||
Remove-Item -Path $README
|
||||
@@ -0,0 +1,45 @@
|
||||
#!/bin/env bash
|
||||
set -e
|
||||
|
||||
NAME=LotteryAutoScript
|
||||
BRABCH=main
|
||||
|
||||
# 视网络情况选择链接
|
||||
GIT_REPO=https://github.com/shanmiteko/${NAME}.git
|
||||
# GIT_REPO=https://ghproxy.com/https://github.com/shanmiteko/${NAME}.git
|
||||
|
||||
if [ -d "$NAME" ]; then
|
||||
cd $NAME
|
||||
git pull
|
||||
cd ..
|
||||
else
|
||||
git clone -b $BRABCH $GIT_REPO $NAME
|
||||
fi
|
||||
|
||||
if [ -f "$NAME/my_config.js" ]; then
|
||||
echo 'my_config 已存在'
|
||||
else
|
||||
cp $NAME/my_config.example.js $NAME/my_config.js
|
||||
fi
|
||||
|
||||
if [ -f "$NAME/env.js" ]; then
|
||||
echo 'env.js 已存在'
|
||||
else
|
||||
cp $NAME/env.example.js $NAME/env.js
|
||||
fi
|
||||
|
||||
function create() {
|
||||
cat >"${NAME}_$1.sh" <<EOF
|
||||
#!/bin/env bash
|
||||
cd $NAME
|
||||
npm run $1
|
||||
EOF
|
||||
}
|
||||
|
||||
create start
|
||||
create check
|
||||
create clear
|
||||
create account
|
||||
|
||||
cd $NAME
|
||||
npm i
|
||||
@@ -0,0 +1,51 @@
|
||||
const assert = require('assert');
|
||||
const bili_client = require("../lib/net/bili");
|
||||
const util = require('./util');
|
||||
const { parseDynamicCard } = require('../lib/core/searcher');
|
||||
|
||||
(async () => {
|
||||
assert.notEqual(await bili_client.getMyinfo(), null);
|
||||
|
||||
await util.par_run([0, 3], [
|
||||
// 0
|
||||
async () => {
|
||||
assert.equal((await bili_client.getTopRcmd()).length, 10)
|
||||
},
|
||||
// 1
|
||||
async () => {
|
||||
assert.equal(await bili_client.sendChat(
|
||||
parseDynamicCard(await bili_client.getOneDynamicByDyid("692193323569381399")).rid_str,
|
||||
"test",
|
||||
11),
|
||||
7
|
||||
)
|
||||
},
|
||||
// 2
|
||||
async () => {
|
||||
assert.equal(await bili_client.sendChat(
|
||||
parseDynamicCard(await bili_client.getOneDynamicByDyid("11229466874154064")).rid_str,
|
||||
"test",
|
||||
1),
|
||||
3
|
||||
)
|
||||
},
|
||||
// 3
|
||||
async () => {
|
||||
assert.notEqual((await bili_client.searchArticlesByKeyword("专栏")).length, 0)
|
||||
},
|
||||
// 4
|
||||
async () => {
|
||||
assert.notEqual(await bili_client.sendChat("703886913053917267", "t", 17), 1)
|
||||
},
|
||||
// 5
|
||||
async () => {
|
||||
assert(!await bili_client.createDynamic("1"))
|
||||
},
|
||||
// 6
|
||||
async () => {
|
||||
assert.equal(await bili_client.autolike("761391835139538967"), 4)
|
||||
},
|
||||
])
|
||||
|
||||
console.log("api.test ... ok!");
|
||||
})()
|
||||
@@ -0,0 +1,15 @@
|
||||
const assert = require('assert');
|
||||
const bili_client = require("../lib/net/bili");
|
||||
const util = require('./util');
|
||||
|
||||
(async () => {
|
||||
await util.par_run([], [
|
||||
// 0
|
||||
async () => {
|
||||
let info = await bili_client.getOneArticleByCv(22112353);
|
||||
let short_ids = [...new Set(info.match(/(?<=b23.tv\/)[a-zA-Z0-9]{7}/g) || [])];
|
||||
assert.equal((await Promise.all(short_ids.map(bili_client.shortDynamicIdToDyid)))[0], "767357823884460033");
|
||||
},
|
||||
])
|
||||
console.log("article.test ... ok!");
|
||||
})()
|
||||
@@ -0,0 +1,68 @@
|
||||
const assert = require('assert');
|
||||
const bili_client = require("../lib/net/bili");
|
||||
const searcher = require("../lib/core/searcher");
|
||||
const util = require('./util');
|
||||
|
||||
(async () => {
|
||||
await util.par_run([0, 1, 2, 3, 4, 5, 6, 7, 8], [
|
||||
// 0
|
||||
async () => {
|
||||
let info = await bili_client.getOneDynamicByDyid("728424890210713624");
|
||||
assert(searcher.parseDynamicCard(info).is_charge_lottery);
|
||||
},
|
||||
// 1
|
||||
async () => {
|
||||
let info = await bili_client.getOneDynamicByDyid("768874900850999300");
|
||||
assert(searcher.parseDynamicCard(info).origin_is_charge_lottery);
|
||||
},
|
||||
// 2
|
||||
async () => {
|
||||
let card = searcher.parseDynamicCard(await bili_client.getOneDynamicByDyid("746824225190314008"));
|
||||
let chats = await bili_client.getChat(card.rid_str, card.chat_type)
|
||||
assert(chats.length > 0 && typeof chats[0][0] == "string")
|
||||
},
|
||||
// 3
|
||||
async () => {
|
||||
let card = searcher.parseDynamicCard(await bili_client.getOneDynamicByDyid("747169355882561625"));
|
||||
assert(card.chat_type == 11)
|
||||
card = searcher.parseDynamicCard(await bili_client.getOneDynamicByDyid("747441158580338693"));
|
||||
assert(card.chat_type == 17)
|
||||
assert(card.origin_chat_type == 11)
|
||||
},
|
||||
// 4
|
||||
async () => {
|
||||
assert.equal(await bili_client.getOneDynamicByDyid("111111111111111111"), undefined);
|
||||
assert.notEqual(await bili_client.getOneDynamicByDyid("746824225190314008"), undefined);
|
||||
assert.equal(await bili_client.getOneDynamicByDyid("761475750233636886"), undefined);
|
||||
},
|
||||
// 5
|
||||
async () => {
|
||||
let card = searcher.parseDynamicCard(await bili_client.getOneDynamicByDyid("762591475338838053"));
|
||||
let chats = await bili_client.getChat(card.rid_str, card.chat_type)
|
||||
assert.equal(chats.length, 19)
|
||||
card = searcher.parseDynamicCard(await bili_client.getOneDynamicByDyid("762502724122050647"));
|
||||
chats = await bili_client.getChat(card.rid_str, card.chat_type)
|
||||
assert.equal(chats.filter(it => it[0] === '六的月').length, 0)
|
||||
},
|
||||
// 6
|
||||
async () => {
|
||||
const dy = await bili_client.getOneDynamicByDyid("774973685666676768");
|
||||
const card = searcher.parseDynamicCard(dy)
|
||||
assert.notEqual(card.description + "", undefined + "");
|
||||
},
|
||||
// 7
|
||||
async () => {
|
||||
const dy = await bili_client.getOneDynamicByDyid("832208853440397352");
|
||||
const card = searcher.parseDynamicCard(dy)
|
||||
assert.equal(card.reserve_id, "3106984");
|
||||
},
|
||||
// 8
|
||||
async () => {
|
||||
const dy = await bili_client.getOneDynamicByDyid("832966468497834066");
|
||||
const card = searcher.parseDynamicCard(dy)
|
||||
assert.equal(card.origin_reserve_id, "3106984");
|
||||
},
|
||||
])
|
||||
|
||||
console.log("dynamic_card.test ... ok!");
|
||||
})()
|
||||
@@ -0,0 +1,12 @@
|
||||
const env = require("../lib/data/env");
|
||||
const global_var = require("../lib/data/global_var");
|
||||
const { log } = require('../lib/utils');
|
||||
const fs = require('fs');
|
||||
|
||||
log._level = 4
|
||||
env.init()
|
||||
global_var.init(process.env["COOKIE"], 1)
|
||||
|
||||
fs.readdirSync(module.path)
|
||||
.filter(file => file.endsWith(".test.js"))
|
||||
.forEach(file => require(`${module.path}/${file}`))
|
||||
@@ -0,0 +1,23 @@
|
||||
const assert = require('assert');
|
||||
const bili_client = require("../lib/net/bili");
|
||||
const util = require('./util');
|
||||
const { parseDynamicCard } = require('../lib/core/searcher');
|
||||
|
||||
(async () => {
|
||||
await util.par_run([], [
|
||||
// 0
|
||||
async () => {
|
||||
assert.notEqual(await bili_client.getMyinfo(), null);
|
||||
|
||||
const rid = parseDynamicCard(await bili_client.getOneDynamicByDyid("551416252543796684")).rid_str;
|
||||
|
||||
for (let index = 0; index < 100; index++) {
|
||||
console.log(index);
|
||||
await bili_client.sendChatWithOcr(
|
||||
rid,
|
||||
Date.now().toString(),
|
||||
17,
|
||||
)
|
||||
}
|
||||
},]);
|
||||
})()
|
||||
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* @param {Array<number>} nums
|
||||
* @param {Array<()=>any>} fns
|
||||
*/
|
||||
function par_run(nums, fns) {
|
||||
return Promise.all(
|
||||
nums.map(num => fns[num]())
|
||||
)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
par_run
|
||||
}
|
||||