mirror of
https://github.com/shanmiteko/LotteryAutoScript.git
synced 2026-07-22 21:13:47 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e0c18b0a1a | ||
|
|
ad6289006f | ||
|
|
1c369415ef | ||
|
|
2f4734c9de | ||
|
|
8e63e072dd | ||
|
|
d879c6336f | ||
|
|
a1a0474299 | ||
|
|
3af17e59ed | ||
|
|
d3cc24c43b | ||
|
|
acd2121d97 | ||
|
|
a2c461b22a | ||
|
|
abe660b717 | ||
|
|
7aa82fe412 | ||
|
|
08a6359579 | ||
|
|
33a1d1a38b | ||
|
|
d0a0dd9219 | ||
|
|
d40daa2b0a | ||
|
|
a0856faa4e | ||
|
|
7172e58d28 | ||
|
|
30bf989aa3 | ||
|
|
15c1d22469 | ||
|
|
adbfb6bb38 | ||
|
|
b74bb02c65 | ||
|
|
ebb561c312 | ||
|
|
c85c9106ff | ||
|
|
c4d37eda9f | ||
|
|
ca1ea8c93d | ||
|
|
d007d8bab9 | ||
|
|
e543c63404 | ||
|
|
bcf87a9d00 | ||
|
|
737feae41e | ||
|
|
f261e915f0 | ||
|
|
533606839f | ||
|
|
5447c9ae69 | ||
|
|
f5f63bcc91 | ||
|
|
1832f6d52b | ||
|
|
717d8cf281 | ||
|
|
a4215f1881 | ||
|
|
2f5990f277 | ||
|
|
6b1c2310ca | ||
|
|
1d4e8eaaca |
@@ -16,18 +16,18 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
uses: docker/setup-qemu-action@v4
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
uses: docker/setup-buildx-action@v4
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v2
|
||||
uses: docker/login-action@v4
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v3
|
||||
uses: docker/build-push-action@v7
|
||||
with:
|
||||
push: true
|
||||
tags: ${{ secrets.DOCKERHUB_REPO }}
|
||||
|
||||
@@ -10,7 +10,7 @@ jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Mirror + trigger CI
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
name: "Publishing to NPM"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "package.json"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: JS-DevTools/npm-publish@v1
|
||||
with:
|
||||
token: ${{ secrets.NPM_TOKEN }}
|
||||
+15
-17
@@ -26,31 +26,29 @@ jobs:
|
||||
nodev: 18
|
||||
- platform: win
|
||||
nodev: 18
|
||||
# - platform: win
|
||||
# nodev: 12
|
||||
steps:
|
||||
- name: "Checkout codes"
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
- name: "Use Node.js"
|
||||
uses: actions/setup-node@v4
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: "*"
|
||||
- name: "Pkg this"
|
||||
run: |
|
||||
npm run pkg "node${{ matrix.nodev }}-${{ matrix.platform }}-x64"
|
||||
- name: "Upload to artifact"
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
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 }}
|
||||
uses: softprops/action-gh-release@v3
|
||||
with:
|
||||
file: "dist/*.zip"
|
||||
files: "dist/*.zip"
|
||||
tag_name: "v2"
|
||||
overwrite: true
|
||||
draft: true
|
||||
overwrite_files: true
|
||||
token: ${{ secrets.GH_TOKEN }}
|
||||
arm64:
|
||||
runs-on: ubuntu-latest
|
||||
name: node18-${{ matrix.platform }}-arm64
|
||||
@@ -62,20 +60,20 @@ jobs:
|
||||
- platform: alpine
|
||||
steps:
|
||||
- name: "Checkout codes"
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
- name: "Pkg this"
|
||||
run: |
|
||||
npm run pkg "node18-${{ matrix.platform }}-arm64"
|
||||
- name: "Upload to artifact"
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: node18-${{ matrix.platform }}-arm64
|
||||
path: "dist/*.zip"
|
||||
- name: "Upload to release draft"
|
||||
uses: xresloader/upload-to-github-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
uses: softprops/action-gh-release@v3
|
||||
with:
|
||||
file: "dist/*.zip"
|
||||
files: "dist/*.zip"
|
||||
tag_name: "v2"
|
||||
overwrite: true
|
||||
draft: true
|
||||
overwrite_files: true
|
||||
token: ${{ secrets.GH_TOKEN }}
|
||||
|
||||
@@ -1,5 +1,78 @@
|
||||
<!-- markdownlint-disable MD036 MD024-->
|
||||
# CHANGELOG
|
||||
## 主要变化(2.11.0)
|
||||
* 1c36941 fix: origin is null
|
||||
* 2f4734c chore: 不再推送至npm
|
||||
* 8e63e07 fix: @信息未获取导致转发错误标蓝
|
||||
* d879c63 fix: 转发类型动态获取不到rid无法评论 (#466)
|
||||
* a1a0474 fix: 监控uid模式获取不到动态内容
|
||||
* 3af17e5 feat: 可在设置接入AI判断动态是否是抽奖动态
|
||||
* d3cc24c feat: debug日志输出网络请求
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.10.3)
|
||||
* a2c461b fix: clear异常循环 (#484)
|
||||
* abe660b fix: prevent is_repost_then_chat from overriding AI-generated comments (#485)
|
||||
* 7aa82fe feat: Integrate Feishu for notification (#482)
|
||||
* 08a6359 fix: `is_charge_lottery`默认false
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.10.2)
|
||||
* d0a0dd9 feat: 新增QMSG_SOCKET推送参数支持私有云 (#473)
|
||||
* d40daa2 docs: 注解默认设置
|
||||
* a0856fa fix: 风控导致动态内容为空 (#465)
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.10.1)
|
||||
* 30bf989 feat: ai评论支持所有兼容OpenAI API的平台 (#463)
|
||||
* 15c1d22 fix: 官方非官方抽奖类型判断 (#461)
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.10.0)
|
||||
* b74bb02 feat: ai 评论 (#462)
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.9.8)
|
||||
* c85c910 doc: 图片链接换源
|
||||
* c4d37ed fix: Dockerfile.pkg-arm64换源
|
||||
* ca1ea8c fix: 青龙换源gitlab
|
||||
* d007d8b feat: 更新换源及优化
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.9.7)
|
||||
* bcf87a9 feat: 新增日志等级Notice (#454)
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.9.6)
|
||||
* f261e91 fix: API.X_POLYMER_WEB_DYNAMIC_V1_DETAIL 缺少参数 (#452)
|
||||
* 5336068 fix: 修复通过uid监视转发抽奖动态 (#449)
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.9.5)
|
||||
* f5f63bc fix: 官方抽奖判断未获取到内容 (#445)
|
||||
* 1832f6d feat: 增加多账号的代理 (#433)
|
||||
* 717d8cf fix: 换源gitlab
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.9.4)
|
||||
* 2f5990f fix: 动态ID字符串长度超过18
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.9.3)
|
||||
* 1d4e8ea fix: 专栏获取为空 (#425)
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.9.2)
|
||||
* 4134190 fix: 分区移动失败继续运行 (#423)
|
||||
* 66fa06f fix: 源动态禁止转发
|
||||
|
||||
@@ -5,7 +5,7 @@ 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 \
|
||||
ENV DOWNLOAD_HOST=https://github.com \
|
||||
RELEASE_TAG=v3.4 \
|
||||
NODEV=18.5.0 \
|
||||
PKG_CACHE_PATH=/root/.pkg-cache \
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
|
||||
[](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,7 +31,7 @@
|
||||
- 监控用户转发
|
||||
- 监控话题页面
|
||||
- 监控专栏合集
|
||||
- 自动点赞、评论、乱序转发、@好友、带话题、可选随机动态
|
||||
- 自动点赞、AI评论、乱序转发、@好友、带话题、可选随机动态
|
||||
- 直播预约抽奖
|
||||
- 检测是否中奖
|
||||
- 已读@
|
||||
@@ -103,7 +101,7 @@ Chrome浏览器:
|
||||
|
||||
(此步骤是为了方便后续采用JS获取Cookies,获取完毕后应再次勾选)
|
||||
|
||||

|
||||

|
||||
|
||||
3. 在Console中复制以下代码回车
|
||||
|
||||
@@ -166,7 +164,7 @@ buvid3亦可不填 使用随机生成值
|
||||
```
|
||||
|
||||
1. 运行截图
|
||||

|
||||

|
||||
|
||||
#### 以源码方式运行
|
||||
|
||||
@@ -198,42 +196,47 @@ buvid3亦可不填 使用随机生成值
|
||||
|
||||
关键词有限 可能会有**漏掉**的或**误报**
|
||||
|
||||
可在设置开启AI判断
|
||||
|
||||
### 中奖推送
|
||||
|
||||
> 填写在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://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` | 电子邮件 | 接收方电子邮件 |
|
||||
| `GOTIFY_URL` | gotify推送 | gotify消息推送地址(例如 http://localhost:8008/message),[官方文档](https://gotify.net/docs/) |
|
||||
| `GOTIFY_APPKEY` | gotify推送 | 一个gotify application的token,[官方文档](https://gotify.net/docs/) |
|
||||
| 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`,再不懂看 [这个图](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`等字符 , 注:钉钉机器人安全设置只需勾选`加签`即可,其他选项不要勾选,再不懂看 [这个图](doc/pic/DD_bot.png) |
|
||||
| `FS_BOT_WEBHOOK` | 飞书机器人 | 飞书机器人 webhook,创建自定义机器人后复制 webhook 地址,[官方文档](https://open.feishu.cn/document/client-docs/bot-v3/add-custom-bot) |
|
||||
| `FS_BOT_SECRET` | 飞书机器人 | 飞书机器人安全设置中的签名密钥(若开启“签名校验”则必填),[官方文档](https://open.feishu.cn/document/client-docs/bot-v3/add-custom-bot) |
|
||||
| `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_SOCKET` | [Qmsg酱](https://qmsg.zendee.cn)私聊推送 | 私有云IP:私有云WEB端口 默认`qmsg.zendee.cn` |
|
||||
| `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` | 电子邮件 | 接收方电子邮件 |
|
||||
| `GOTIFY_URL` | gotify推送 | gotify消息推送地址(例如 http://localhost:8008/message),[官方文档](https://gotify.net/docs/) |
|
||||
| `GOTIFY_APPKEY` | gotify推送 | 一个gotify application的token,[官方文档](https://gotify.net/docs/) |
|
||||
|
||||
----------------------------------------
|
||||
|
||||
|
||||
+3
-3
@@ -4,16 +4,16 @@
|
||||
|
||||
Ⅰ.首先在Telegram上搜索[BotFather](https://t.me/BotFather)机器人<br>
|
||||
|
||||

|
||||

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

|
||||

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

|
||||

|
||||
|
||||
|
||||
7.如果本地的脚本需要更新
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
1.初始化
|
||||
|
||||
```bash
|
||||
curl -fsSL https://ghproxy.com/https://raw.githubusercontent.com/shanmiteko/LotteryAutoScript/main/script/docker/init.sh | sudo bash
|
||||
curl -fsSL https://gitlab.com/shanmiteko/LotteryAutoScript/-/raw/main/script/docker/init.sh | sudo bash
|
||||
```
|
||||
|
||||
进入`lottery`文件夹
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@ step1: 下载代码到本地
|
||||
|
||||
[点此下载](https://github.com/shanmiteko/LotteryAutoScript/archive/refs/heads/main.zip)或如图示下载↓
|
||||
|
||||

|
||||

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

|
||||

|
||||
|
||||
step3:修改env.example.js文件及创建运行文件(打开扩展名显示)
|
||||
|
||||
|
||||
+3
-3
@@ -16,13 +16,13 @@
|
||||
|
||||
7.在`操作`页面中点击`新建`,选择操作为`启动程序`,在设置里点击浏览找到`start.bat`文件并选择,在`起始于(可选)(T):`中的空白框里输入`start.bat`文件的目录地址,也就是`程序或脚本(P):`里`start.bat`的前面那一串目录地址,最后是以`\`结尾的 ,填好东西后按下面`确认`
|
||||
|
||||

|
||||

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

|
||||

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

|
||||

|
||||
|
||||
具体看任务是否正常执行,你可以看看自己的账号动态的最新转发,运行成功每几分钟自动转发抽奖动态
|
||||
|
||||
+30
-6
@@ -6,16 +6,20 @@ module.exports = Object.freeze({
|
||||
* - `NUMBER` 表示是第几个账号
|
||||
* - `CLEAR` 是否启用清理功能
|
||||
* - `ACCOUNT_UA` 账号UA, 可在浏览器控制台输入 navigator.userAgent 查看
|
||||
*
|
||||
* ## 高级功能
|
||||
* - `ENABLE_CHAT_CAPTCHA_OCR` 开启评论验证码识别 使用方法见README
|
||||
* - `CHAT_CAPTCHA_OCR_URL` 验证码识别接口 POST `url`->`code`
|
||||
* - `ENABLE_MULTIPLE_ACCOUNT` 是否启用多账号
|
||||
* - `MULTIPLE_ACCOUNT_PARM` 多账号参数(JSON格式) <不推荐使用
|
||||
* - `ENABLE_AI_JUDGE` 是否启用AI判断抽奖
|
||||
* - `ENABLE_AI_COMMENTS` 是否启用AI评论
|
||||
*
|
||||
* ## 调试相关
|
||||
* - `LOTTERY_LOG_LEVEL` 输出日志等级 Error<Warn<Info<Debug 1<2<3<4
|
||||
* - `LOTTERY_LOG_LEVEL` 输出日志等级 Error<Warn<Notice<Info<Debug 0<1<2<3<4
|
||||
* - `NOT_GO_LOTTERY` 关闭抽奖行为
|
||||
*
|
||||
* ## 多账号
|
||||
* - `ENABLE_MULTIPLE_ACCOUNT` 是否启用多账号
|
||||
* - `MULTIPLE_ACCOUNT_PARM` 多账号参数(JSON格式) <不推荐使用
|
||||
* 1. 将 ENABLE_MULTIPLE_ACCOUNT 的值改为true
|
||||
* 2. 将账号信息依次填写于 multiple_account_parm 中, 参考例子类推
|
||||
* - `WAIT` 表示下一个账号运行等待时间(毫秒)
|
||||
@@ -31,9 +35,12 @@ module.exports = Object.freeze({
|
||||
|
||||
ENABLE_CHAT_CAPTCHA_OCR: false,
|
||||
CHAT_CAPTCHA_OCR_URL: 'http://127.0.0.1:9898/ocr/url/text',
|
||||
ENABLE_MULTIPLE_ACCOUNT: false,
|
||||
ENABLE_AI_JUDGE: false,
|
||||
ENABLE_AI_COMMENTS: false,
|
||||
|
||||
ENABLE_MULTIPLE_ACCOUNT: false,
|
||||
MULTIPLE_ACCOUNT_PARM: '',
|
||||
|
||||
LOTTERY_LOG_LEVEL: 3,
|
||||
NOT_GO_LOTTERY: ''
|
||||
},
|
||||
@@ -64,7 +71,11 @@ module.exports = Object.freeze({
|
||||
NUMBER: 1,
|
||||
CLEAR: true,
|
||||
WAIT: 60 * 1000,
|
||||
ACCOUNT_UA: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36'
|
||||
ACCOUNT_UA: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36',
|
||||
PROXY_HOST: '',//代理ip
|
||||
PROXY_PORT: '',//代理ip端口
|
||||
PROXY_USER: '',//代理ip账号
|
||||
PROXY_PASS: '',//代理ip密码
|
||||
}
|
||||
],
|
||||
|
||||
@@ -91,6 +102,7 @@ module.exports = Object.freeze({
|
||||
IGOT_PUSH_KEY: '',
|
||||
PUSH_PLUS_TOKEN: '',
|
||||
PUSH_PLUS_USER: '',
|
||||
QMSG_SOCKET: '',
|
||||
QMSG_KEY: '',
|
||||
QMSG_QQ: '',
|
||||
SMTP_HOST: '',
|
||||
@@ -99,6 +111,18 @@ module.exports = Object.freeze({
|
||||
SMTP_PASS: '',
|
||||
SMTP_TO_USER: '',
|
||||
GOTIFY_URL: '',
|
||||
GOTIFY_APPKEY: ''
|
||||
GOTIFY_APPKEY: '',
|
||||
FS_BOT_WEBHOOK: '',
|
||||
FS_BOT_SECRET: ''
|
||||
},
|
||||
|
||||
/**
|
||||
* AI Authentication(OpenAI 兼容的 API 格式)
|
||||
* Chat completions
|
||||
* 此处填写Key, 在my_config中的ai_comments_parm中填写API地址等信息
|
||||
*/
|
||||
ai_parm: {
|
||||
//apikey
|
||||
AI_API_KEY: '',
|
||||
}
|
||||
});
|
||||
|
||||
+2
-2
@@ -92,10 +92,10 @@ async function isMe(num) {
|
||||
log.info('中奖检测', '--> OK');
|
||||
}
|
||||
if (desp) {
|
||||
log.info('可能中奖了', desp);
|
||||
log.notice('可能中奖了', desp);
|
||||
await sendNotify(`帐号${num}可能中奖了`, desp);
|
||||
} else {
|
||||
log.info('中奖检测', '暂未中奖');
|
||||
log.notice('中奖检测', '暂未中奖');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
+1
-1
@@ -128,7 +128,7 @@ async function clear() {
|
||||
/* 延时 */
|
||||
await delay(clear_remove_delay);
|
||||
log.info('清理动态', `第${page + 1}页(${allModifyDynamicResArray.length})中的转发动态与关注全部处理成功`);
|
||||
if (next_offset === '0' || !success) break;
|
||||
if (!next_offset || next_offset === '' || next_offset === '0'|| !success) break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
+56
-11
@@ -1,4 +1,4 @@
|
||||
const { log, hasEnv, shuffle, getRandomOne, delay, try_for_each, retryfn, appendLotteryInfoFile } = require('../utils');
|
||||
const { log, hasEnv, shuffle, getRandomOne, getAiContent, delay, try_for_each, retryfn, appendLotteryInfoFile } = require('../utils');
|
||||
const { send } = require('../net/http');
|
||||
const bili = require('../net/bili');
|
||||
const { sendNotify } = require('../helper/notify');
|
||||
@@ -255,6 +255,7 @@ class Monitor extends Searcher {
|
||||
* @property {string} [rid] 评论标识
|
||||
* @property {number} chat_type 评论类型
|
||||
* @property {string} [chat] 评论词
|
||||
* @property {boolean} [isAiChat] 是否为AI生成的评论
|
||||
*/
|
||||
/**
|
||||
* @returns {Promise<LotteryOptions[]>}
|
||||
@@ -281,7 +282,7 @@ class Monitor extends Searcher {
|
||||
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,
|
||||
only_followed, at_users, blockword, blacklist, ai_comments_parm
|
||||
} = config,
|
||||
now_ts = Date.now() / 1000;
|
||||
|
||||
@@ -354,6 +355,11 @@ class Monitor extends Searcher {
|
||||
|
||||
log.debug('正在筛选的动态信息', lottery_info);
|
||||
|
||||
if (des === '') {
|
||||
log.info('筛选动态', `获取动态内容为空(https://t.bilibili.com/${dyid})风控`);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (lottery_info_type.startsWith('sneak') && sneaktower) {
|
||||
log.info('筛选动态', `偷塔模式不检查是否已转发(https://t.bilibili.com/${dyid})`);
|
||||
} else {
|
||||
@@ -378,7 +384,7 @@ class Monitor extends Searcher {
|
||||
return false;
|
||||
}
|
||||
|
||||
const
|
||||
let
|
||||
[m_uid, ori_uid] = uids,
|
||||
mIsFollowed = !m_uid || (new RegExp(m_uid)).test(attentionList),
|
||||
oriIsFollowed = !ori_uid || (new RegExp(ori_uid)).test(attentionList),
|
||||
@@ -429,7 +435,7 @@ class Monitor extends Searcher {
|
||||
|
||||
if (reserve_id) {
|
||||
if (disable_reserve_lottery) {
|
||||
log.info('已关闭预约抽奖功能');
|
||||
log.info('预约抽奖', '已关闭预约抽奖功能');
|
||||
} else {
|
||||
log.info('预约抽奖', '开始');
|
||||
log.info('预约抽奖', `奖品: ${reserve_lottery_text}`);
|
||||
@@ -446,8 +452,28 @@ class Monitor extends Searcher {
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasOfficialLottery && model[1] === '1' && !has_key_words && description) {
|
||||
log.warn('筛选动态', `无关键词动态的描述: ${description}\n\n考虑是否修改设置key_words:\n${key_words.join('\n且满足: ')}`);
|
||||
if (!hasOfficialLottery && model[1] === '1') {
|
||||
if (hasEnv('ENABLE_AI_JUDGE')) {
|
||||
let msg = await getAiContent(
|
||||
config.ai_judge_parm.url,
|
||||
config.ai_judge_parm.body,
|
||||
config.ai_judge_parm.prompt,
|
||||
lottery_info.des
|
||||
);
|
||||
try {
|
||||
let msg_json = JSON.parse(msg);
|
||||
has_key_words = msg_json.has_key_words;
|
||||
needTopic = msg_json.needTopic;
|
||||
needAt = msg_json.needAt;
|
||||
isLottery = has_key_words;
|
||||
log.info('ai判断抽奖', msg_json.more);
|
||||
} catch (_) {
|
||||
log.error('ai判断抽奖', '未返回JSON格式');
|
||||
}
|
||||
}
|
||||
if (!has_key_words && description) {
|
||||
log.warn('筛选动态', `无关键词动态的描述: ${description}\n\n考虑是否修改设置key_words或ai提示词`);
|
||||
}
|
||||
}
|
||||
|
||||
/**若勾选只转已关注 */
|
||||
@@ -527,8 +553,23 @@ class Monitor extends Searcher {
|
||||
/* 是否评论 */
|
||||
if (isSendChat) {
|
||||
onelotteryinfo.rid = rid;
|
||||
onelotteryinfo.chat = (getRandomOne(chats) || '!!!')
|
||||
.replace(/\$\{uname\}/g, uname);
|
||||
if (hasEnv('ENABLE_AI_COMMENTS')) {
|
||||
try {
|
||||
log.info('开始获取Ai评论', `(https://t.bilibili.com/${dyid})`);
|
||||
onelotteryinfo.chat = await getAiContent(
|
||||
ai_comments_parm.url,
|
||||
ai_comments_parm.body,
|
||||
ai_comments_parm.prompt,
|
||||
lottery_info.des) || '!!!';
|
||||
log.info('获取到Ai评论内容', `${onelotteryinfo.chat}`);
|
||||
onelotteryinfo.isAiChat = true;
|
||||
} catch (e) {
|
||||
log.error('获取AI评论失败,使用随机评论', e);
|
||||
onelotteryinfo.chat = (getRandomOne(chats) || '!!!').replace(/\$\{uname\}/g, uname);
|
||||
}
|
||||
} else {
|
||||
onelotteryinfo.chat = (getRandomOne(chats) || '!!!').replace(/\$\{uname\}/g, uname);
|
||||
}
|
||||
}
|
||||
|
||||
alllotteryinfo.push(onelotteryinfo);
|
||||
@@ -581,7 +622,7 @@ class Monitor extends Searcher {
|
||||
|
||||
let
|
||||
status = 0,
|
||||
{ uid, dyid, chat_type, rid, relay_chat, ctrl, chat } = option,
|
||||
{ uid, dyid, chat_type, rid, relay_chat, ctrl, chat, isAiChat } = option,
|
||||
{ check_if_duplicated, is_copy_chat, copy_blockword, is_repost_then_chat, is_not_create_partition } = config;
|
||||
|
||||
/* 评论 */
|
||||
@@ -597,7 +638,11 @@ class Monitor extends Searcher {
|
||||
global_var.get('myUNAME') || '');
|
||||
} else {
|
||||
if (is_repost_then_chat) {
|
||||
chat = chat + relay_chat;
|
||||
if (isAiChat) {
|
||||
relay_chat = chat;
|
||||
} else {
|
||||
chat = chat + relay_chat;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -692,4 +737,4 @@ class Monitor extends Searcher {
|
||||
}
|
||||
|
||||
|
||||
module.exports = { Monitor };
|
||||
module.exports = { Monitor };
|
||||
|
||||
+140
-303
@@ -24,18 +24,18 @@ const { log } = utils;
|
||||
* @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} 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
|
||||
* @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} 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
|
||||
@@ -59,9 +59,11 @@ const { log } = utils;
|
||||
* @return {UsefulDynamicInfo}
|
||||
*/
|
||||
function parseDynamicCard(data) {
|
||||
if (data?.card?.desc?.uid) {
|
||||
return oldParseDynamicCard(data?.card);
|
||||
// 如果是多个 items,返回一个数组
|
||||
if (Array.isArray(data?.items)) {
|
||||
return data.items.map(item => parseDynamicCard({ item }));
|
||||
}
|
||||
|
||||
let ditem = data?.item;
|
||||
/**临时储存单个动态中的信息 */
|
||||
let obj = {};
|
||||
@@ -90,10 +92,10 @@ function parseDynamicCard(data) {
|
||||
obj.create_time = ditem?.modules?.module_author?.pub_ts || 0;
|
||||
/* 动态类型 */
|
||||
obj.type = dy_typeenum2num.get(ditem?.type) || 0;
|
||||
/* 用于发送评论 */
|
||||
/* 用于发送评论 无法获取到源动态的rid_str*/
|
||||
obj.rid_str = ditem?.basic?.comment_id_str || '';
|
||||
/* 用于发送评论 */
|
||||
obj.chat_type = ditem?.basic?.comment_type || 0;
|
||||
obj.chat_type = dy_type2chat_type.get(ditem?.type) || 0;
|
||||
/* 转发者的动态ID !!!!此为大数需使用字符串值,不然JSON.parse()会有丢失精度 */
|
||||
obj.dynamic_id = ditem?.id_str || '';
|
||||
/* 定位@信息 */
|
||||
@@ -103,210 +105,54 @@ function parseDynamicCard(data) {
|
||||
/* 转发描述 */
|
||||
obj.description = '';
|
||||
let _total_len = 0;
|
||||
ditem?.modules?.module_dynamic?.desc?.rich_text_nodes.forEach(node => {
|
||||
if (node.type === 'RICH_TEXT_NODE_TYPE_AT') {
|
||||
obj.ctrl.push({
|
||||
data: node.rid,
|
||||
location: _total_len,
|
||||
length: node.text.length,
|
||||
type: 1
|
||||
});
|
||||
}
|
||||
/* 是否有官方抽奖 */
|
||||
if (node.type === 'RICH_TEXT_NODE_TYPE_LOTTERY') {
|
||||
obj.hasOfficialLottery = true;
|
||||
}
|
||||
obj.description += node.orig_text;
|
||||
_total_len += node.text.length;
|
||||
});
|
||||
if (Array.isArray(ditem?.modules?.module_dynamic?.desc?.rich_text_nodes)) {
|
||||
ditem?.modules?.module_dynamic?.desc?.rich_text_nodes.forEach(node => {
|
||||
if (node.type === 'RICH_TEXT_NODE_TYPE_AT') {
|
||||
obj.ctrl.push({
|
||||
data: node.rid,
|
||||
location: _total_len,
|
||||
length: node.text.length,
|
||||
type: 1
|
||||
});
|
||||
}
|
||||
/* 是否有官方抽奖 */
|
||||
if (node.type === 'RICH_TEXT_NODE_TYPE_LOTTERY') {
|
||||
obj.hasOfficialLottery = true;
|
||||
}
|
||||
obj.description += node.orig_text;
|
||||
_total_len += node.text.length;
|
||||
});
|
||||
} else {
|
||||
ditem?.modules?.module_dynamic?.major?.opus?.summary?.rich_text_nodes.forEach(node => {
|
||||
if (node.type === 'RICH_TEXT_NODE_TYPE_AT') {
|
||||
obj.ctrl.push({
|
||||
data: node.rid,
|
||||
location: _total_len,
|
||||
length: node.text.length,
|
||||
type: 1
|
||||
});
|
||||
}
|
||||
/* 是否有官方抽奖 */
|
||||
if (node.type === 'RICH_TEXT_NODE_TYPE_LOTTERY') {
|
||||
obj.hasOfficialLottery = true;
|
||||
}
|
||||
obj.description += node.orig_text;
|
||||
_total_len += node.text.length;
|
||||
});
|
||||
}
|
||||
/* 预约抽奖信息 */
|
||||
obj.reserve_id = ditem?.modules?.module_dynamic?.additional?.reserve?.rid || 0;
|
||||
obj.reserve_lottery_text = ditem?.modules?.module_dynamic?.additional?.reserve?.title || '信息丢失';
|
||||
obj.reserve_lottery_text = ditem?.modules?.module_dynamic?.additional?.reserve?.title || '未获取到';
|
||||
/* 充电抽奖 */
|
||||
obj.is_charge_lottery = false;
|
||||
if (ditem?.modules?.module_dynamic?.additional?.type === 'ADDITIONAL_TYPE_UPOWER_LOTTERY') {
|
||||
obj.is_charge_lottery = true;
|
||||
}
|
||||
/* 转发 */
|
||||
if (obj.type === 1) {
|
||||
/* 被转发者的UID */
|
||||
obj.origin_uid = ditem?.orig?.modules?.module_author?.mid || 0;
|
||||
/* 被转发者的name */
|
||||
obj.origin_uname = ditem?.orig?.modules?.module_author?.name || '';
|
||||
/* 源动态的ts10 */
|
||||
obj.origin_create_time = ditem?.orig?.modules?.module_author?.pub_ts || 0;
|
||||
/* 源动态类型 */
|
||||
obj.origin_type = dy_typeenum2num.get(ditem?.orig?.type) || 0;
|
||||
/* 被转发者的rid(用于发评论) */
|
||||
switch (ditem?.orig?.type) {
|
||||
case 'DYNAMIC_TYPE_DRAW':
|
||||
obj.origin_rid_str = ditem?.orig?.modules?.module_dynamic?.major?.draw?.id?.toString() || '';
|
||||
break;
|
||||
case 'DYNAMIC_TYPE_AV':
|
||||
obj.origin_rid_str = ditem?.orig?.modules?.module_dynamic?.major?.archive?.aid || '';
|
||||
break;
|
||||
case 'DYNAMIC_TYPE_ARTICLE':
|
||||
obj.origin_rid_str = ditem?.orig?.modules?.module_dynamic?.major?.article?.id?.toString() || '';
|
||||
break;
|
||||
default:
|
||||
obj.origin_rid_str = ditem?.orig?.id_str || '';
|
||||
break;
|
||||
}
|
||||
/* 用于发送评论 */
|
||||
obj.origin_chat_type = dy_type2chat_type.get(ditem?.orig?.type) || 0;
|
||||
/* 被转发者的动态的ID !!!!此为大数需使用字符串值,不然JSON.parse()会有丢失精度 */
|
||||
obj.origin_dynamic_id = ditem?.orig?.id_str || '';
|
||||
/* 预约抽奖信息 */
|
||||
obj.origin_reserve_id = ditem?.orig?.modules?.module_dynamic?.additional?.reserve?.rid || 0;
|
||||
obj.origin_reserve_lottery_text = ditem?.orig?.modules?.module_dynamic?.additional?.reserve?.title || '信息丢失';
|
||||
/* 充电抽奖 */
|
||||
if (ditem?.orig?.modules?.module_dynamic?.additional?.type === 'ADDITIONAL_TYPE_UPOWER_LOTTERY') {
|
||||
obj.origin_is_charge_lottery = true;
|
||||
}
|
||||
/* 是否有官方抽奖 */
|
||||
obj.origin_hasOfficialLottery = false;
|
||||
/* 转发描述 */
|
||||
obj.origin_description = '';
|
||||
ditem?.orig?.modules?.module_dynamic?.desc?.rich_text_nodes.forEach(node => {
|
||||
/* 是否有官方抽奖 */
|
||||
if (node.type === 'RICH_TEXT_NODE_TYPE_LOTTERY') {
|
||||
obj.origin_hasOfficialLottery = true;
|
||||
}
|
||||
obj.origin_description += node.orig_text;
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
log.error('动态卡片解析', e);
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {object} dynamic_detail_card
|
||||
* @return {UsefulDynamicInfo}
|
||||
*/
|
||||
function oldParseDynamicCard(dynamic_detail_card) {
|
||||
const { strToJson } = utils;
|
||||
/**临时储存单个动态中的信息 */
|
||||
let obj = {};
|
||||
try {
|
||||
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 = desc.uid;
|
||||
/* 转发者的name */
|
||||
obj.uname = info.uname || '';
|
||||
/* 动态是否点过赞 */
|
||||
obj.is_liked = is_liked > 0;
|
||||
/* 动态的ts10 */
|
||||
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.chat_type = dy_type2chat_type.get(obj.type) || 0;
|
||||
/* 转发者的动态ID !!!!此为大数需使用字符串值,不然JSON.parse()会有丢失精度 */
|
||||
obj.dynamic_id = desc.dynamic_id_str;
|
||||
/* 定位@信息 */
|
||||
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 || '')
|
||||
+ (cardToJson.vest && cardToJson.vest.content || '')
|
||||
)
|
||||
|| '';
|
||||
/* 转发 */
|
||||
if (obj.type === 1) {
|
||||
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 = parseDynamicCard({item: ditem.orig});
|
||||
} else {
|
||||
obj.origin = {};
|
||||
}
|
||||
} catch (e) {
|
||||
log.error('动态卡片解析', e);
|
||||
@@ -323,16 +169,18 @@ function oldParseDynamicCard(dynamic_detail_card) {
|
||||
function modifyDynamicRes(res) {
|
||||
let
|
||||
{ data, code } = utils.strToJson(res),
|
||||
{ cards, has_more, offset } = data || {};
|
||||
{ items, has_more, offset } = data || {};
|
||||
|
||||
if (code !== 0) {
|
||||
log.error('处理动态数据', '获取动态数据出错,可能是访问太频繁 \n' + res);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (cards == null || !cards || !cards.length) {
|
||||
/**
|
||||
* !cards已经能涵盖cards == null,你在想什么?
|
||||
*/
|
||||
if (!items || !items.length) {
|
||||
log.warn('处理动态数据', '未找到任何动态信息');
|
||||
cards = [];
|
||||
items = [];
|
||||
}
|
||||
|
||||
if (typeof has_more === 'undefined'
|
||||
@@ -347,18 +195,16 @@ function modifyDynamicRes(res) {
|
||||
*/
|
||||
next = {
|
||||
has_more,
|
||||
next_offset: typeof offset === 'string'
|
||||
? offset
|
||||
: /(?<=next_offset":)[0-9]+/.exec(res)[0]
|
||||
next_offset: offset
|
||||
},
|
||||
/**
|
||||
* 储存获取到的一组动态中的信息
|
||||
*/
|
||||
array = next.has_more === 0
|
||||
? []
|
||||
: cards.map(oldParseDynamicCard);
|
||||
: items.map(item => parseDynamicCard({ item }));
|
||||
|
||||
log.info('处理动态数据', `动态数据读取完毕(${cards.length})(${next.has_more})`);
|
||||
log.info('处理动态数据', `动态数据读取完毕(${items.length})(${next.has_more})`);
|
||||
|
||||
return {
|
||||
modifyDynamicResArray: array,
|
||||
@@ -379,7 +225,7 @@ class Searcher {
|
||||
* @param {string} [offset] 默认'0'
|
||||
* @returns {Promise<{allModifyDynamicResArray: UsefulDynamicInfo[], offset: string} | null>} 获取前 `pages*12` 个动态信息
|
||||
*/
|
||||
static async checkAllDynamic(hostuid, pages, time = 0, offset = '0') {
|
||||
static async checkAllDynamic(host_mid, pages, time = 0, offset = '0') {
|
||||
log.info('检查所有动态', `准备读取${pages}页动态`);
|
||||
|
||||
const { getOneDynamicInfoByUID } = bili,
|
||||
@@ -390,7 +236,7 @@ class Searcher {
|
||||
/**
|
||||
* 储存了特定UID的请求函数
|
||||
*/
|
||||
hadUidGetOneDynamicInfoByUID = curriedGetOneDynamicInfoByUID(hostuid);
|
||||
hadUidGetOneDynamicInfoByUID = curriedGetOneDynamicInfoByUID(host_mid);
|
||||
|
||||
/**
|
||||
* 储存所有经过整理后信息
|
||||
@@ -401,9 +247,12 @@ class Searcher {
|
||||
for (let i = 0; i < pages; i++) {
|
||||
log.info('检查所有动态', `正在读取其中第${i + 1}页动态`);
|
||||
|
||||
const
|
||||
OneDynamicInfo = await hadUidGetOneDynamicInfoByUID(offset),
|
||||
mDRdata = modifyDynamicRes(OneDynamicInfo);
|
||||
// 当 offset 为 '0'(初始页)时,传入 offset 会报错
|
||||
const OneDynamicInfo = offset === '0'
|
||||
? await hadUidGetOneDynamicInfoByUID()
|
||||
: await hadUidGetOneDynamicInfoByUID(offset);
|
||||
|
||||
const mDRdata = modifyDynamicRes(OneDynamicInfo);
|
||||
|
||||
if (mDRdata === null) {
|
||||
return null;
|
||||
@@ -461,36 +310,31 @@ class Searcher {
|
||||
}
|
||||
})
|
||||
.reduce(async (pre, cur) => {
|
||||
let
|
||||
results = await pre,
|
||||
{ origin_dynamic_id } = cur,
|
||||
is_liked = false;
|
||||
let results = await pre;
|
||||
|
||||
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);
|
||||
const card = await bili.getOneDynamicByDyid(cur.origin.dynamic_id);
|
||||
log.info('获取动态', `查看源动态(${cur.origin.dynamic_id})详细信息获取rid用于评论 (${length--})`);
|
||||
if (card) {
|
||||
cur.origin = 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
|
||||
create_time: cur.origin.create_time,
|
||||
is_liked: cur.origin.is_liked,
|
||||
uids: [cur.uid, cur.origin.uid],
|
||||
uname: cur.origin.uname,
|
||||
ctrl: cur.origin.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;
|
||||
@@ -543,7 +387,7 @@ class Searcher {
|
||||
lottery_info_type: 'tag',
|
||||
create_time: o.create_time,
|
||||
is_liked: o.is_liked,
|
||||
uids: [o.uid, o.origin_uid],
|
||||
uids: [o.uid, o.origin.uid],
|
||||
uname: o.uname,
|
||||
ctrl: o.ctrl,
|
||||
dyid: o.dynamic_id,
|
||||
@@ -582,7 +426,7 @@ class Searcher {
|
||||
}
|
||||
const
|
||||
content = (await bili.getOneArticleByCv(id) || '').split('推荐文章')[0],
|
||||
dyids = content.match(/[0-9]{18}/g) || [],
|
||||
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)),
|
||||
@@ -599,38 +443,34 @@ class Searcher {
|
||||
|
||||
/**遍历某专栏中的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);
|
||||
|
||||
log.info('获取动态', `查看专栏中所提及动态(${dyid}) (${length--})`);
|
||||
const card = await bili.getOneDynamicByDyid(dyid);
|
||||
if (card) {
|
||||
await utils.delay(get_dynamic_detail_wait);
|
||||
|
||||
if (card) {
|
||||
await utils.delay(get_dynamic_detail_wait);
|
||||
const parsed_card = parseDynamicCard(card)
|
||||
, { is_liked } = parsed_card;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
_dyinfos.push(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;
|
||||
}
|
||||
|
||||
_dyinfos.push(parsed_card);
|
||||
} else {
|
||||
log.warn('获取动态', `动态(${dyid})无效 (${length--})`);
|
||||
log.warn('获取动态', `动态细节获取失败(${dyid})`);
|
||||
}
|
||||
}
|
||||
dyinfos.push(..._dyinfos);
|
||||
@@ -640,7 +480,7 @@ class Searcher {
|
||||
lottery_info_type: 'article',
|
||||
create_time: o.create_time,
|
||||
is_liked: o.is_liked,
|
||||
uids: [o.uid, o.origin_uid],
|
||||
uids: [o.uid, o.origin.uid],
|
||||
uname: o.uname,
|
||||
ctrl: o.ctrl,
|
||||
dyid: o.dynamic_id,
|
||||
@@ -751,40 +591,37 @@ class Searcher {
|
||||
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);
|
||||
|
||||
log.info('获取动态', `查看Txt中所提及动态(${dyid}) (${length--})`);
|
||||
const card = await bili.getOneDynamicByDyid(dyid);
|
||||
if (card) {
|
||||
await utils.delay(get_dynamic_detail_wait);
|
||||
|
||||
if (card) {
|
||||
await utils.delay(get_dynamic_detail_wait);
|
||||
const parsed_card = parseDynamicCard(card)
|
||||
, { is_liked } = parsed_card;
|
||||
|
||||
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);
|
||||
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--})`);
|
||||
log.warn('获取动态', `动态细节获取失败(${dyid})`);
|
||||
}
|
||||
|
||||
}
|
||||
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],
|
||||
uids: [o.uid, o.origin.uid],
|
||||
uname: o.uname,
|
||||
ctrl: o.ctrl,
|
||||
dyid: o.dynamic_id,
|
||||
|
||||
+13
-1
@@ -86,6 +86,12 @@ const config = {
|
||||
'[转关评粉]|参与'
|
||||
],
|
||||
|
||||
ai_judge_parm: {
|
||||
url: '',
|
||||
body: {},
|
||||
prompt: ''
|
||||
},
|
||||
|
||||
/**
|
||||
* - '00' 关闭自动抽奖
|
||||
* - '10' 只转发官方抽奖
|
||||
@@ -332,6 +338,12 @@ const config = {
|
||||
'坚持不懈,迎难而上,开拓创新!', '[OK][OK]', '我来抽个奖', '中中中中中中', '[doge][doge][doge]', '我我我',
|
||||
],
|
||||
|
||||
ai_comments_parm: {
|
||||
url: '',
|
||||
body: {},
|
||||
prompt: ''
|
||||
},
|
||||
|
||||
/**
|
||||
* 是否抄热评
|
||||
*/
|
||||
@@ -478,4 +490,4 @@ const config = {
|
||||
};
|
||||
|
||||
|
||||
module.exports = config;
|
||||
module.exports = config;
|
||||
|
||||
+2
-1
@@ -13,7 +13,8 @@ const env = {
|
||||
const raw_env = this.raw_env();
|
||||
this.setEnv({
|
||||
...raw_env['account_parm'],
|
||||
...raw_env['push_parm']
|
||||
...raw_env['push_parm'],
|
||||
...raw_env['ai_parm']
|
||||
});
|
||||
},
|
||||
/**
|
||||
|
||||
+30
-22
@@ -1,4 +1,4 @@
|
||||
const { log, readDyidFile, writeDyidFile, dyid_length } = require('../utils');
|
||||
const { log, readDyidFile, writeDyidFile } = require('../utils');
|
||||
|
||||
const d_storage = {
|
||||
/**
|
||||
@@ -6,24 +6,35 @@ const d_storage = {
|
||||
* @param {string} dyid
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
searchDyid: (dyid) => {
|
||||
return new Promise((resolve) => {
|
||||
const Rdyid = new RegExp(dyid);
|
||||
const rs = readDyidFile(Number(process.env.NUMBER));
|
||||
let status = false;
|
||||
rs.on('data', chunk => {
|
||||
if (Rdyid.test(chunk)) {
|
||||
status = true;
|
||||
}
|
||||
});
|
||||
rs.on('end', () => {
|
||||
resolve(status);
|
||||
});
|
||||
rs.on('error', err => {
|
||||
log.error('搜索dyid', err);
|
||||
resolve(status);
|
||||
});
|
||||
});
|
||||
searchDyid: async (dyid) => {
|
||||
let buffer = '';
|
||||
let found = false;
|
||||
|
||||
const stream = readDyidFile(Number(process.env.NUMBER));
|
||||
|
||||
for await (const chunk of stream) {
|
||||
buffer += chunk;
|
||||
|
||||
while ((buffer.indexOf(dyid)) !== -1) {
|
||||
found = true;
|
||||
stream.destroy();
|
||||
return found;
|
||||
}
|
||||
|
||||
const lastCommaIdx = buffer.lastIndexOf(',');
|
||||
if (lastCommaIdx !== -1) {
|
||||
buffer = buffer.slice(lastCommaIdx);
|
||||
}
|
||||
}
|
||||
|
||||
if (!found && buffer.length > 0) {
|
||||
if (buffer.includes(dyid)) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
stream.destroy();
|
||||
return found;
|
||||
},
|
||||
/**
|
||||
* 更新dyid
|
||||
@@ -31,9 +42,6 @@ const d_storage = {
|
||||
*/
|
||||
updateDyid: (dyid) => {
|
||||
log.info('更新dyid', `写入${dyid}`);
|
||||
if (dyid.length !== dyid_length) {
|
||||
log.error('更新dyid', `dyid(${dyid})长度不为18 若出现此问题请即时通知开发者`);
|
||||
}
|
||||
return new Promise((resolve) => {
|
||||
const ws = writeDyidFile(Number(process.env.NUMBER));
|
||||
ws.write(dyid + ',', () => {
|
||||
|
||||
+89
-5
@@ -70,6 +70,7 @@ let PUSH_PLUS_TOKEN = '';
|
||||
let PUSH_PLUS_USER = '';
|
||||
|
||||
// ===========================================QMSG===========================================
|
||||
let QMSG_SOCKET = '';
|
||||
let QMSG_KEY = '';
|
||||
let QMSG_QQ = '';
|
||||
|
||||
@@ -87,6 +88,14 @@ let GOTIFY_URL = '';
|
||||
// 此处填你想推送的Application的Token(不包含推送时额外添加的前缀 Bearer )
|
||||
let GOTIFY_APPKEY = '';
|
||||
|
||||
// =======================================飞书机器人通知设置区域===========================================
|
||||
// 此处填你飞书机器人的 webhook(详见文档 https://open.feishu.cn/document/client-docs/bot-v3/add-custom-bot)
|
||||
// 注:此处设置github action用户填写到Settings-Secrets里面(Name输入FS_BOT_WEBHOOK)
|
||||
let FS_BOT_WEBHOOK = '';
|
||||
// 签名密钥(如果在飞书机器人安全设置里开启了“签名校验”)
|
||||
// 注:此处设置github action用户填写到Settings-Secrets里面(Name输入FS_BOT_SECRET)
|
||||
let FS_BOT_SECRET = '';
|
||||
|
||||
//==========================云端环境变量的判断与接收=========================
|
||||
if (process.env.SCKEY) {
|
||||
SCKEY = process.env.SCKEY;
|
||||
@@ -173,6 +182,12 @@ if (process.env.PUSH_PLUS_USER) {
|
||||
PUSH_PLUS_USER = process.env.PUSH_PLUS_USER;
|
||||
}
|
||||
|
||||
if (process.env.QMSG_SOCKET) {
|
||||
QMSG_SOCKET = process.env.QMSG_SOCKET;
|
||||
} else {
|
||||
QMSG_SOCKET = 'qmsg.zendee.cn';
|
||||
}
|
||||
|
||||
if (process.env.QMSG_KEY) {
|
||||
QMSG_KEY = process.env.QMSG_KEY;
|
||||
}
|
||||
@@ -204,6 +219,14 @@ if (process.env.GOTIFY_URL) {
|
||||
}
|
||||
}
|
||||
|
||||
if (process.env.FS_BOT_WEBHOOK) {
|
||||
FS_BOT_WEBHOOK = process.env.FS_BOT_WEBHOOK;
|
||||
}
|
||||
|
||||
if (process.env.FS_BOT_SECRET) {
|
||||
FS_BOT_SECRET = process.env.FS_BOT_SECRET;
|
||||
}
|
||||
|
||||
//==========================云端环境变量的判断与接收=========================
|
||||
|
||||
async function sendNotify(text, desp, params = {}) {
|
||||
@@ -239,7 +262,9 @@ async function sendNotify(text, desp, params = {}) {
|
||||
//电子邮件
|
||||
email(text, desp),
|
||||
// Gotify
|
||||
gotifyNotify(text, desp)
|
||||
gotifyNotify(text, desp),
|
||||
// 飞书机器人
|
||||
feishuNotify(text, desp)
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -619,7 +644,7 @@ function ddBotNotify(text, desp) {
|
||||
|
||||
function qywxAmNotify(text, desp) {
|
||||
return new Promise(resolve => {
|
||||
desp=desp.replace(/\n/g, '<br>');
|
||||
desp = desp.replace(/\n/g, '<br>');
|
||||
if (QYWX_AM) {
|
||||
const QYWX_AM_AY = QYWX_AM.split(',');
|
||||
send({
|
||||
@@ -648,8 +673,8 @@ function qywxAmNotify(text, desp) {
|
||||
agentid: `${QYWX_AM_AY[3]}`,
|
||||
safe: '0',
|
||||
msgtype: 'mpnews',
|
||||
mpnews : {
|
||||
articles:[
|
||||
mpnews: {
|
||||
articles: [
|
||||
{
|
||||
title: `${text}`,
|
||||
thumb_media_id: `${QYWX_AM_AY[4]}`,
|
||||
@@ -878,12 +903,71 @@ function gotifyNotify(text, desp) {
|
||||
});
|
||||
}
|
||||
|
||||
function feishuNotify(text, desp) {
|
||||
return new Promise(resolve => {
|
||||
if (FS_BOT_WEBHOOK) {
|
||||
const payload = {
|
||||
msg_type: 'text',
|
||||
content: {
|
||||
text: `${text}\n\n${desp}`
|
||||
}
|
||||
};
|
||||
|
||||
if (FS_BOT_SECRET) {
|
||||
const crypto = require('crypto');
|
||||
const timestamp = Math.floor(Date.now() / 1000);
|
||||
const signStr = `${timestamp}\n${FS_BOT_SECRET}`;
|
||||
const sign = crypto
|
||||
.createHmac('sha256', FS_BOT_SECRET)
|
||||
.update(signStr)
|
||||
.digest('base64');
|
||||
payload.timestamp = `${timestamp}`;
|
||||
payload.sign = sign;
|
||||
}
|
||||
|
||||
send({
|
||||
method: 'POST',
|
||||
url: FS_BOT_WEBHOOK,
|
||||
contents: payload,
|
||||
config: {
|
||||
retry: false
|
||||
},
|
||||
headers: {
|
||||
accept: 'application/json, text/plain, */*',
|
||||
'content-type': 'application/json',
|
||||
},
|
||||
success: res => {
|
||||
try {
|
||||
const data = JSON.parse(res.body);
|
||||
if (data.code === 0) {
|
||||
log.info('发送通知', '飞书机器人发送通知消息完成。');
|
||||
} else {
|
||||
log.error('发送通知', `${data.msg || '飞书机器人发送通知异常'}`);
|
||||
}
|
||||
} catch (e) {
|
||||
log.error('发送通知', e);
|
||||
} finally {
|
||||
resolve();
|
||||
}
|
||||
},
|
||||
failure: err => {
|
||||
log.error('发送通知', '飞书机器人发送通知消息失败!!' + err);
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
log.debug('发送通知', '您未提供飞书机器人推送所需的FS_BOT_WEBHOOK,取消飞书机器人推送消息通知');
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function qmsg(text, desp) {
|
||||
return new Promise(resolve => {
|
||||
if (QMSG_KEY) {
|
||||
send({
|
||||
method: 'POST',
|
||||
url: 'https://qmsg.zendee.cn/send/' + QMSG_KEY,
|
||||
url: `https://${QMSG_SOCKET}/send/${QMSG_KEY}`,
|
||||
contents: {
|
||||
msg: text + '\n\n' + desp,
|
||||
qq: QMSG_QQ
|
||||
|
||||
+1
-2
@@ -5,9 +5,7 @@ module.exports = Object.freeze({
|
||||
DYNAMIC_REPOST_SHARE: 'https://api.vc.bilibili.com/dynamic_repost/v1/dynamic_repost/share',
|
||||
DYNAMIC_SVR_CREATE_DRAW: 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/create_draw',
|
||||
DYNAMIC_SVR_CREATE: 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/create',
|
||||
DYNAMIC_SVR_GET_DYNAMIC_DETAIL: 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/get_dynamic_detail',
|
||||
DYNAMIC_SVR_RM_DYNAMIC: 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/rm_dynamic',
|
||||
DYNAMIC_SVR_SPACE_HISTORY: 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/space_history',
|
||||
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',
|
||||
@@ -39,4 +37,5 @@ module.exports = Object.freeze({
|
||||
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',
|
||||
X_POLYMER_WEB_DYNAMIC_V1_DETAIL: 'https://api.bilibili.com/x/polymer/web-dynamic/v1/detail',
|
||||
X_POLYMER_WEB_DYNAMIC_V1_FEED_SPACE: 'https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/space',
|
||||
});
|
||||
|
||||
+17
-19
@@ -98,8 +98,8 @@ function get({ url, config, contents, query }) {
|
||||
},
|
||||
query,
|
||||
contents,
|
||||
success: res => resolve(res.body),
|
||||
failure: err => resolve(err)
|
||||
success: res => resolve(log.debug_return(url, res.body)),
|
||||
failure: err => resolve(log.debug_return(url, err))
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -122,8 +122,8 @@ function post({ url, config, contents, query }) {
|
||||
},
|
||||
query,
|
||||
contents,
|
||||
success: res => resolve(res.body),
|
||||
failure: err => resolve(err)
|
||||
success: res => resolve(log.debug_return(url, res.body)),
|
||||
failure: err => resolve(log.debug_return(url, err))
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -407,7 +407,7 @@ const bili_client = {
|
||||
redirect: false,
|
||||
}
|
||||
}).then(a => {
|
||||
const dyid = (a.match(/[0-9]{18}/) || [])[0];
|
||||
const dyid = (a.match(/[0-9]{18,}/) || [])[0];
|
||||
log.info('短连接转换', `${short_id} -> ${dyid}`);
|
||||
return dyid;
|
||||
});
|
||||
@@ -419,14 +419,8 @@ const bili_client = {
|
||||
url: API.X_POLYMER_WEB_DYNAMIC_V1_DETAIL,
|
||||
config: { retry: false },
|
||||
query: {
|
||||
id
|
||||
}
|
||||
}),
|
||||
(dynamic_id) => get({
|
||||
url: API.DYNAMIC_SVR_GET_DYNAMIC_DETAIL,
|
||||
config: { retry: false },
|
||||
query: {
|
||||
dynamic_id
|
||||
id,
|
||||
features: 'itemOpusStyle'
|
||||
}
|
||||
}),
|
||||
]
|
||||
@@ -455,14 +449,15 @@ const bili_client = {
|
||||
* @param {string} offset_dynamic_id 此动态偏移量 初始为 0
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
getOneDynamicInfoByUID(host_uid, offset_dynamic_id) {
|
||||
getOneDynamicInfoByUID(host_mid, offset) {
|
||||
/* 鉴别工作交由modifyDynamicRes完成 */
|
||||
/* 新版似乎没有 visitor_uid */
|
||||
return get({
|
||||
url: API.DYNAMIC_SVR_SPACE_HISTORY,
|
||||
url: API.X_POLYMER_WEB_DYNAMIC_V1_FEED_SPACE,
|
||||
query: {
|
||||
visitor_uid: GlobalVar.get('myUID'),
|
||||
host_uid,
|
||||
offset_dynamic_id,
|
||||
host_mid,
|
||||
offset,
|
||||
features: 'itemOpusStyle'
|
||||
},
|
||||
config: {
|
||||
retry: false
|
||||
@@ -568,7 +563,10 @@ const bili_client = {
|
||||
*/
|
||||
getOneArticleByCv(cv) {
|
||||
return get({
|
||||
url: API.READ_CV.replace('{{cv}}', cv)
|
||||
url: API.READ_CV.replace('{{cv}}', cv),
|
||||
config: {
|
||||
redirect: true
|
||||
}
|
||||
});
|
||||
},
|
||||
/**
|
||||
|
||||
+13
-10
@@ -62,28 +62,31 @@ async function update(isDdownload) {
|
||||
try {
|
||||
const { tag_name, assets, body: text } = await getLatestRelease('shanmiteko', 'LotteryAutoScript');
|
||||
if (checkVersion(version) < checkVersion(tag_name)) {
|
||||
const download_url = assets
|
||||
/**
|
||||
* @type {{browser_download_url:string, size:number}[]}
|
||||
*/
|
||||
const download_item = assets
|
||||
.filter(({ name }) => checkPlatform(name))
|
||||
.map(({ browser_download_url }) => browser_download_url);
|
||||
if (download_url.length) {
|
||||
.map(({ browser_download_url, size }) => { return { browser_download_url, size }; });
|
||||
if (download_item.length) {
|
||||
if (isDdownload) {
|
||||
await try_for_each(download_url.entries(), async ([i, url]) => {
|
||||
let proxy_url = 'https://mirror.ghproxy.com/';
|
||||
proxy_url += url;
|
||||
await try_for_each(download_item.entries(), async ([i, { browser_download_url, size }]) => {
|
||||
let proxy_url = 'https://ghfast.top/';
|
||||
proxy_url += browser_download_url;
|
||||
log.warn('自动下载', `切换代理${proxy_url}`);
|
||||
await download(proxy_url, `latest_version${i}.zip`)
|
||||
await download(proxy_url, `latest_version${i}.zip`, size)
|
||||
.catch(async err => {
|
||||
log.error('自动下载', err);
|
||||
proxy_url = url;
|
||||
proxy_url = browser_download_url;
|
||||
log.warn('自动下载', `使用原始链接${proxy_url}`);
|
||||
await download(proxy_url, `latest_version${i}.zip`);
|
||||
await download(proxy_url, `latest_version${i}.zip`, size);
|
||||
});
|
||||
return false;
|
||||
});
|
||||
log.info('自动下载', '成功下载到当前目录');
|
||||
log.info('检查更新', '请手动解压替换可执行文件');
|
||||
}
|
||||
log.info('更新说明', '\n' + text + '\n');
|
||||
log.notice('更新说明', '\n' + text + '\n');
|
||||
} else {
|
||||
throw `未找到能在此平台(${process.platform})-(${process.arch})上运行的版本,建议以源码运行`;
|
||||
}
|
||||
|
||||
+104
-20
@@ -19,8 +19,6 @@ const utils = {
|
||||
lottery_info_dir: path.join(process.cwd(), 'lottery_info'),
|
||||
/**本地抽奖信息存放目录 */
|
||||
lottery_dyids: path.join(process.cwd(), 'lottery_dyids'),
|
||||
/**dyid长度 */
|
||||
dyid_length: 18,
|
||||
/**
|
||||
* 将版本号转为数字
|
||||
* @example
|
||||
@@ -100,6 +98,7 @@ const utils = {
|
||||
return _c(restNum - 1, argsList.concat(x));
|
||||
};
|
||||
}
|
||||
|
||||
return _c(func.length, []);
|
||||
},
|
||||
/**
|
||||
@@ -123,7 +122,9 @@ const utils = {
|
||||
let c = {
|
||||
i: 0,
|
||||
next: () => c.i++,
|
||||
clear: () => { c.i = 0; },
|
||||
clear: () => {
|
||||
c.i = 0;
|
||||
},
|
||||
value: () => c.i
|
||||
};
|
||||
return c;
|
||||
@@ -132,7 +133,7 @@ const utils = {
|
||||
* 无限序列
|
||||
* `[0..]`
|
||||
*/
|
||||
*infiniteNumber() {
|
||||
* infiniteNumber() {
|
||||
for (let index = 0; ; index++) {
|
||||
yield index;
|
||||
}
|
||||
@@ -180,7 +181,7 @@ const utils = {
|
||||
/**
|
||||
* 是否有指定环境变量
|
||||
* @param {string} env_name
|
||||
* @returns
|
||||
* @returns
|
||||
*/
|
||||
hasEnv(env_name) {
|
||||
return process.env[env_name] ? true : false;
|
||||
@@ -190,7 +191,7 @@ const utils = {
|
||||
_level: 3,
|
||||
_colors: [
|
||||
chalk.hex('#64B3FF'), chalk.grey, chalk.hex('#FFA500'),
|
||||
chalk.hex('#0070BB'), chalk.hex('#48BB31'), chalk.hex('#BBBB23'), chalk.hex('#FF0006')
|
||||
chalk.hex('#0070BB'), chalk.hex('#48BB31'), chalk.hex('#BFFF00'), chalk.hex('#BBBB23'), chalk.hex('#FF0006')
|
||||
],
|
||||
_iso_time: () => new Date(Date.now() + 288e5).toISOString().slice(0, -1) + '+08',
|
||||
_cache: [],
|
||||
@@ -230,7 +231,7 @@ const utils = {
|
||||
process.stdout.write(status_bar);
|
||||
},
|
||||
debug(context, msg) {
|
||||
if (this._level > 3) {
|
||||
if (this._level >= 4) {
|
||||
if (msg instanceof Object) msg = JSON.stringify(msg, null, 4);
|
||||
let color_text_pair = [
|
||||
[this._colors[0], `[${this._iso_time()}]`],
|
||||
@@ -241,8 +242,12 @@ const utils = {
|
||||
this.proPrint(color_text_pair.map(([color, text]) => color(text)));
|
||||
}
|
||||
},
|
||||
debug_return(context, obj) {
|
||||
this.debug(context, obj);
|
||||
return obj;
|
||||
},
|
||||
info(context, msg) {
|
||||
if (this._level > 2) {
|
||||
if (this._level >= 3) {
|
||||
let color_text_pair = [
|
||||
[this._colors[0], `[${this._iso_time()}]`],
|
||||
[this._colors[1], '[Info]'],
|
||||
@@ -253,25 +258,37 @@ const utils = {
|
||||
this.proPrint(color_text_pair.map(([color, text]) => color(text)));
|
||||
}
|
||||
},
|
||||
notice(context, msg) {
|
||||
if (this._level >= 2) {
|
||||
let color_text_pair = [
|
||||
[this._colors[0], `[${this._iso_time()}]`],
|
||||
[this._colors[1], '[Notice]'],
|
||||
[this._colors[2], `[帐号${process.env['NUMBER']} ${context}]`],
|
||||
[this._colors[5], `[${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) {
|
||||
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._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)));
|
||||
}
|
||||
},
|
||||
error(context, msg) {
|
||||
if (this._level > 0) {
|
||||
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._colors[7], `[\n${msg}\n]`],
|
||||
];
|
||||
this._cache.push(color_text_pair.map(it => it[1]).join(' '));
|
||||
this.proPrint(color_text_pair.map(([color, text]) => color(text)));
|
||||
@@ -280,7 +297,7 @@ const utils = {
|
||||
},
|
||||
/**
|
||||
* 验证码识别
|
||||
* @param {string} url
|
||||
* @param {string} url
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
ocr(url) {
|
||||
@@ -305,9 +322,10 @@ const utils = {
|
||||
* 下载文件
|
||||
* @param {string} url
|
||||
* @param {string} file_name
|
||||
* @param {number} size
|
||||
* @returns {Promise<void | string>}
|
||||
*/
|
||||
download(url, file_name) {
|
||||
download(url, file_name, size) {
|
||||
return new Promise((resolve, reject) => {
|
||||
send({
|
||||
url,
|
||||
@@ -327,6 +345,9 @@ const utils = {
|
||||
resStream.pipe(wtbs);
|
||||
wtbs.on('finish', () => {
|
||||
utils.log.proPrint('下载完成');
|
||||
if (recv_length < size) {
|
||||
reject(`未正确下载文件: ${recv_length}B < ${size}B`);
|
||||
}
|
||||
resolve();
|
||||
}).on('error', error => {
|
||||
wtbs.destroy();
|
||||
@@ -342,7 +363,7 @@ const utils = {
|
||||
/**
|
||||
* 是否存在文件或目录
|
||||
* @param {string} path
|
||||
* @returns
|
||||
* @returns
|
||||
*/
|
||||
hasFileOrDir(path) {
|
||||
try {
|
||||
@@ -402,7 +423,7 @@ const utils = {
|
||||
*/
|
||||
readDyidFile(num) {
|
||||
const fpath = num < 2 ? path.join(utils.dyids_dir, 'dyid.txt') : path.join(utils.dyids_dir, `dyid${num}.txt`);
|
||||
return fs.createReadStream(fpath, { encoding: 'utf8', highWaterMark: (utils.dyid_length + 1) * 1000 });
|
||||
return fs.createReadStream(fpath, { encoding: 'utf8' });
|
||||
},
|
||||
/**
|
||||
* 追加dyid
|
||||
@@ -416,7 +437,7 @@ const utils = {
|
||||
/**
|
||||
* 追加lotteryinfo
|
||||
* @param {string} from
|
||||
* @param {import("./core/searcher").LotteryInfo[]} lottery_info
|
||||
* @param {import('./core/searcher').LotteryInfo[]} lottery_info
|
||||
* @return {Promise<void>}
|
||||
*/
|
||||
async appendLotteryInfoFile(from, lottery_info) {
|
||||
@@ -437,7 +458,7 @@ const utils = {
|
||||
/**
|
||||
* 读取lottery_info
|
||||
* @param {string} filename
|
||||
* @return {Promise<import("./core/searcher").LotteryInfo[]>}
|
||||
* @return {Promise<import('./core/searcher').LotteryInfo[]>}
|
||||
*/
|
||||
readLotteryInfoFile(filename) {
|
||||
return new Promise((resolve) => {
|
||||
@@ -473,8 +494,71 @@ const utils = {
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
getIpInfo() {
|
||||
return new Promise((resolve) => {
|
||||
send({
|
||||
url: 'https://myip.qq.com/',
|
||||
method: 'GET',
|
||||
success: res => resolve(res.body),
|
||||
failure: err => resolve(err)
|
||||
});
|
||||
});
|
||||
},
|
||||
printIpInfo(beforeProxy) {
|
||||
const printMessage = beforeProxy ? '当前IP----->' : '代理后IP=======>';
|
||||
utils.getIpInfo().then(res => {
|
||||
console.log(printMessage + res);
|
||||
}).catch((err) => {
|
||||
console.error('获取' + printMessage + '地址失败', err);
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 获取ai
|
||||
* @param {string} url
|
||||
* @param {object} body
|
||||
* @param {string} prompt
|
||||
* @param {string} content
|
||||
* @returns {Promise<string|null>}
|
||||
*/
|
||||
getAiContent(url, body, prompt, content) {
|
||||
return new Promise((resolve) => {
|
||||
send({
|
||||
method: 'POST',
|
||||
url,
|
||||
headers: {
|
||||
'authorization': 'Bearer ' + process.env.AI_API_KEY,
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
config: {
|
||||
timeout: 120000
|
||||
},
|
||||
contents: {
|
||||
...body,
|
||||
'stream': false,
|
||||
'response_format': { 'type': 'text' },
|
||||
'messages': [
|
||||
{
|
||||
'role': 'system',
|
||||
'content': prompt
|
||||
},
|
||||
{
|
||||
'role': 'user',
|
||||
'content': content
|
||||
}
|
||||
]
|
||||
},
|
||||
success: res => {
|
||||
const data = utils.strToJson(res.body);
|
||||
resolve(data?.choices?.[0]?.message?.content || null);
|
||||
},
|
||||
failure: () => {
|
||||
resolve(null);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
module.exports = utils;
|
||||
module.exports = utils;
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
const { version: ve, env_file, config_file, log, hasEnv, delay, hasFileOrDir, clearLotteryInfo } = require('./lib/utils');
|
||||
|
||||
const {
|
||||
version: ve,
|
||||
env_file,
|
||||
config_file,
|
||||
log,
|
||||
hasEnv,
|
||||
delay,
|
||||
hasFileOrDir,
|
||||
clearLotteryInfo, printIpInfo
|
||||
} = require('./lib/utils');
|
||||
const { HttpsProxyAgent } = require('https-proxy-agent');
|
||||
const request = require('https');
|
||||
const metainfo = [
|
||||
' _ _ _ _____ _ _ ',
|
||||
' | | | | | | / ____| (_) | | ',
|
||||
@@ -31,6 +41,7 @@ async function main() {
|
||||
: JSON.parse(MULTIPLE_ACCOUNT_PARM);
|
||||
|
||||
process.env.ENABLE_MULTIPLE_ACCOUNT = '';
|
||||
let localhost = request.globalAgent;
|
||||
|
||||
for (const acco of muti_acco) {
|
||||
process.env.COOKIE = acco.COOKIE;
|
||||
@@ -38,6 +49,19 @@ async function main() {
|
||||
process.env.CLEAR = acco.CLEAR;
|
||||
process.env.NOTE = acco.NOTE;
|
||||
process.env.ACCOUNT_UA = acco.ACCOUNT_UA;
|
||||
if (acco.PROXY_HOST) {
|
||||
printIpInfo(true);
|
||||
//http://ip:port
|
||||
//http://user:pwd@ip:port'
|
||||
const proxyUrl = acco.PROXY_USER
|
||||
? 'http://' + acco.PROXY_USER + ':' + acco.PROXY_PASS + '@' + acco.PROXY_HOST + ':' + acco.PROXY_PORT
|
||||
: 'http://' + acco.PROXY_HOST + ':' + acco.PROXY_PORT;
|
||||
request.globalAgent = new HttpsProxyAgent(proxyUrl);
|
||||
printIpInfo(false);
|
||||
}else {
|
||||
//未设置还原
|
||||
request.globalAgent = localhost;
|
||||
}
|
||||
const err_msg = await main();
|
||||
if (err_msg) {
|
||||
return err_msg;
|
||||
@@ -48,8 +72,8 @@ async function main() {
|
||||
await delay(3 * 1000);
|
||||
}
|
||||
}
|
||||
request.globalAgent = localhost;
|
||||
}
|
||||
|
||||
/**多账号状态还原 */
|
||||
process.env.ENABLE_MULTIPLE_ACCOUNT = ENABLE_MULTIPLE_ACCOUNT;
|
||||
} else if (COOKIE) {
|
||||
@@ -65,7 +89,12 @@ async function main() {
|
||||
const mode = process.env.lottery_mode;
|
||||
const help_msg = '用法: lottery [OPTIONS]\n\nOPTIONS:\n\tstart 启动抽奖\n\tcheck 中奖检查\n\tacount 查看帐号信息\n\tclear 清理动态和关注\n\tlogin 扫码登录更新CK\n\tupdate 检查更新\n\thelp 帮助信息';
|
||||
if (await checkCookie(NUMBER)) {
|
||||
const { lottery_loop_wait, check_loop_wait, clear_loop_wait, save_lottery_info_to_file } = require('./lib/data/config');
|
||||
const {
|
||||
lottery_loop_wait,
|
||||
check_loop_wait,
|
||||
clear_loop_wait,
|
||||
save_lottery_info_to_file
|
||||
} = require('./lib/data/config');
|
||||
ck_flag = 1;
|
||||
switch (mode) {
|
||||
case 'start':
|
||||
|
||||
+51
-7
@@ -90,6 +90,19 @@ module.exports = Object.freeze({
|
||||
'[转关评粉]|参与'
|
||||
],
|
||||
|
||||
/**
|
||||
* AI 判断抽奖
|
||||
* https://learn.microsoft.com/en-us/azure/ai-foundry/openai/reference#chat-completions
|
||||
*/
|
||||
ai_judge_parm: {
|
||||
/**
|
||||
* /chat/completions
|
||||
*/
|
||||
url: '',
|
||||
body: {},
|
||||
prompt: ''
|
||||
},
|
||||
|
||||
/**
|
||||
* - '00' 关闭自动抽奖
|
||||
* - '10' 只转发官方抽奖
|
||||
@@ -341,6 +354,19 @@ module.exports = Object.freeze({
|
||||
'坚持不懈,迎难而上,开拓创新!', '[OK][OK]', '我来抽个奖', '中中中中中中', '[doge][doge][doge]', '我我我',
|
||||
],
|
||||
|
||||
/**
|
||||
* AI Chat completions参数
|
||||
* https://learn.microsoft.com/en-us/azure/ai-foundry/openai/reference#chat-completions
|
||||
*/
|
||||
ai_comments_parm: {
|
||||
/**
|
||||
* /chat/completions
|
||||
*/
|
||||
url: '',
|
||||
body: {},
|
||||
prompt: ''
|
||||
},
|
||||
|
||||
/**
|
||||
* 是否抄热评
|
||||
*/
|
||||
@@ -459,7 +485,7 @@ module.exports = Object.freeze({
|
||||
* 1
|
||||
* [1,2,4]
|
||||
*/
|
||||
clear_dynamic_type: [1]
|
||||
clear_dynamic_type: [1],
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -470,15 +496,12 @@ module.exports = Object.freeze({
|
||||
/**
|
||||
* 手动添加抽奖号UID
|
||||
* - 抽奖动态下的二级小号
|
||||
*
|
||||
* 帐号1存储抽奖信息至文件
|
||||
*/
|
||||
UIDs: [],
|
||||
|
||||
TAGs: [
|
||||
'互动抽奖',
|
||||
'转发抽奖',
|
||||
'动态抽奖',
|
||||
'抽奖',
|
||||
],
|
||||
TAGs: [],
|
||||
|
||||
Articles: [
|
||||
'抽奖合集'
|
||||
@@ -486,8 +509,29 @@ module.exports = Object.freeze({
|
||||
|
||||
APIs: [],
|
||||
|
||||
ai_judge_parm: {
|
||||
url: 'https://api.deepseek.com/chat/completions',
|
||||
body: {
|
||||
'model': 'Qwen/Qwen3-32B',
|
||||
'enable_thinking': true,
|
||||
},
|
||||
prompt: '你是一个B站用户,需要判断动态内容是否是抽奖动态,以及参与条件,以json格式输出,仅需包含key:has_key_words(bool 是否是抽奖动态),needAt(bool 是否需要@),needTopic(bool 是否需要带话题),more(string 总结参与抽奖的条件).回答不要包含markdown标记文本,输出纯json文本'
|
||||
},
|
||||
|
||||
ai_comments_parm: {
|
||||
url: 'https://api.deepseek.com/chat/completions',
|
||||
body: {
|
||||
'model': 'Qwen/Qwen3-32B',
|
||||
'enable_thinking': true,
|
||||
},
|
||||
prompt: '你是一个B站用户,请根据以下内容直接生成一条模拟真实用户的评论,不要使用表情,无需说明信息,且不包含任何敏感词汇。'
|
||||
},
|
||||
|
||||
save_lottery_info_to_file: true,
|
||||
},
|
||||
/**
|
||||
* 后续帐号从文件提取抽奖信息转抽
|
||||
*/
|
||||
config_2: {},
|
||||
config_3: {}
|
||||
});
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "lottery-auto-script",
|
||||
"version": "2.9.2",
|
||||
"version": "2.11.0",
|
||||
"description": "自动参与B站动态抽奖",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
||||
+12
-12
@@ -1,11 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# version: <major.minor.patch>
|
||||
level=patch
|
||||
level=minor
|
||||
|
||||
npm version $level \
|
||||
--no-commit-hooks \
|
||||
--no-git-tag-version
|
||||
--no-commit-hooks \
|
||||
--no-git-tag-version
|
||||
|
||||
OLD_VERSION_ARRAY=($(npm view lottery-auto-script version | tr '.' ' '))
|
||||
major=${OLD_VERSION_ARRAY[0]}
|
||||
@@ -14,17 +14,17 @@ patch=${OLD_VERSION_ARRAY[2]}
|
||||
|
||||
case "${level}" in
|
||||
"major")
|
||||
((major += 1))
|
||||
minor=0
|
||||
patch=0
|
||||
;;
|
||||
((major += 1))
|
||||
minor=0
|
||||
patch=0
|
||||
;;
|
||||
"minor")
|
||||
((minor += 1))
|
||||
patch=0
|
||||
;;
|
||||
((minor += 1))
|
||||
patch=0
|
||||
;;
|
||||
*)
|
||||
((patch += 1))
|
||||
;;
|
||||
((patch += 1))
|
||||
;;
|
||||
esac
|
||||
|
||||
NEW_VERSION="$major.$minor.$patch"
|
||||
|
||||
@@ -37,7 +37,7 @@ CONFIG_FILE=my_config.js
|
||||
# docker仓库
|
||||
DOCKER_REPO=shanmite/lottery_auto_docker
|
||||
# cdn
|
||||
CDN=https://cdn.staticaly.com/gh/shanmiteko/LotteryAutoScript/main
|
||||
CDN=https://gitlab.com/shanmiteko/LotteryAutoScript/-/raw/main
|
||||
# env.example.js文件
|
||||
ENV_EXAMPLE="$CDN/env.example.js"
|
||||
# my_config.example.js文件
|
||||
|
||||
@@ -4,9 +4,7 @@ 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
|
||||
GIT_REPO=https://gitlab.com/shanmiteko/${NAME}.git
|
||||
|
||||
if [ -d "$NAME" ]; then
|
||||
cd $NAME
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
const util = require('./util');
|
||||
const utils = require('../lib/utils.js');
|
||||
const config = require('../lib/data/config');
|
||||
|
||||
(async () => {
|
||||
await util.par_run([], [
|
||||
// 0
|
||||
async () => {
|
||||
let msg = await utils.getAiContent(
|
||||
config.ai_judge_parm.url,
|
||||
config.ai_judge_parm.body,
|
||||
config.ai_judge_parm.prompt,
|
||||
'#胜利女神新的希望# #nikke# \n【一周年评论盖楼挑战③】拿来吧妮……的表情包!\n\n指挥官的手机里,\n一定存着几张出场率超高的妮姬表情包吧?\n和妮姬们相遇的一周年已至,这些也成了旅途中的一段快乐印记~是时候公开自己的库存了yo!\n\n无论是新收新做的趣味表情,还是珍藏一年的经典老图——\n现在,让它们登场吧!\n\n评论区交出您的表情包库存,看看这一年谁的“收藏”最cool!!\n🎁我们将在6月9日于本条评论区随机抽选:\n▶1位指挥官赠送【周边大礼盒】× 1\n▶10位指挥官赠送【Q版印章小立牌】× 1\n\n💝盖楼目标达成奖励:\n5月20日~22日期间,参与【一周年评论盖楼挑战】系列话题活动! 当全平台评论数累计达成 【2026】 楼时,我们将从本平台参与系列话题活动的用户中额外抽取2位幸运指挥官,每人送出【哈曼卡顿音响】× 1!\n\n————————————\n✦《胜利女神:新的希望》一周年庆典版本「OLD TALES 尘封童话」现已上线!游戏多端互通,前往Bilibili游戏中心搜索《胜利女神:新的希望》即可下载。'
|
||||
);
|
||||
console.log(msg);
|
||||
msg = await utils.getAiContent(
|
||||
config.ai_comments_parm.url,
|
||||
config.ai_comments_parm.body,
|
||||
config.ai_comments_parm.prompt,
|
||||
'#胜利女神新的希望# #nikke# \n【一周年评论盖楼挑战③】拿来吧妮……的表情包!\n\n指挥官的手机里,\n一定存着几张出场率超高的妮姬表情包吧?\n和妮姬们相遇的一周年已至,这些也成了旅途中的一段快乐印记~是时候公开自己的库存了yo!\n\n无论是新收新做的趣味表情,还是珍藏一年的经典老图——\n现在,让它们登场吧!\n\n评论区交出您的表情包库存,看看这一年谁的“收藏”最cool!!\n🎁我们将在6月9日于本条评论区随机抽选:\n▶1位指挥官赠送【周边大礼盒】× 1\n▶10位指挥官赠送【Q版印章小立牌】× 1\n\n💝盖楼目标达成奖励:\n5月20日~22日期间,参与【一周年评论盖楼挑战】系列话题活动! 当全平台评论数累计达成 【2026】 楼时,我们将从本平台参与系列话题活动的用户中额外抽取2位幸运指挥官,每人送出【哈曼卡顿音响】× 1!\n\n————————————\n✦《胜利女神:新的希望》一周年庆典版本「OLD TALES 尘封童话」现已上线!游戏多端互通,前往Bilibili游戏中心搜索《胜利女神:新的希望》即可下载。'
|
||||
);
|
||||
console.log(msg);
|
||||
|
||||
},
|
||||
]);
|
||||
console.log('ai.test ... ok!');
|
||||
})();
|
||||
+1
-1
@@ -6,7 +6,7 @@ const { parseDynamicCard } = require('../lib/core/searcher');
|
||||
(async () => {
|
||||
assert.notEqual(await bili_client.getMyinfo(), null);
|
||||
|
||||
await util.par_run([0, 3], [
|
||||
await util.par_run([], [
|
||||
// 0
|
||||
async () => {
|
||||
assert.equal((await bili_client.getTopRcmd()).length, 10);
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
const assert = require('assert');
|
||||
const util = require('./util');
|
||||
const d_storage = require('../lib/helper/d_storage');
|
||||
|
||||
(async () => {
|
||||
await util.par_run([], [
|
||||
// 0
|
||||
async () => {
|
||||
assert(await d_storage.searchDyid('1234567901234568'));
|
||||
assert(!await d_storage.searchDyid('1234567901234569'));
|
||||
},
|
||||
]);
|
||||
console.log('dyidSearch.test ... ok!');
|
||||
})();
|
||||
@@ -1,68 +1,17 @@
|
||||
const assert = require('assert');
|
||||
//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], [
|
||||
await util.par_run([0], [
|
||||
// 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('900172162530279445'));
|
||||
assert.equal(card.chat_type, 11);
|
||||
card = searcher.parseDynamicCard(await bili_client.getOneDynamicByDyid('926978638295859236'));
|
||||
assert.equal(card.chat_type, 17);
|
||||
assert.equal(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('924676093465591832');
|
||||
const card = searcher.parseDynamicCard(dy);
|
||||
assert.equal(card.reserve_id, '3715576');
|
||||
},
|
||||
// 8
|
||||
async () => {
|
||||
const dy = await bili_client.getOneDynamicByDyid('925061227481137187');
|
||||
const card = searcher.parseDynamicCard(dy);
|
||||
assert.equal(card.origin_reserve_id, '3715576');
|
||||
let info = await bili_client.getOneDynamicByDyid('1207028214165143570');
|
||||
let card = searcher.parseDynamicCard(info);
|
||||
console.log(JSON.stringify(card, null, 4));
|
||||
},
|
||||
]);
|
||||
|
||||
console.log('dynamic_card.test ... ok!');
|
||||
})();
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user