Compare commits

...
18 Commits
Author SHA1 Message Date
shanmite 73f04a357a docs: 更新CHANGELOG 2022-06-24 11:08:41 +08:00
shanmite 2742dcbd4f feat: 清理动态加入错误重试(#140)
fixed: #140
2022-06-24 11:07:48 +08:00
shanmite 329c5e506f feat: 自动参与预约抽奖(#155)
fixed #155
2022-06-24 10:27:11 +08:00
shanmite 3bc7dafe3e doc: 图片换源gitlab 2022-05-21 17:02:01 +08:00
shanmite 23432edb74 docs: 更新CHANGELOG 2022-05-21 16:36:07 +08:00
shanmite df7b3210a3 fix: 远程设置换源gitlab 2022-05-21 16:35:26 +08:00
shanmite 31e8941415 docs: 更新CHANGELOG 2022-05-03 10:01:55 +08:00
shanmite f329457c9a fix: 评论包含敏感词(#150)
Fixed #150
2022-05-03 09:55:53 +08:00
shanmiteandGitHub 0eddee4f15 Merge pull request #147 from spiritLHLS/patch-1
更换仓库地址
2022-04-11 09:21:36 +08:00
spiritLHLSandGitHub ce2c9e58dd Update README.md
备份迁移至此号
2022-04-11 09:10:09 +08:00
spiritLHLSandGitHub f1bbc9d1da Update README.md
备份迁移至此号
2022-04-11 08:53:58 +08:00
shanmite 29bb2f32a3 docs: 更新CHANGELOG 2022-03-23 15:58:12 +08:00
shanmite 22e4d2aaa1 fix: 转发了不含关键词的抽奖动态(#136)
Fixed #136
2022-03-23 15:04:59 +08:00
shanmite 354d8cff1a fix: 推送异常(#132)
Fixed #132
2022-03-22 15:02:59 +08:00
shanmite 1b80f853ed docs: 更新CHANGELOG 2022-03-02 19:49:10 +08:00
shanmite b1f478cb8e feat: 可选通知现阶段运行到哪个账号(#132)
新增设置`notice_running_state`
 Fixed #132
2022-03-02 19:44:27 +08:00
shanmite 39d69e0448 docs: 更新CHANGELOG 2022-03-01 21:17:53 +08:00
shanmite 45ac58e312 fix: 评论与转发相同时去掉动态原文(#128)
Fixed #128
2022-03-01 21:08:33 +08:00
17 changed files with 182 additions and 61 deletions
+37
View File
@@ -1,5 +1,42 @@
<!-- markdownlint-disable MD036 MD024-->
# CHANGELOG
## 主要变化(2.5.6)
* 2742dcb feat: 清理动态加入错误重试(#140)
* 329c5e5 feat: 自动参与预约抽奖(#155)
* 3bc7daf doc: 图片换源gitlab
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
## 主要变化(2.5.5)
* df7b321 fix: 远程设置换源gitlab
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
## 主要变化(2.5.4)
* f329457 fix: 评论包含敏感词(#150)
* 0eddee4 Merge pull request #147 from spiritLHLS/patch-1
* ce2c9e5 Update README.md
* f1bbc9d Update README.md
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
## 主要变化(2.5.3)
* 22e4d2a fix: 转发了不含关键词的抽奖动态(#136)
* 354d8cf fix: 推送异常(#132)
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
## 主要变化(2.5.2)
* b1f478c feat: 可选通知现阶段运行到哪个账号(#132)
* 新增设置`notice_running_state`
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
## 主要变化(2.5.1)
* 45ac58e fix: 评论与转发相同时去掉动态原文(#128)
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
## 主要变化(2.5.0)
* 41b9540 fix: 未知错误退出
+33 -32
View File
@@ -28,6 +28,7 @@
- 监控话题页面
- 监控专栏合集
- 自动点赞、评论、乱序转发、@好友、带话题、可选随机动态
- 直播预约抽奖
- 检测是否中奖
- 已读@
- 已读私信
@@ -59,7 +60,7 @@ Chrome浏览器:
(此步骤是为了方便后续采用JS获取Cookies,获取完毕后应再次勾选)
![取消httponly](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/getCookies.png)
![取消httponly](https://gitlab.com/shanmiteko/LotteryAutoScript/-/raw/main/doc/pic/getCookies.png)
3. 在Console中复制以下代码回车
@@ -126,7 +127,7 @@ Chrome浏览器:
```
7. 运行截图
![lottery_start](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/lottery_start.png)
![lottery_start](https://gitlab.com/shanmiteko/LotteryAutoScript/-/raw/main/doc/pic/lottery_start.png)
#### 以源码方式运行
@@ -140,7 +141,7 @@ step1: 下载代码到本地
[点此下载](https://github.com/shanmiteko/LotteryAutoScript/archive/refs/heads/main.zip)或如图示下载↓
![点我加载下载操作图示](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/download.png)
![点我加载下载操作图示](https://gitlab.com/shanmiteko/LotteryAutoScript/-/raw/main/doc/pic/download.png)
下载的压缩包解压后修改env.example.js文件,详见step3
@@ -148,7 +149,7 @@ step2: 下载并安装Node.js
[点此进入nodejs下载页面](http://nodejs.cn/download)
![点我加载下载nodejs操作图示](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/nodejs.png)
![点我加载下载nodejs操作图示](https://gitlab.com/shanmiteko/LotteryAutoScript/-/raw/main/doc/pic/nodejs.png)
step3:修改env.example.js文件及创建运行文件(打开扩展名显示)
@@ -266,31 +267,31 @@ $ tree
以下是支持的推送方式
| Name | 归属 | 说明 |
| :---------------: | :--------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `SCKEY` | 微信server酱推送(于2021/4月下线) | server酱的微信通知[官方文档](http://sc.ftqq.com/3.version) |
| `SENDKEY` | 微信server酱(Turbo版)推送 | [获取SENDKEY](https://sct.ftqq.com/sendkey) [选择消息通道](https://sct.ftqq.com/forward) |
| `BARK_PUSH` | [BARK推送](https://apps.apple.com/us/app/bark-customed-notifications/id1403753865) | IOS用户下载BARK这个APP,填写内容是app提供的`设备码`,例如:<https://api.day.app/123> ,那么此处的设备码就是`123`,再不懂看 [这个图](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/bark.jpg)(注:支持自建填完整链接即可) |
| `BARK_SOUND` | [BARK推送](https://apps.apple.com/us/app/bark-customed-notifications/id1403753865) | bark推送声音设置,例如`choo`,具体值请在`bark`-`推送铃声`-`查看所有铃声` |
| `TG_BOT_TOKEN` | telegram推送 | tg推送(需设备可连接外网),`TG_BOT_TOKEN`和`TG_USER_ID`两者必需,填写自己申请[@BotFather](https://t.me/BotFather)的Token,如`10xxx4:AAFcqxxxxgER5uw` , [具体教程](doc/TG_PUSH.md) |
| `TG_USER_ID` | telegram推送 | tg推送(需设备可连接外网),`TG_BOT_TOKEN`和`TG_USER_ID`两者必需,填写[@getuseridbot](https://t.me/getuseridbot)中获取到的纯数字ID, [具体教程](doc/TG_PUSH.md) |
| `TG_PROXY_HOST` | Telegram 代理的 IP | 代理类型为 http。例子:http代理 <http://127.0.0.1:1080> 则填写 127.0.0.1 |
| `TG_PROXY_PORT` | Telegram 代理的端口 | 例子:http代理 <http://127.0.0.1:1080> 则填写 1080 |
| `DD_BOT_TOKEN` | 钉钉推送 | 钉钉推送(`DD_BOT_TOKEN`和`DD_BOT_SECRET`两者必需)[官方文档](https://ding-doc.dingtalk.com/doc#/serverapi2/qf2nxq) ,只需`https://oapi.dingtalk.com/robot/send?access_token=XXX` 等于`=`符号后面的XXX即可 |
| `DD_BOT_SECRET` | 钉钉推送 | (`DD_BOT_TOKEN`和`DD_BOT_SECRET`两者必需) ,密钥,机器人安全设置页面,加签一栏下面显示的SEC开头的`SECXXXXXXXXXX`等字符 , 注:钉钉机器人安全设置只需勾选`加签`即可,其他选项不要勾选,再不懂看 [这个图](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/DD_bot.png) |
| `IGOT_PUSH_KEY` | iGot推送 | iGot聚合推送,支持多方式推送,确保消息可达。 [参考文档](https://wahao.github.io/Bark-MP-helper ) |
| `QQ_SKEY` | 酷推(Cool Push)推送 | 推送所需的Skey,登录后获取Skey [参考文档](https://cp.xuthus.cc/) |
| `QQ_MODE` | 酷推(Cool Push)推送 | 推送方式(send或group或者wx,默认send) [参考文档](https://cp.xuthus.cc/) |
| `QYWX_KEY` | 企业微信推送 | 密钥,企业微信推送 webhook 后面的 key [详见官方说明文档](https://work.weixin.qq.com/api/doc/90000/90136/91770) |
| `PUSH_PLUS_TOKEN` | pushplus推送 | 微信扫码登录后一对一推送或一对多推送下面的token(您的Token) [官方网站](http://pushplus.hxtrip.com/) |
| `PUSH_PLUS_USER` | pushplus推送 | 一对多推送的“群组编码”(一对多推送下面->您的群组(如无则新建)->群组编码)注:(1、需订阅者扫描二维码 2、如果您是创建群组所属人,也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送),只填`PUSH_PLUS_TOKEN`默认为一对一推送 |
| `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://gitlab.com/shanmiteko/LotteryAutoScript/-/raw/main/doc/pic/bark.jpg)(注:支持自建填完整链接即可) |
| `BARK_SOUND` | [BARK推送](https://apps.apple.com/us/app/bark-customed-notifications/id1403753865) | bark推送声音设置,例如`choo`,具体值请在`bark`-`推送铃声`-`查看所有铃声` |
| `TG_BOT_TOKEN` | telegram推送 | tg推送(需设备可连接外网),`TG_BOT_TOKEN`和`TG_USER_ID`两者必需,填写自己申请[@BotFather](https://t.me/BotFather)的Token,如`10xxx4:AAFcqxxxxgER5uw` , [具体教程](doc/TG_PUSH.md) |
| `TG_USER_ID` | telegram推送 | tg推送(需设备可连接外网),`TG_BOT_TOKEN`和`TG_USER_ID`两者必需,填写[@getuseridbot](https://t.me/getuseridbot)中获取到的纯数字ID, [具体教程](doc/TG_PUSH.md) |
| `TG_PROXY_HOST` | Telegram 代理的 IP | 代理类型为 http。例子:http代理 <http://127.0.0.1:1080> 则填写 127.0.0.1 |
| `TG_PROXY_PORT` | Telegram 代理的端口 | 例子:http代理 <http://127.0.0.1:1080> 则填写 1080 |
| `DD_BOT_TOKEN` | 钉钉推送 | 钉钉推送(`DD_BOT_TOKEN`和`DD_BOT_SECRET`两者必需)[官方文档](https://ding-doc.dingtalk.com/doc#/serverapi2/qf2nxq) ,只需`https://oapi.dingtalk.com/robot/send?access_token=XXX` 等于`=`符号后面的XXX即可 |
| `DD_BOT_SECRET` | 钉钉推送 | (`DD_BOT_TOKEN`和`DD_BOT_SECRET`两者必需) ,密钥,机器人安全设置页面,加签一栏下面显示的SEC开头的`SECXXXXXXXXXX`等字符 , 注:钉钉机器人安全设置只需勾选`加签`即可,其他选项不要勾选,再不懂看 [这个图](https://gitlab.com/shanmiteko/LotteryAutoScript/-/raw/main/doc/pic/DD_bot.png) |
| `IGOT_PUSH_KEY` | iGot推送 | iGot聚合推送,支持多方式推送,确保消息可达。 [参考文档](https://wahao.github.io/Bark-MP-helper ) |
| `QQ_SKEY` | 酷推(Cool Push)推送 | 推送所需的Skey,登录后获取Skey [参考文档](https://cp.xuthus.cc/) |
| `QQ_MODE` | 酷推(Cool Push)推送 | 推送方式(send或group或者wx,默认send) [参考文档](https://cp.xuthus.cc/) |
| `QYWX_KEY` | 企业微信推送 | 密钥,企业微信推送 webhook 后面的 key [详见官方说明文档](https://work.weixin.qq.com/api/doc/90000/90136/91770) |
| `PUSH_PLUS_TOKEN` | pushplus推送 | 微信扫码登录后一对一推送或一对多推送下面的token(您的Token) [官方网站](http://pushplus.hxtrip.com/) |
| `PUSH_PLUS_USER` | pushplus推送 | 一对多推送的“群组编码”(一对多推送下面->您的群组(如无则新建)->群组编码)注:(1、需订阅者扫描二维码 2、如果您是创建群组所属人,也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送),只填`PUSH_PLUS_TOKEN`默认为一对一推送 |
| `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` | 电子邮件 | 接收方电子邮件 |
----------------------------------------
@@ -303,6 +304,6 @@ $ tree
## Awesome
相关项目
- [LotteryAutoScript_Station](https://github.com/spiritLHL/LotteryAutoScript_Station) - [@spiritLHL](https://github.com/spiritLHL)
- [sync_lottery](https://github.com/spiritLHL/sync_lottery) - [@spiritLHL](https://github.com/spiritLHL)
- [BDSF](https://github.com/spiritLHL/BDSF) - [@spiritLHL](https://github.com/spiritLHL)
- [LotteryAutoScript_Station](https://github.com/spiritLHLS/LotteryAutoScript_Station) - [@spiritLHL](https://github.com/spiritLHLS)
- [sync_lottery](https://github.com/spiritLHLS/sync_lottery) - [@spiritLHL](https://github.com/spiritLHLS)
- [BDSF](https://github.com/spiritLHLS/BDSF) - [@spiritLHL](https://github.com/spiritLHLS)
+3 -3
View File
@@ -4,16 +4,16 @@
.首先在Telegram上搜索[BotFather](https://t.me/BotFather)机器人<br>
![TG_PUSH1](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/TG_PUSH1.png)
![TG_PUSH1](https://gitlab.com/shanmiteko/LotteryAutoScript/-/raw/main/doc/pic/TG_PUSH1.png)
Ⅱ.利用[BotFather](https://t.me/BotFather)创建一个属于自己的通知机器人,按照下图中的1、2、3步骤拿到token,格式形如```10xxx4:AAFcqxxxxgER5uw```。填入```TG_BOT_TOKEN```<br>
![TG_PUSH2](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/TG_PUSH2.png)<br>
![TG_PUSH2](https://gitlab.com/shanmiteko/LotteryAutoScript/-/raw/main/doc/pic/TG_PUSH2.png)<br>
**新创建的机器人需要跟它发一条消息来开启对话,否则可能会遇到secret填对了但是收不到消息的情况**<br>
Ⅲ.再次在Telegram上搜索[getuserIDbot](https://t.me/getuserIDbot)机器人,获取UserID。填入```TG_USER_ID```<br>
![TG_PUSH3](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/TG_PUSH3.png)
![TG_PUSH3](https://gitlab.com/shanmiteko/LotteryAutoScript/-/raw/main/doc/pic/TG_PUSH3.png)
至此,获取**TG_BOT_TOKEN**以及**TG_USER_ID**的教程结束
+1 -1
View File
@@ -73,7 +73,7 @@ PATH=/sbin:/bin:/usr/sbin/:/usr/bin
看看有没有效果
![image-start](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/image-start.png)
![image-start](https://gitlab.com/shanmiteko/LotteryAutoScript/-/raw/main/doc/pic/image-start.png)
7.如果本地的脚本需要更新
+3 -3
View File
@@ -16,13 +16,13 @@
7.在`操作`页面中点击`新建`,选择操作为`启动程序`,在设置里点击浏览找到`start.bat`文件并选择,在`起始于(可选)(T)`中的空白框里输入`start.bat`文件的目录地址,也就是`程序或脚本(P)``start.bat`的前面那一串目录地址,最后是以`\`结尾的 ,填好东西后按下面`确认`
![点我加载步骤7结果图示](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/step_menu.png)
![点我加载步骤7结果图示](https://gitlab.com/shanmiteko/LotteryAutoScript/-/raw/main/doc/pic/step_menu.png)
8.在`条件`页面中选择`网络`,设定启动条件为任何连接
9.在`设置`页面中选择如图示选项,或者不修改默认设置
![点我加载步骤9结果图示](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/shezhi_renwu.png)
![点我加载步骤9结果图示](https://gitlab.com/shanmiteko/LotteryAutoScript/-/raw/main/doc/pic/shezhi_renwu.png)
10.最后按`确定`
@@ -30,6 +30,6 @@
最后你可以在任务列表中选择已有的任务,右边的操作框中选择`运行`点击,启动计划的任务,如下图所示
![点我加载运行图示](https://gitee.com/shanmite/LotteryAutoScript/raw/main/doc/pic/start_renwu.png)
![点我加载运行图示](https://gitlab.com/shanmiteko/LotteryAutoScript/-/raw/main/doc/pic/start_renwu.png)
具体看任务是否正常执行,你可以看看自己的账号动态的最新转发,运行成功每几分钟自动转发抽奖动态
+9 -5
View File
@@ -1,4 +1,4 @@
const { log, delay, infiniteNumber } = require("./utils");
const { log, delay, infiniteNumber, retryfn } = require("./utils");
const bili = require("./net/bili");
const { Searcher } = require("./core/searcher");
const global_var = require('./data/global_var');
@@ -46,7 +46,7 @@ async function clear() {
for (const [index, uid] of uid_list.entries()) {
log.info('清理关注', `(${index}) (${uid})`)
/* 取消关注 */
if (await bili.cancelAttention(uid)) {
if (await retryfn(3, [false], () => bili.cancelAttention(uid))) {
log.info('清理关注', '成功')
} else {
log.error('清理关注', '失败')
@@ -65,7 +65,11 @@ async function clear() {
for (const page of infiniteNumber()) {
log.info('清理动态', `开始读取第${page + 1}`);
const { allModifyDynamicResArray, offset } = await Searcher.checkAllDynamic(MY_UID, 1, search_wait, next_offset);
const { allModifyDynamicResArray = [], offset = '0' } = await retryfn(
3,
[null],
() => Searcher.checkAllDynamic(MY_UID, 1, search_wait, next_offset)
);
next_offset = offset;
for (const [index, dyinfo] of allModifyDynamicResArray.entries()) {
log.info('清理动态', `${page + 1}页中的第${index + 1}个动态`)
@@ -82,7 +86,7 @@ async function clear() {
if (dynamic_id
&& clear_remove_dynamic
&& !(new RegExp(dynamic_id).test(clear_white_list))) {
success = await bili.rmDynamic(dynamic_id)
success = await retryfn(3, [false], () => bili.rmDynamic(dynamic_id))
}
/* 取消关注 */
@@ -91,7 +95,7 @@ async function clear() {
&& clear_remove_attention
&& before_separate.indexOf(origin_uid) === -1
&& uid_list.indexOf(origin_uid) > -1) {
success = await bili.cancelAttention(origin_uid);
success = await retryfn(3, [false], () => bili.cancelAttention(origin_uid))
}
if (!success) {
+15 -2
View File
@@ -303,7 +303,7 @@ class Monitor extends Searcher {
await try_for_each(protoLotteryInfo, async function (lottery_info) {
const {
lottery_info_type, is_liked,
uids, uname, dyid, create_time,
uids, uname, dyid, reserve_id, create_time,
ctrl, rid, des, type,
hasOfficialLottery
} = lottery_info;
@@ -375,6 +375,7 @@ class Monitor extends Searcher {
if (!has_key_words && description) {
log.warn("筛选动态", `无关键词动态的描述: ${description}\n\n考虑是否修改设置key_words:\n${key_words.join('\n')}`)
return false
}
/**屏蔽词 */
@@ -404,6 +405,10 @@ class Monitor extends Searcher {
return false
}
if (reserve_id) {
await bili.reserve_lottery(reserve_id)
}
if (isLottery) {
const { uname_map = {} } = global_var.get("remoteconfig")
let onelotteryinfo = {};
@@ -539,11 +544,19 @@ class Monitor extends Searcher {
[1, 4],
() => bili.sendChat(
rid,
is_repost_then_chat ? relay_chat : chat,
is_repost_then_chat ? relay_chat.split('//')[0] : chat,
chat_type
)
)
if (status === 8) {
status = await bili.sendChat(
rid,
"[doge]",
chat_type
)
}
if (status) {
log.warn("抽奖信息", `dyid: ${dyid}, rid: ${rid}, chat_type: ${chat_type}`)
return 1000 + status
+22 -4
View File
@@ -18,6 +18,7 @@ const { log } = utils
* @property {string} dynamic_id
* @property {number} type
* @property {string} description
* @property {number} reserve_id
* @property {boolean} hasOfficialLottery
* @property {Array<Object.<string,string|number>>} ctrl
* @property {number} origin_create_time 10
@@ -27,6 +28,7 @@ const { log } = utils
* @property {string} origin_dynamic_id
* @property {number} orig_type
* @property {string} origin_description
* @property {number} origin_reserve_id
* @property {boolean} origin_hasOfficialLottery
*
* 整理后的抽奖信息
@@ -38,6 +40,7 @@ const { log } = utils
* @property {string} uname
* @property {Array<{}>} ctrl
* @property {string} dyid
* @property {number} reserve_id
* @property {string} rid
* @property {string} des
* @property {number} type
@@ -53,6 +56,7 @@ function parseDynamicCard(dynamic_detail_card) {
const { desc, card, extension, extend_json } = dynamic_detail_card
, { is_liked = 1, user_profile = {} } = desc
, { info = {} } = user_profile
, extendjsonToJson = strToJson(extend_json)
, cardToJson = strToJson(card)
, { item } = cardToJson;
/* 转发者的UID */
@@ -72,7 +76,12 @@ function parseDynamicCard(dynamic_detail_card) {
/* 转发者的动态ID !!!!此为大数需使用字符串值,不然JSON.parse()会有丢失精度 */
obj.dynamic_id = desc.dynamic_id_str;
/* 定位@信息 */
obj.ctrl = (extend_json && strToJson(extend_json).ctrl) || [];
obj.ctrl = (extendjsonToJson.ctrl) || [];
/* 预约抽奖信息 */
if (extendjsonToJson.reserve) {
let { reserve_id, reserve_lottery } = extendjsonToJson.reserve;
obj.reserve_id = reserve_lottery === 1 ? reserve_id : 0;
}
/* 是否有官方抽奖 */
obj.hasOfficialLottery = extension && extension.lott && true;
/* 转发者的描述 纯文字内容 图片动态描述 后两个分别是视频动态的描述和视频本身的描述*/
@@ -81,8 +90,9 @@ function parseDynamicCard(dynamic_detail_card) {
|| (cardToJson.dynamic || '' + cardToJson.desc || '')
|| '';
if (obj.type === 1) {
const { origin_extension, origin } = cardToJson
const { origin_extension, origin, origin_extend_json } = cardToJson
, originToJson = strToJson(origin)
, originextendjsonToJson = strToJson(origin_extend_json)
, { user, item } = originToJson;
/* 源动态的ts10 */
obj.origin_create_time = desc.origin.timestamp;
@@ -92,6 +102,11 @@ function parseDynamicCard(dynamic_detail_card) {
obj.origin_rid_str = desc.origin.rid_str.length > 12 ? desc.origin.dynamic_id_str : desc.origin.rid_str;
/* 被转发者的动态的ID !!!!此为大数需使用字符串值,不然JSON.parse()会有丢失精度 */
obj.origin_dynamic_id = desc.orig_dy_id_str;
/* 预约抽奖信息 */
if (originextendjsonToJson.reserve) {
let { reserve_id, reserve_lottery } = originextendjsonToJson.reserve;
obj.origin_reserve_id = reserve_lottery === 1 ? reserve_id : 0;
}
/* 是否有官方抽奖 */
obj.origin_hasOfficialLottery = origin_extension && origin_extension.lott;
/* 被转发者的name */
@@ -161,7 +176,7 @@ class Searcher {
* @param {number} pages 读取页数
* @param {number} time 时延
* @param {string} [offset] 默认'0'
* @returns {Promise<{allModifyDynamicResArray: UsefulDynamicInfo[], offset: string}>} 获取前 `pages*12` 个动态信息
* @returns {Promise<{allModifyDynamicResArray: UsefulDynamicInfo[], offset: string} | null>} 获取前 `pages*12` 个动态信息
*/
static async checkAllDynamic(hostuid, pages, time = 0, offset = '0') {
log.info('检查所有动态', `准备读取${pages}页动态`);
@@ -190,7 +205,7 @@ class Searcher {
mDRdata = modifyDynamicRes(OneDynamicInfo);
if (mDRdata === null) {
break;
return null
}
const
@@ -263,6 +278,7 @@ class Searcher {
uname: cur.origin_uname,
ctrl: [],
dyid: cur.origin_dynamic_id,
reserve_id: cur.origin_reserve_id,
rid: cur.origin_rid_str,
des: cur.origin_description,
type: cur.orig_type,
@@ -321,6 +337,7 @@ class Searcher {
uname: o.uname,
ctrl: o.ctrl,
dyid: o.dynamic_id,
reserve_id: o.reserve_id,
rid: o.rid_str,
des: o.description,
type: o.type,
@@ -409,6 +426,7 @@ class Searcher {
uname: o.uname,
ctrl: o.ctrl,
dyid: o.dynamic_id,
reserve_id: o.reserve_id,
rid: o.rid_str,
des: o.description,
type: o.type,
+5
View File
@@ -317,6 +317,11 @@ const config = {
"~你预约的直播已开始"
],
/**
* 是否发送运行状态通知
*/
notice_running_state: false,
/**
* - 获取私信页数
*/
+10 -3
View File
@@ -5,6 +5,7 @@ const { Searcher } = require('./core/searcher');
const { Monitor } = require('./core/monitor');
const config = require('./data/config');
const { randomDynamic } = require('./helper/randomDynamic');
const { sendNotify } = require('./helper/notify');
const { log } = utils;
async function createRandomDynamic(num) {
@@ -23,18 +24,21 @@ async function createRandomDynamic(num) {
/**
* 抽奖主函数
* @param {string} cookie
* @param {string} num
* @returns {Promise<void>}
*/
function start() {
function start(num) {
return new Promise(resolve => {
let times = utils.counter();
if (config.notice_running_state) {
sendNotify(`动态抽奖-帐号${num}开始抽奖`, "运行正常")
}
/* 注册事件 */
event_bus.on('Turn_on_the_Monitor', async () => {
const lotterys = global_var.get("Lottery");
if (lotterys.length === 0) {
log.info('抽奖', '抽奖信息为空');
resolve();
event_bus.emit('Turn_off_the_Monitor', '抽奖信息为空')
return;
}
if (times.value() === lotterys.length) {
@@ -48,6 +52,9 @@ function start() {
await (new Monitor(lottery)).init();
});
event_bus.on('Turn_off_the_Monitor', async (msg) => {
if (config.notice_running_state) {
sendNotify(`动态抽奖-帐号${num}结束抽奖`, msg)
}
await createRandomDynamic(config.create_dy_num);
log.info('结束抽奖', '原因: ' + msg);
event_bus.flush();
+2 -1
View File
@@ -1,5 +1,6 @@
module.exports = Object.freeze({
DYNAMIC_LIKE_THUMB: 'https://api.vc.bilibili.com/dynamic_like/v1/dynamic_like/thumb',
DYNAMIC_MIX_RESERVE_ATTACH_CARD_BUTTON: 'https://api.vc.bilibili.com/dynamic_mix/v1/dynamic_mix/reserve_attach_card_button',
DYNAMIC_REPOST_REPOST: 'https://api.vc.bilibili.com/dynamic_repost/v1/dynamic_repost/repost',
DYNAMIC_REPOST_SHARE: 'https://api.vc.bilibili.com/dynamic_repost/v1/dynamic_repost/share',
DYNAMIC_SVR_CREATE_DRAW: 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/create_draw',
@@ -7,9 +8,9 @@ module.exports = Object.freeze({
DYNAMIC_SVR_GET_DYNAMIC_DETAIL: 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/get_dynamic_detail',
DYNAMIC_SVR_RM_DYNAMIC: 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/rm_dynamic',
DYNAMIC_SVR_SPACE_HISTORY: 'https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/space_history',
FETCH_SESSION_MSGS: 'https://api.vc.bilibili.com/svr_sync/v1/svr_sync/fetch_session_msgs',
FEED_GET_ATTENTION_LIST: 'https://api.vc.bilibili.com/feed/v1/feed/get_attention_list',
FEED_SETUSERFOLLOW: 'https://api.vc.bilibili.com/feed/v1/feed/SetUserFollow',
FETCH_SESSION_MSGS: 'https://api.vc.bilibili.com/svr_sync/v1/svr_sync/fetch_session_msgs',
LOTTERY_SVR_LOTTERY_NOTICE: 'https://api.vc.bilibili.com/lottery_svr/v1/lottery_svr/lottery_notice',
MSGFEED_AT: 'https://api.bilibili.com/x/msgfeed/at',
MSGFEED_REPLAY: 'https://api.bilibili.com/x/msgfeed/reply',
+30 -1
View File
@@ -817,6 +817,31 @@ const bili_client = {
return 1;
}
},
/**
* 预约抽奖
* @param {number} reserve_id
* @returns
*/
async reserve_lottery(reserve_id) {
const
responseText = await post({
url: API.DYNAMIC_MIX_RESERVE_ATTACH_CARD_BUTTON,
contents: {
cur_btn_status: "1",
reserve_id,
csrf: GlobalVar.get("csrf")
}
}),
res = strToJson(responseText);
switch (res.code) {
case 0:
log.info('预约抽奖', '预约成功');
return 0;
default:
log.error('预约抽奖', `未知错误\n${responseText}`);
return 1;
}
},
/**
* @typedef Picture
* @property {string} img_src
@@ -951,6 +976,7 @@ const bili_client = {
* - 已被对方拉入黑名单 5
* - 黑名单用户无法互动 6
* - UP主已关闭评论区 7
* - 评论内容包含敏感信息 8
*/
async sendChat(rid, msg, type) {
const
@@ -966,7 +992,7 @@ const bili_client = {
res = strToJson(responseText);
switch (res.code) {
case 0:
log.info('自动评论', '评论成功');
log.info('自动评论', `评论成功: ${msg}`);
return 0;
case -404:
log.error('自动评论', '原动态已删除');
@@ -986,6 +1012,9 @@ const bili_client = {
case 12061:
log.error('自动评论', 'UP主已关闭评论区');
return 7;
case 12016:
log.error('自动评论', '评论内容包含敏感信息');
return 8;
default:
log.error('自动评论', `未知错误\n${responseText}`);
return 1;
+3 -3
View File
@@ -64,6 +64,7 @@ const utils = {
* @param {number} max_times
* @param {Array<T>} unexpected
* @param {() => Promise<T>} fn
* @return {Promise<T | null>}
*/
async retryfn(max_times, unexpected, fn) {
let ret = null;
@@ -291,11 +292,9 @@ const utils = {
return new Promise((resolve) => {
send({
method: 'GET',
url: 'https://gitee.com/shanmite/lottery-notice/raw/master/notice.json',
url: 'https://gitlab.com/shanmiteko/lottery-notice/-/raw/master/notice.json',
headers: {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36',
accept: 'text/plain; charset=utf-8',
referer: 'https://gitee.com/shanmite/lottery-notice/blob/master/notice.json',
},
success: res => {
try {
@@ -303,6 +302,7 @@ const utils = {
if (body.node_msg) utils.log.info('公告', '\n' + body.node_msg + '\n');
resolve(body.config)
} catch (error) {
utils.log.error('获取远程设置', '获取远程设置错误: ' + error);
resolve({})
}
},
+1 -1
View File
@@ -61,7 +61,7 @@ async function main() {
case 'start':
log.info('抽奖', '开始运行');
loop_wait = lottery_loop_wait;
await start();
await start(NUMBER);
break;
case 'check':
log.info('中奖检测', '检查是否中奖');
+6
View File
@@ -38,6 +38,7 @@ module.exports = Object.freeze({
* @property {string} uname
* @property {Array<{}>} ctrl
* @property {string} dyid
* @property {number} reserve_id
* @property {string} rid
* @property {string} des
* @property {number} type
@@ -336,6 +337,11 @@ module.exports = Object.freeze({
"~你预约的直播已开始"
],
/**
* 是否发送运行状态通知
*/
notice_running_state: false,
/**
* - 获取私信页数
*/
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "lottery-auto-script",
"version": "2.5.0",
"version": "2.5.6",
"description": "自动参与B站动态抽奖",
"main": "main.js",
"scripts": {
+1 -1
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# version: <major.minor.patch>
level=minor
level=patch
npm version $level \
--no-commit-hooks \