mirror of
https://github.com/shanmiteko/LotteryAutoScript.git
synced 2026-07-22 21:13:47 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 |
@@ -16,7 +16,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
- name: Set up Docker Buildx
|
||||
|
||||
@@ -1,20 +1,26 @@
|
||||
name: Mirror and run GitLab CI
|
||||
|
||||
on: [push]
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- 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 }}
|
||||
- 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 }}
|
||||
|
||||
@@ -12,7 +12,7 @@ jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions/checkout@v3
|
||||
- uses: JS-DevTools/npm-publish@v1
|
||||
with:
|
||||
token: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
@@ -30,16 +30,16 @@ jobs:
|
||||
nodev: 12
|
||||
steps:
|
||||
- name: "Checkout codes"
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
- name: "Use Node.js"
|
||||
uses: actions/setup-node@v1
|
||||
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@v2
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: node${{ matrix.nodev }}-${{ matrix.platform }}-x64
|
||||
path: "dist/*.zip"
|
||||
@@ -63,12 +63,12 @@ jobs:
|
||||
- platform: alpine
|
||||
steps:
|
||||
- name: "Checkout codes"
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
- name: "Pkg this"
|
||||
run: |
|
||||
npm run pkg "${{ matrix.platform }}-arm64"
|
||||
- name: "Upload to artifact"
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: arm64
|
||||
path: "dist/*.zip"
|
||||
|
||||
@@ -1,5 +1,56 @@
|
||||
<!-- markdownlint-disable MD036 MD024-->
|
||||
# CHANGELOG
|
||||
## 主要变化(2.7.2)
|
||||
* af8c4a6 feat: 新增推送pushdeer (#236)
|
||||
* c1ca2b6 fix: 关键词筛选重复且影响官抽
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.7.1)
|
||||
* 92f1ad2 fix: 自动评论没有正确评论所有抽奖 (#235)
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.7.0)
|
||||
* c84cb3f feat: 评论内容从评论区随机获取 (#134)
|
||||
* 4fa6d9a feat: 可关闭预约抽奖转发 (#196)
|
||||
* 0814154 feat: 关注分区移动可关闭 (#228)
|
||||
* 5097f2a feat: 清理动态时显示UID保护列表 (#229)
|
||||
* cb08e7a feat: 过滤掉充电包月抽奖 (#224)
|
||||
* 7b5a177 refactor: 调整推送格式 (#223)
|
||||
* 63b550e ci(mirror): shallow update not allowed
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.6.9)
|
||||
* 28fc79e fix: 通知内不显示抽奖信息
|
||||
* 9e6fe66 fix: free `log._cache`
|
||||
* 5b50611 ci: update actions
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.6.8)
|
||||
* 847e680 feat: 丰富推送内容(#135)(#194)(#211)
|
||||
* 8bf5070 fix: `flatMap` is not a function (#218)
|
||||
* 727883a feat: 推送`NOTE` (#221)
|
||||
* fd33478 fix: 微信企业应用推送未配置出错 (#220)
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.6.7)
|
||||
* db7ba49 style: 修改通知格式
|
||||
* b518828 feat: 新增企业微信应用推送 (#217)
|
||||
* e0a8ce5 doc: update image
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.6.6)
|
||||
* 92f7003 perf: monochrome
|
||||
* 8e77afa fix: `fs.uninkSync` returns before remove finish
|
||||
* bfc8fb6 ci: gitlab mirror `workflow_dispatch`
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](https://github.com/shanmiteko/LotteryAutoScript/blob/main/CHANGELOG.md)变更说明_
|
||||
|
||||
## 主要变化(2.6.5)
|
||||
* 47e09a1 ci: arm64 added, and optimized
|
||||
* b91a4f9 fix: `fs.rm` node12
|
||||
|
||||
@@ -171,31 +171,34 @@ Chrome浏览器:
|
||||
|
||||
以下是支持的推送方式
|
||||
|
||||
| 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`-`推送铃声`-`查看所有铃声` |
|
||||
| `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_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`默认为一对一推送 |
|
||||
| `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` | 电子邮件 | 接收方电子邮件 |
|
||||
| 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` | 电子邮件 | 接收方电子邮件 |
|
||||
|
||||
----------------------------------------
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 274 KiB After Width: | Height: | Size: 221 KiB |
@@ -69,12 +69,15 @@ module.exports = Object.freeze({
|
||||
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: "",
|
||||
|
||||
+10
-13
@@ -7,9 +7,8 @@ const bili = require('./net/bili')
|
||||
/**
|
||||
* 是否中奖
|
||||
* @param {number} num
|
||||
* @param {string} [note]
|
||||
*/
|
||||
async function isMe(num, note = "无") {
|
||||
async function isMe(num) {
|
||||
let desp = '';
|
||||
const
|
||||
{ notice_key_words, update_session_wait, get_session_wait, check_session_pages } = config,
|
||||
@@ -23,13 +22,13 @@ async function isMe(num, note = "无") {
|
||||
.slice(0, unread_at_num)
|
||||
.forEach(({ at_time, up_uname, business, source_content, url }) => {
|
||||
desp += '## [at]检测结果\n\n'
|
||||
desp += '----------------------------------------------------------------\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 += `在${business}中@了[你](https://space.bilibili.com/${global_var.get("myUID")})\n\n`
|
||||
desp += `原内容为: ${source_content}\n\n`
|
||||
desp += `[直达链接](${url})\n\n`
|
||||
desp += '----------------------------------------------------------------\n\n'
|
||||
desp += '- - - -\n\n'
|
||||
});
|
||||
log.info('中奖检测', '--> OK');
|
||||
}
|
||||
@@ -41,12 +40,12 @@ async function isMe(num, note = "无") {
|
||||
.forEach(({ nickname, uri, source, timestamp }) => {
|
||||
if (judge(source, notice_key_words)) {
|
||||
desp += '## 回复检测结果\n\n'
|
||||
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 += `回复[你](https://space.bilibili.com/${global_var.get("myUID")})说:\n${source}\n\n`
|
||||
desp += `[直达链接](${uri})\n\n`
|
||||
desp += '----------------------------------------------------------------\n\n'
|
||||
desp += '- - - -\n\n'
|
||||
}
|
||||
})
|
||||
log.info('中奖检测', '--> OK');
|
||||
@@ -64,12 +63,12 @@ async function isMe(num, note = "无") {
|
||||
const content = await bili.fetch_session_msgs(talker_id, unread_count);
|
||||
if (judge(content, notice_key_words)) {
|
||||
desp += '## 私信检测结果\n\n'
|
||||
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://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'
|
||||
desp += '- - - -\n\n'
|
||||
}
|
||||
await bili.updateSessionStatus(talker_id, type, msg_seqno);
|
||||
await delay(update_session_wait);
|
||||
@@ -94,8 +93,6 @@ async function isMe(num, note = "无") {
|
||||
log.info('中奖检测', '--> OK');
|
||||
}
|
||||
if (desp) {
|
||||
desp += `帐号备注: ${note}\n\n`;
|
||||
desp += '中奖了别忘给脚本(https://github.com/shanmiteko/LotteryAutoScript)点一个Star哦, 赞助一两块也不是不可以_(:з」∠)_\n\n'
|
||||
log.info('可能中奖了', desp);
|
||||
await sendNotify(`帐号${num}可能中奖了`, desp);
|
||||
} else {
|
||||
|
||||
@@ -82,6 +82,7 @@ async function clear() {
|
||||
const days_ago = (Now - create_time) / 86400;
|
||||
|
||||
if (days_ago > clear_max_day) {
|
||||
log.info('清理动态', `当前UID保护列表:\n${before_separate.join(',')}\n`)
|
||||
/* 移除动态 */
|
||||
if (dynamic_id
|
||||
&& clear_remove_dynamic
|
||||
|
||||
+55
-26
@@ -37,7 +37,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', '分区获取失败')
|
||||
@@ -66,7 +67,10 @@ class Monitor extends Searcher {
|
||||
case 2004:
|
||||
log.warn('账号异常', `UID(${global_var.get('myUID')})异常号只会对部分UP出现关注异常`)
|
||||
if (!config.is_exception) {
|
||||
await sendNotify('[动态抽奖]账号异常通知', `UID: ${global_var.get('myUID')}\n\n异常号只会对部分UP出现关注异常\n\n可在设置中令is_exception为true关闭此推送`)
|
||||
await sendNotify(
|
||||
'[动态抽奖]账号异常通知',
|
||||
`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')
|
||||
@@ -74,7 +78,10 @@ class Monitor extends Searcher {
|
||||
case 2005:
|
||||
log.warn('关注已达上限', `UID(${global_var.get('myUID')})关注已达上限,已临时进入只转已关注模式`)
|
||||
if (!config.is_outof_maxfollow) {
|
||||
await sendNotify('[动态抽奖]关注已达上限', `UID: ${global_var.get('myUID')}\n\n关注已达上限,已临时进入只转已关注模式\n\n可在设置中令is_outof_maxfollow为true关闭此推送`)
|
||||
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;
|
||||
@@ -256,7 +263,16 @@ class Monitor extends Searcher {
|
||||
/** 所有抽奖信息 */
|
||||
let alllotteryinfo = [];
|
||||
const
|
||||
{ check_if_duplicated, save_lottery_info_to_file, set_lottery_info_url, disable_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,
|
||||
{
|
||||
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;
|
||||
|
||||
/**
|
||||
@@ -289,12 +305,12 @@ class Monitor extends Searcher {
|
||||
|
||||
if (lottery_param[0] !== "APIs" && save_lottery_info_to_file && protoLotteryInfo.length) {
|
||||
log.info("保存抽奖信息", "保存开始")
|
||||
appendLotteryInfoFile(lottery_param[1].toString(), protoLotteryInfo)
|
||||
await appendLotteryInfoFile(lottery_param[1].toString(), protoLotteryInfo)
|
||||
}
|
||||
|
||||
if (lottery_param[0] !== "APIs" && set_lottery_info_url && protoLotteryInfo.length) {
|
||||
log.info("上传抽奖信息", "上传开始")
|
||||
new Promise((resolve) => {
|
||||
await new Promise((resolve) => {
|
||||
send({
|
||||
url: set_lottery_info_url,
|
||||
method: "POST",
|
||||
@@ -318,7 +334,10 @@ class Monitor extends Searcher {
|
||||
await try_for_each(protoLotteryInfo, async function (lottery_info) {
|
||||
const {
|
||||
lottery_info_type, is_liked,
|
||||
uids, uname, dyid, reserve_id, reserve_lottery_text, create_time,
|
||||
uids, uname, dyid, reserve_id,
|
||||
reserve_lottery_text,
|
||||
is_charge_lottery,
|
||||
create_time, chat_type,
|
||||
ctrl, rid, des, type,
|
||||
hasOfficialLottery
|
||||
} = lottery_info;
|
||||
@@ -344,6 +363,11 @@ class Monitor extends Searcher {
|
||||
return false
|
||||
}
|
||||
|
||||
if (is_charge_lottery) {
|
||||
log.info("筛选动态", `充电抽奖(https://t.bilibili.com/${dyid})`)
|
||||
return false
|
||||
}
|
||||
|
||||
const
|
||||
[m_uid, ori_uid] = uids,
|
||||
mIsFollowed = !m_uid || (new RegExp(m_uid)).test(attentionList),
|
||||
@@ -418,13 +442,16 @@ class Monitor extends Searcher {
|
||||
} else {
|
||||
await delay(reserve_lottery_wait);
|
||||
await bili.reserve_lottery(reserve_id)
|
||||
if (is_not_relay_reserve_lottery === true) {
|
||||
log.info("预约抽奖", "已关闭预约抽奖转发功能");
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!has_key_words && description) {
|
||||
if (!hasOfficialLottery && model[1] === '1' && !has_key_words && description) {
|
||||
log.warn("筛选动态", `无关键词动态的描述: ${description}\n\n考虑是否修改设置key_words:\n${key_words.join('\n且满足: ')}`)
|
||||
return false
|
||||
}
|
||||
|
||||
/**若勾选只转已关注 */
|
||||
@@ -500,14 +527,7 @@ 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) {
|
||||
@@ -561,13 +581,16 @@ class Monitor extends Searcher {
|
||||
return 0
|
||||
}
|
||||
|
||||
let status = 0
|
||||
const
|
||||
let
|
||||
status = 0,
|
||||
{ uid, dyid, chat_type, rid, relay_chat, ctrl, chat } = option,
|
||||
{ check_if_duplicated, is_repost_then_chat } = config;
|
||||
{ check_if_duplicated, is_copy_chat, is_repost_then_chat, is_not_create_partition } = config;
|
||||
|
||||
/* 评论 */
|
||||
if (rid && chat_type) {
|
||||
if (is_copy_chat) {
|
||||
chat = getRandomOne(await bili.getChat(rid, chat_type)) || "!!!"
|
||||
}
|
||||
|
||||
status = await retryfn(
|
||||
6,
|
||||
@@ -601,13 +624,19 @@ class Monitor extends Searcher {
|
||||
if (status) {
|
||||
log.warn("抽奖信息", `dyid: ${dyid}, uid: ${u}`)
|
||||
return true
|
||||
} else if (await bili.movePartition(u, this.tagid)) {
|
||||
log.warn("抽奖信息", `dyid: ${dyid}, uid: ${u} tagid: ${this.tagid}`)
|
||||
/* 3000系错误 */
|
||||
status = 1001
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
if (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
|
||||
|
||||
+32
-6
@@ -15,22 +15,26 @@ const { log } = utils
|
||||
* @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
|
||||
*
|
||||
* 整理后的抽奖信息
|
||||
@@ -44,7 +48,9 @@ const { log } = utils
|
||||
* @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 是否官方
|
||||
@@ -63,6 +69,7 @@ function parseDynamicCard(dynamic_detail_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 */
|
||||
@@ -75,8 +82,8 @@ function parseDynamicCard(dynamic_detail_card) {
|
||||
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;
|
||||
/* 定位@信息 */
|
||||
@@ -96,6 +103,9 @@ function parseDynamicCard(dynamic_detail_card) {
|
||||
obj.reserve_lottery_text = text;
|
||||
}
|
||||
}
|
||||
if (JSON.stringify(add_on_card_info).match(/充电专属抽奖/)) {
|
||||
obj.is_charge_lottery = true
|
||||
}
|
||||
/* 是否有官方抽奖 */
|
||||
obj.hasOfficialLottery = extension && extension.lott && true;
|
||||
/* 转发者的描述 纯文字内容 图片动态描述 后两个分别是视频动态的描述和视频本身的描述*/
|
||||
@@ -103,6 +113,7 @@ function parseDynamicCard(dynamic_detail_card) {
|
||||
(item && (item.content || '' + item.description || ''))
|
||||
|| (cardToJson.dynamic || '' + cardToJson.desc || '')
|
||||
|| '';
|
||||
/* 转发 */
|
||||
if (obj.type === 1) {
|
||||
const { origin_extension, origin } = cardToJson
|
||||
, originToJson = strToJson(origin)
|
||||
@@ -112,8 +123,12 @@ function parseDynamicCard(dynamic_detail_card) {
|
||||
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;
|
||||
/* 预约抽奖信息 */
|
||||
@@ -131,6 +146,9 @@ function parseDynamicCard(dynamic_detail_card) {
|
||||
obj.origin_reserve_lottery_text = text;
|
||||
}
|
||||
}
|
||||
if (JSON.stringify(add_on_card_info).match(/充电专属抽奖/)) {
|
||||
obj.origin_is_charge_lottery = true
|
||||
}
|
||||
/* 是否有官方抽奖 */
|
||||
obj.origin_hasOfficialLottery = origin_extension && origin_extension.lott;
|
||||
/* 被转发者的name */
|
||||
@@ -256,6 +274,7 @@ class Searcher {
|
||||
|
||||
return ({ allModifyDynamicResArray, offset });
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最新动态信息(转发子动态)
|
||||
* 并初步整理
|
||||
@@ -307,9 +326,11 @@ class Searcher {
|
||||
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.orig_type,
|
||||
type: cur.origin_type,
|
||||
hasOfficialLottery: cur.origin_hasOfficialLottery
|
||||
})
|
||||
|
||||
@@ -320,6 +341,7 @@ class Searcher {
|
||||
|
||||
return fomatdata;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取tag下的抽奖信息(转发母动态)
|
||||
* 并初步整理
|
||||
@@ -367,7 +389,9 @@ class Searcher {
|
||||
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
|
||||
@@ -377,6 +401,7 @@ class Searcher {
|
||||
|
||||
return fomatdata
|
||||
}
|
||||
|
||||
/**
|
||||
* 从专栏中获取抽奖信息
|
||||
* @param {string} key_words
|
||||
@@ -457,7 +482,9 @@ class Searcher {
|
||||
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
|
||||
@@ -548,5 +575,4 @@ class Searcher {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module.exports = { Searcher };
|
||||
module.exports = { Searcher, parseDynamicCard };
|
||||
|
||||
@@ -100,6 +100,11 @@ const config = {
|
||||
*/
|
||||
disable_reserve_lottery: false,
|
||||
|
||||
/**
|
||||
* 不转发预约抽奖
|
||||
* - 预约抽奖可能与转发抽奖并存
|
||||
*/
|
||||
is_not_relay_reserve_lottery: false,
|
||||
|
||||
/**
|
||||
* 检查是否重复转发
|
||||
@@ -326,12 +331,22 @@ const config = {
|
||||
'坚持不懈,迎难而上,开拓创新!', '[OK][OK]', '我来抽个奖', '中中中中中中', '[doge][doge][doge]', '我我我',
|
||||
],
|
||||
|
||||
/**
|
||||
* 是否抄热评
|
||||
*/
|
||||
is_copy_chat: false,
|
||||
|
||||
/**
|
||||
* - 抽奖UP用户分组id(网页端点击分区后地址栏中的tagid)
|
||||
* - 自动获取
|
||||
*/
|
||||
partition_id: 0,
|
||||
|
||||
/**
|
||||
* - 是否不为抽奖UP单独设置关注分区
|
||||
*/
|
||||
is_not_create_partition: false,
|
||||
|
||||
/**
|
||||
* 是否关注异常
|
||||
*/
|
||||
|
||||
@@ -42,8 +42,9 @@ let global_var = {
|
||||
LotteryOrder
|
||||
.map(it => LotteryOrderMap.get(it))
|
||||
.filter(it => typeof it === "string")
|
||||
.flatMap(lottery_option => config[lottery_option]
|
||||
.map(it => [lottery_option, it])));
|
||||
.map(lottery_option => config[lottery_option].map(it => [lottery_option, it]))
|
||||
.flat()
|
||||
);
|
||||
this.set('remoteconfig', await getRemoteConfig());
|
||||
}
|
||||
await createDir('dyids');
|
||||
|
||||
+154
-4
@@ -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)
|
||||
@@ -88,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自建用户
|
||||
@@ -105,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;
|
||||
}
|
||||
@@ -125,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;
|
||||
}
|
||||
@@ -164,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),
|
||||
@@ -179,10 +206,14 @@ 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
|
||||
@@ -381,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) {
|
||||
@@ -529,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) {
|
||||
|
||||
+7
-7
@@ -17,8 +17,8 @@ async function createRandomDynamic(num) {
|
||||
[null],
|
||||
() => Searcher.checkAllDynamic(global_var.get("myUID"), 1)
|
||||
)) || { allModifyDynamicResArray: [] },
|
||||
{ type, orig_type } = allModifyDynamicResArray[0] || {};
|
||||
if (type === 1 && orig_type !== 8) {
|
||||
{ type, origin_type } = allModifyDynamicResArray[0] || {};
|
||||
if (type === 1 && origin_type !== 8) {
|
||||
await randomDynamic(num)
|
||||
} else {
|
||||
log.info('随机动态', '已有非抽奖动态故无需创建');
|
||||
@@ -34,9 +34,6 @@ async function createRandomDynamic(num) {
|
||||
function start(num) {
|
||||
return new Promise(resolve => {
|
||||
let times = utils.counter();
|
||||
if (config.notice_running_state) {
|
||||
sendNotify(`动态抽奖-帐号${num}开始抽奖`, "运行正常")
|
||||
}
|
||||
/* 注册事件 */
|
||||
event_bus.on('Turn_on_the_Monitor', async () => {
|
||||
const lotterys = global_var.get("Lottery");
|
||||
@@ -56,11 +53,14 @@ function start(num) {
|
||||
await (new Monitor(lottery)).init();
|
||||
});
|
||||
event_bus.on('Turn_off_the_Monitor', async (msg) => {
|
||||
log.info('结束抽奖', '原因: ' + msg);
|
||||
if (config.notice_running_state) {
|
||||
sendNotify(`动态抽奖-帐号${num}结束抽奖`, msg)
|
||||
sendNotify(
|
||||
`动态抽奖-帐号${num}结束抽奖`,
|
||||
`${log._cache.filter(it => /抽奖\]|Error|\s抽奖信息\]/.test(it)).join('\n')}`
|
||||
);
|
||||
}
|
||||
await createRandomDynamic(config.create_dy_num);
|
||||
log.info('结束抽奖', '原因: ' + msg);
|
||||
event_bus.flush();
|
||||
resolve();
|
||||
})
|
||||
|
||||
+2
-1
@@ -29,10 +29,11 @@ module.exports = Object.freeze({
|
||||
SESSION_SVR_UPDATE_ACK: 'https://api.vc.bilibili.com/session_svr/v1/session_svr/update_ack',
|
||||
SPACE_MYINFO: 'https://api.bilibili.com/x/space/myinfo',
|
||||
TAG_INFO: 'https://api.bilibili.com/x/tag/info',
|
||||
TOP_RCMD: "https://api.bilibili.com/x/web-interface/index/top/rcmd",
|
||||
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_SEARCH_TYPE: 'https://api.bilibili.com/x/web-interface/search/type',
|
||||
})
|
||||
@@ -1044,6 +1044,35 @@ const bili_client = {
|
||||
return 1;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 查询评论
|
||||
* @param {*} rid
|
||||
* @param {*} type
|
||||
* @returns {Promise<Array<string>>}
|
||||
*/
|
||||
async getChat(rid, type) {
|
||||
const
|
||||
responseText = await get({
|
||||
url: API.V2_REPLAY,
|
||||
query: {
|
||||
oid: rid,
|
||||
type: type,
|
||||
}
|
||||
}),
|
||||
res = strToJson(responseText);
|
||||
switch (res.code) {
|
||||
case 0:
|
||||
log.info('查询评论', `成功`);
|
||||
try {
|
||||
return res.data.replies.map(it => it.content.message);
|
||||
} catch (_) {
|
||||
return []
|
||||
}
|
||||
default:
|
||||
log.error('查询评论', `未知错误\n${responseText}`);
|
||||
return [];
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 检查分区
|
||||
* 不存在指定分区时创建
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
//@ts-check
|
||||
/**
|
||||
* @typedef {import("http").IncomingHttpHeaders} HttpHeaders 头部信息
|
||||
*
|
||||
|
||||
+52
-46
@@ -189,8 +189,8 @@ const utils = {
|
||||
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'
|
||||
,
|
||||
_iso_time: () => new Date(Date.now() + 288e5).toISOString().slice(0, -1) + '+08',
|
||||
_cache: [],
|
||||
/**
|
||||
* 初始化默认level为3
|
||||
*/
|
||||
@@ -213,10 +213,7 @@ const utils = {
|
||||
* @returns
|
||||
*/
|
||||
rainbow(msg) {
|
||||
const
|
||||
colors = ['red', 'yellow', 'green', 'cyan', 'blue', 'magenta'],
|
||||
colorsCount = colors.length;
|
||||
this.proPrint(msg.map(it => it.split('').map((l, i) => chalk[colors[i % colorsCount]](l)).join('')), '\n')
|
||||
this.proPrint(msg.map(it => it.split('').map(l => chalk.hex("#89cff0")(l)).join('')), '\n')
|
||||
},
|
||||
/**
|
||||
* @param {number} done
|
||||
@@ -232,20 +229,50 @@ const utils = {
|
||||
debug(context, msg) {
|
||||
if (this._level > 3) {
|
||||
if (msg instanceof Object) msg = JSON.stringify(msg, null, 4);
|
||||
this.proPrint([this._colors[0](`[${this._iso_time()}]`), this._colors[1]("[Debug]"), this._colors[2](`[帐号${process.env["NUMBER"]} ${context}]`), this._colors[3](`[\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([this._colors[0](`[${this._iso_time()}]`), this._colors[1]("[Info]"), this._colors[2](`[帐号${process.env["NUMBER"]} ${context}]`), this._colors[4](`[${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([this._colors[0](`[${this._iso_time()}]`), this._colors[1]("[Warn]"), this._colors[2](`[帐号${process.env["NUMBER"]} ${context}]`), this._colors[5](`[\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([this._colors[0](`[${this._iso_time()}]`), this._colors[1]("[Error]"), this._colors[2](`[帐号${process.env["NUMBER"]} ${context}]`), this._colors[6](`[\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)))
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
@@ -370,25 +397,6 @@ const utils = {
|
||||
})
|
||||
});
|
||||
},
|
||||
/**
|
||||
* deleteFolderRecursive
|
||||
* @param {*} url
|
||||
*/
|
||||
deleteFolderRecursive(url) {
|
||||
var files = [];
|
||||
if (fs.existsSync(url)) {
|
||||
files = fs.readdirSync(url);
|
||||
files.forEach(function (file) {
|
||||
var curPath = path.join(url, file);
|
||||
if (fs.statSync(curPath).isDirectory()) {
|
||||
utils.deleteFolderRecursive(curPath);
|
||||
} else {
|
||||
fs.unlinkSync(curPath);
|
||||
}
|
||||
});
|
||||
fs.rmdirSync(url);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 读取dyid文件
|
||||
* @param {number} num
|
||||
@@ -413,23 +421,20 @@ const utils = {
|
||||
* @param {import("./core/searcher").LotteryInfo[]} lottery_info
|
||||
* @return {Promise<void>}
|
||||
*/
|
||||
appendLotteryInfoFile(from, lottery_info) {
|
||||
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 = {}
|
||||
}
|
||||
utils
|
||||
.createDir(utils.lottery_info_dir)
|
||||
.then(() => {
|
||||
if (all_lottery_info[from] instanceof Array) {
|
||||
all_lottery_info[from].push(...lottery_info)
|
||||
} else {
|
||||
all_lottery_info[from] = lottery_info
|
||||
}
|
||||
utils.createFile(utils.lottery_info_dir, `lottery_info_${Number(process.env.NUMBER)}.json`, JSON.stringify(all_lottery_info), "w")
|
||||
})
|
||||
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
|
||||
@@ -449,10 +454,11 @@ const utils = {
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 清空lottery_info
|
||||
* 清空lottery_info file
|
||||
*/
|
||||
clearLotteryInfo() {
|
||||
utils.deleteFolderRecursive(utils.lottery_info_dir)
|
||||
async clearLotteryInfo() {
|
||||
await utils.createDir(utils.lottery_info_dir);
|
||||
await utils.createFile(utils.lottery_info_dir, `lottery_info_${Number(process.env.NUMBER)}.json`, "{}", "w")
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ let loop_wait = 0;
|
||||
* @returns {Promise<string>} 错误信息
|
||||
*/
|
||||
async function main() {
|
||||
const { COOKIE, NOTE, NUMBER, CLEAR, ENABLE_MULTIPLE_ACCOUNT, MULTIPLE_ACCOUNT_PARM } = process.env;
|
||||
const { COOKIE, NUMBER, CLEAR, ENABLE_MULTIPLE_ACCOUNT, MULTIPLE_ACCOUNT_PARM } = process.env;
|
||||
if (ENABLE_MULTIPLE_ACCOUNT) {
|
||||
let muti_acco = multiple_account.length
|
||||
? multiple_account
|
||||
@@ -52,21 +52,25 @@ async function main() {
|
||||
const { start, isMe, clear, 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 } = require("./lib/data/config");
|
||||
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;
|
||||
if (save_lottery_info_to_file) {
|
||||
await clearLotteryInfo()
|
||||
}
|
||||
await start(NUMBER);
|
||||
break;
|
||||
case 'check':
|
||||
log.info('中奖检测', '检查是否中奖');
|
||||
loop_wait = check_loop_wait;
|
||||
await isMe(NUMBER, NOTE);
|
||||
await isMe(NUMBER);
|
||||
break;
|
||||
case 'clear':
|
||||
if (CLEAR) {
|
||||
@@ -158,13 +162,11 @@ function initConfig() {
|
||||
log.warn('结束运行', '5秒后自动退出');
|
||||
await delay(5 * 1000);
|
||||
} else {
|
||||
clearLotteryInfo();
|
||||
while (loop_wait) {
|
||||
log.info('程序休眠', `${loop_wait / 1000}秒后再次启动`)
|
||||
await delay(loop_wait)
|
||||
if (initEnv() || initConfig()) return;
|
||||
await main()
|
||||
clearLotteryInfo();
|
||||
}
|
||||
log.info('结束运行', '未在config.js中设置休眠时间')
|
||||
}
|
||||
|
||||
@@ -102,6 +102,12 @@ module.exports = Object.freeze({
|
||||
*/
|
||||
disable_reserve_lottery: false,
|
||||
|
||||
/**
|
||||
* 不转关预约抽奖
|
||||
* - 预约抽奖可能与转发抽奖并存
|
||||
*/
|
||||
is_not_relay_reserve_lottery: false,
|
||||
|
||||
/**
|
||||
* 检查是否重复转发
|
||||
* - 不检查 -1
|
||||
@@ -332,12 +338,22 @@ module.exports = Object.freeze({
|
||||
'坚持不懈,迎难而上,开拓创新!', '[OK][OK]', '我来抽个奖', '中中中中中中', '[doge][doge][doge]', '我我我',
|
||||
],
|
||||
|
||||
/**
|
||||
* 是否抄热评
|
||||
*/
|
||||
is_copy_chat: false,
|
||||
|
||||
/**
|
||||
* - 抽奖UP用户分组id(网页端点击分区后地址栏中的tagid)
|
||||
* - 自动获取
|
||||
*/
|
||||
partition_id: 0,
|
||||
|
||||
/**
|
||||
* - 是否不为抽奖UP单独设置关注分区
|
||||
*/
|
||||
is_not_create_partition: false,
|
||||
|
||||
/**
|
||||
* 是否关注异常
|
||||
*/
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "lottery-auto-script",
|
||||
"version": "2.6.5",
|
||||
"version": "2.7.2",
|
||||
"description": "自动参与B站动态抽奖",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
||||
+8
-2
@@ -5,10 +5,12 @@ const util = require('./util');
|
||||
(async () => {
|
||||
assert(await bili_client.getMyinfo());
|
||||
|
||||
await util.par_run([
|
||||
await util.par_run([0, 1, 2, 3, 4], [
|
||||
// 0
|
||||
async () => {
|
||||
assert.equal((await bili_client.getTopRcmd()).length, 10)
|
||||
},
|
||||
// 1
|
||||
async () => {
|
||||
assert.equal(await bili_client.sendChat(
|
||||
(await bili_client.getOneDynamicByDyid("692193323569381399")).desc.rid,
|
||||
@@ -17,6 +19,7 @@ const util = require('./util');
|
||||
7
|
||||
)
|
||||
},
|
||||
// 2
|
||||
async () => {
|
||||
assert.equal(await bili_client.sendChat(
|
||||
(await bili_client.getOneDynamicByDyid("11229466874154064")).desc.rid,
|
||||
@@ -25,14 +28,17 @@ const util = require('./util');
|
||||
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("123"))
|
||||
assert(!await bili_client.createDynamic("1"))
|
||||
}
|
||||
])
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
const assert = require('assert');
|
||||
const bili_client = require("../lib/net/bili");
|
||||
const searcher = require("../lib/core/searcher");
|
||||
const util = require('./util');
|
||||
|
||||
(async () => {
|
||||
assert(await bili_client.getMyinfo());
|
||||
|
||||
await util.par_run([0, 1, 2, 3], [
|
||||
// 0
|
||||
async () => {
|
||||
let info = await bili_client.getOneDynamicByDyid("728424890210713624");
|
||||
assert(searcher.parseDynamicCard(info).is_charge_lottery);
|
||||
},
|
||||
// 1
|
||||
async () => {
|
||||
let info = await bili_client.getOneDynamicByDyid("728455586333589522");
|
||||
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] == "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)
|
||||
},
|
||||
])
|
||||
|
||||
|
||||
|
||||
|
||||
console.log("dynamic_card.test ... ok!");
|
||||
})()
|
||||
+5
-2
@@ -1,8 +1,11 @@
|
||||
/**
|
||||
* @param {Array<number>} nums
|
||||
* @param {Array<()=>any>} fns
|
||||
*/
|
||||
function par_run(fns) {
|
||||
return Promise.all((fns.map(fn => fn())))
|
||||
function par_run(nums, fns) {
|
||||
return Promise.all(
|
||||
nums.map(num => fns[num]())
|
||||
)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
Reference in New Issue
Block a user