mirror of
https://github.com/shanmiteko/LotteryAutoScript.git
synced 2026-07-22 21:13:47 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
156c31a3f5 | ||
|
|
051a181210 | ||
|
|
e8b9e05a65 | ||
|
|
e298970d3f | ||
|
|
1eaa188374 | ||
|
|
b36d24a4d8 | ||
|
|
3b73d6a2f5 | ||
|
|
f851ac1afe | ||
|
|
b53b698930 | ||
|
|
08d46c6f5c | ||
|
|
80ae3df933 | ||
|
|
ac397c68ec | ||
|
|
423bc24939 | ||
|
|
41b28a133e | ||
|
|
b1ead1329d | ||
|
|
e0e99a07bb | ||
|
|
30d0e8b1bd |
@@ -1,4 +1,6 @@
|
||||
node_modules/
|
||||
.vscode/
|
||||
tests/
|
||||
dyids/
|
||||
dist/
|
||||
package-lock.json
|
||||
|
||||
+482
@@ -0,0 +1,482 @@
|
||||
## 主要变化(2.2.9)
|
||||
- 检查动态创建时间(#57)(#58)
|
||||
- 简单整理(#56)
|
||||
## 问题修复
|
||||
- 非转发动态无源用户(#54)
|
||||
## 较上一版本变化
|
||||
- `env.js`无
|
||||
- `my_config.js`增加`max_create_time`
|
||||
|
||||
**替换可执行文件和更改配置文件(建议修改)**
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
|
||||
|
||||
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.2.8...v2.2.9
|
||||
|
||||
|
||||
## 主要变化(2.2.8)
|
||||
- 遇到过期的cookie跳过(#51)
|
||||
## 问题修复
|
||||
- UP关闭评论区(#52)
|
||||
## 较上一版本变化
|
||||
- `env.js`无
|
||||
- `my_config.js`无
|
||||
|
||||
**替换可执行文件**
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
|
||||
|
||||
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.2.7...v2.2.8
|
||||
|
||||
|
||||
## 主要变化(2.2.7)
|
||||
## 问题修复
|
||||
- 未移动分区(#50)
|
||||
- 修改线路切换逻辑
|
||||
## 较上一版本变化
|
||||
- `env.js`无
|
||||
- `my_config.js`无
|
||||
|
||||
**替换可执行文件**
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
|
||||
|
||||
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.2.6...v2.2.7
|
||||
|
||||
|
||||
## 主要变化(2.2.6)
|
||||
- LOG日志显示随机动态内容(#47)
|
||||
- 增加设置过滤间隔
|
||||
## 较上一版本变化
|
||||
- `env.js`无
|
||||
- `my_config.js`增加`filter_wait`
|
||||
|
||||
**替换可执行文件和更改配置文件(建议修改)**
|
||||
|
||||
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
|
||||
|
||||
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.2.5...v2.2.6
|
||||
|
||||
|
||||
## 主要变化(2.2.5)
|
||||
## 问题修复
|
||||
- 因黑名单而关注失败(#45)
|
||||
## 较上一版本变化
|
||||
- `env.js`无
|
||||
- `my_config.js`无
|
||||
|
||||
**替换可执行文件**
|
||||
|
||||
_如果之前版本小于上一版本,请查看**历次更新**说明_
|
||||
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
|
||||
|
||||
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.2.4...v2.2.5
|
||||
|
||||
|
||||
## 主要变化(2.2.4)
|
||||
- api线路切换具有记忆功能
|
||||
- 增加更多时延自定义值(#44)
|
||||
- 重构部分代码
|
||||
- 内置默认设置
|
||||
## 问题修复
|
||||
- 清理动态时关注列表获取失败
|
||||
## 较上一版本变化
|
||||
- `env.js`无
|
||||
- `my_config.js`增加
|
||||
- `get_session_wait` 读取下一页私信间隔
|
||||
- `update_session_wait` 已读私信间隔
|
||||
- `get_partition_wait` 读取下一页关注列表间隔
|
||||
- `get_dynamic_detail_wait` 获取动态细节间隔
|
||||
- `random_dynamic_wait` 随机动态间隔
|
||||
|
||||
**替换可执行文件和更改配置文件(建议修改)**
|
||||
|
||||
_如果之前版本小于上一版本,请查看**历次更新**说明_
|
||||
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
|
||||
|
||||
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.2.3...v2.2.4
|
||||
|
||||
|
||||
## 主要变化(2.2.3)
|
||||
- clear_dynamic_type类型可以多选(#42)
|
||||
## 问题修复
|
||||
- 番剧动态无user_profile(#41)
|
||||
## 较上一版本变化
|
||||
- `env.js`无
|
||||
- `my_config.js`修改`clear_dynamic_type`
|
||||
|
||||
**替换可执行文件和更改配置文件(建议修改)**
|
||||
|
||||
_如果之前版本小于上一版本,请查看**历次更新**说明_
|
||||
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
|
||||
|
||||
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.2.2...v2.2.3
|
||||
|
||||
|
||||
## 主要变化(2.2.2)
|
||||
- 随机转发热门视频(#40)
|
||||
## 较上一版本变化
|
||||
- `env.js`无
|
||||
- `my_config.js`增加`create_dy_mode` `create_dy_type`
|
||||
|
||||
**替换可执行文件和更改配置文件(建议修改)**
|
||||
|
||||
_如果之前版本小于上一版本,请查看**历次更新**说明_
|
||||
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
|
||||
|
||||
|
||||
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.2.1...v2.2.2
|
||||
|
||||
|
||||
## 主要变化(2.2.1)
|
||||
- 动态不存在时出错(#39)
|
||||
## 较上一版本变化
|
||||
- `env.js`无
|
||||
- `my_config.js`无
|
||||
|
||||
**替换可执行文件**
|
||||
|
||||
_如果之前版本小于上一版本,请查看**历次更新**说明_
|
||||
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
|
||||
|
||||
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.2.0...v2.2.1
|
||||
|
||||
|
||||
## 主要变化(2.2.0)
|
||||
- 修改转发验重逻辑
|
||||
- 可间隔插入随机动态(#33)
|
||||
## 较上一版本变化
|
||||
- `env.js`无
|
||||
- `my_config.js`增加create_dy_mode
|
||||
|
||||
**替换可执行文件和更改配置文件(建议修改)**
|
||||
|
||||
_如果之前版本小于上一版本,请查看**历次更新**说明_
|
||||
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
|
||||
|
||||
|
||||
## 主要变化(2.1.8)
|
||||
- 设置支持热更新(#29)
|
||||
## 较上一版本变化
|
||||
- `env.js`文件格式更改
|
||||
- `my_config.js`文件格式更改
|
||||
|
||||
**替换可执行文件和更改配置文件(建议修改)**
|
||||
|
||||
_如果之前版本小于上一版本,请查看**历次更新**说明_
|
||||
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
|
||||
|
||||
|
||||
## 主要变化(2.1.7)
|
||||
- 设置支持热更新(#29)
|
||||
## 较上一版本变化
|
||||
- `env.js`文件格式更改
|
||||
- `my_config.js`无
|
||||
|
||||
**替换可执行文件和更改env.js**
|
||||
|
||||
_如果之前版本小于上一版本,请查看**历次更新**说明_
|
||||
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
|
||||
|
||||
|
||||
## 主要变化(2.1.6)
|
||||
- 新增设置not_check_article(#25)
|
||||
## 较上一版本变化
|
||||
- `env.js`无
|
||||
- `my_config.js`新增设置not_check_article
|
||||
|
||||
**替换可执行文件和更改my_config.js**
|
||||
|
||||
_如果之前版本小于上一版本,请查看**历次更新**说明_
|
||||
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
|
||||
|
||||
|
||||
## 主要变化(2.1.5)
|
||||
- 修复之前无法更新的问题
|
||||
## 较上一版本变化
|
||||
- `env.js`无
|
||||
- `my_config.js`无
|
||||
|
||||
**仅需替换可执行文件**
|
||||
|
||||
_如果之前版本小于上一版本,请查看**历次更新**说明_
|
||||
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
|
||||
|
||||
|
||||
## 主要变化(2.1.4)
|
||||
- 黑名单处理(#22)
|
||||
## 较上一版本变化
|
||||
- `env.js`无
|
||||
- `my_config.js`无
|
||||
|
||||
**仅需替换可执行文件**
|
||||
|
||||
_如果之前版本小于上一版本,请查看**历次更新**说明_
|
||||
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
|
||||
|
||||
|
||||
## 主要变化(2.1.3)
|
||||
- 错误码变更(#20)
|
||||
## 较上一版本变化
|
||||
- `env.js`无
|
||||
- `my_config.js`无
|
||||
|
||||
**仅需替换可执行文件**
|
||||
|
||||
_如果之前版本小于上一版本,请查看**历次更新**说明_
|
||||
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
|
||||
|
||||
|
||||
## 主要变化(2.1.2)
|
||||
- 支持arm平台运行
|
||||
- 改变账号异常应对策略
|
||||
- 修改dingtalk签名base64问题(#17)
|
||||
## 较上一版本变化
|
||||
- `env.js`无
|
||||
- `my_config.js`无
|
||||
|
||||
**仅需替换可执行文件**
|
||||
|
||||
_如果之前版本小于上一版本,请查看**历次更新**说明_
|
||||
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
|
||||
|
||||
|
||||
## 主要变化(2.1.1)
|
||||
- 获取未读私信接口变化
|
||||
## 较上一版本变化
|
||||
- `env.js`无
|
||||
- `my_config.js`无
|
||||
|
||||
**仅需替换可执行文件**
|
||||
|
||||
_如果之前版本小于上一版本,请查看**历次更新**说明_
|
||||
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
|
||||
|
||||
|
||||
## 主要变化(2.1.0)
|
||||
- 修复两处问题
|
||||
## 较上一版本变化
|
||||
- `env.js`无
|
||||
- `my_config.js`无
|
||||
|
||||
**仅需替换可执行文件**
|
||||
|
||||
_如果之前版本小于上一版本,请查看**历次更新**说明_
|
||||
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
|
||||
|
||||
|
||||
## 主要变化(2.0.9)
|
||||
- 账号异常自动切换线路(#14)
|
||||
## 较上一版本变化
|
||||
- `env.js`无
|
||||
- `my_config.js`无
|
||||
|
||||
**仅需替换可执行文件**
|
||||
|
||||
_如果之前版本小于上一版本,请查看**历次更新**说明_
|
||||
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
|
||||
|
||||
|
||||
## 主要变化(2.0.8)
|
||||
- 账号异常时未处理和发送通知
|
||||
## 较上一版本变化
|
||||
- `env.js`无
|
||||
- `my_config.js`无
|
||||
|
||||
**仅需替换可执行文件**
|
||||
|
||||
_如果之前版本小于上一版本,请查看**历次更新**说明_
|
||||
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
|
||||
|
||||
|
||||
## 主要变化(2.0.7)
|
||||
- 修复一处问题
|
||||
- 日志时间UTC+8(#13)
|
||||
## 较上一版本变化
|
||||
- `env.js`无
|
||||
- `my_config.js`无
|
||||
|
||||
**仅需替换可执行文件**
|
||||
|
||||
_如果之前版本小于上一版本,请查看**历次更新**说明_
|
||||
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
|
||||
|
||||
|
||||
## 主要变化
|
||||
- 支持更新检查
|
||||
- 增加设置`update_loop_wait`
|
||||
## 较上一版本(v2.0.5)变化
|
||||
- `env.js`无
|
||||
- `my_config.js`增加设置`update_loop_wait`
|
||||
|
||||
**替换可执行文件和更新my_config.js**
|
||||
|
||||
_如果之前版本小于2.0.5,请查看历次更新说明_
|
||||
|
||||
|
||||
## 主要变化
|
||||
- 不参与主站黑名单用户抽奖
|
||||
- my_config.js注释修改
|
||||
- 可从环境变量中读取COOKIE
|
||||
- 其他不影响功能的调整
|
||||
## 较上一版本(v2.0.4)变化
|
||||
- `env.js`无
|
||||
- `my_config.js`无
|
||||
|
||||
**仅需替换可执行文件**
|
||||
|
||||
|
||||
## 新特性
|
||||
中奖通知设置可设黑名单
|
||||
## 较上一版本(v2.0.3)变化
|
||||
`env.js`无
|
||||
`my_config.js`无
|
||||
**仅需替换可执行文件**
|
||||
|
||||
|
||||
## 问题修复
|
||||
- 评论失败未退出
|
||||
- 切割tag不精准
|
||||
## 较上一版本(v2.0.2)变化
|
||||
`env.js`无
|
||||
`my_config.js`无
|
||||
**仅需替换可执行文件**
|
||||
|
||||
edit: 替换release
|
||||
|
||||
|
||||
## 问题修复
|
||||
#9
|
||||
## 较上一版本(2.0.1)变化
|
||||
`env.js`无
|
||||
`my_config.js`无
|
||||
**仅需替换可执行文件**
|
||||
|
||||
|
||||
## 新增特性
|
||||
增加两处自定义设置(`my_config.js`)
|
||||
- `clear_quick_remove_attention`
|
||||
- `notice_key_words`
|
||||
## 问题修复
|
||||
#7
|
||||
## 较上一版本(2.0.0)变化
|
||||
`env.js`无
|
||||
`my_config.js`需修改添加两处自定义设置
|
||||
除了替换可执行文件,还要修改`my_config.js`文件
|
||||
|
||||
|
||||
## 新增特性
|
||||
打乱将转发的动态顺序,防止被人认出是抽奖号
|
||||
## 问题修复
|
||||
修复两处潜在bug
|
||||
## 较上一版本(1.9.9)变化
|
||||
`env.js`无
|
||||
`my_config.js`无
|
||||
只需替换可执行文件
|
||||
|
||||
|
||||
## 优化体验
|
||||
清理动态时日志更详细
|
||||
以及其他细节处理
|
||||
## 较上一版本(1.9.8)变化
|
||||
`env.js`无
|
||||
`my_config.js`无
|
||||
只需替换可执行文件
|
||||
|
||||
edit: 1.9.9.1
|
||||
edit: 1.9.9.2
|
||||
|
||||
|
||||
## 修复Bug
|
||||
两级解构时第一级为undefined(表现为异常退出)
|
||||
|
||||
## 较上一版本(1.9.7)变化
|
||||
`env.js`更改注释内容
|
||||
`my_config.js`无
|
||||
只需替换可执行文件
|
||||
|
||||
## 修复Bug
|
||||
转发专栏内的抽奖时无法获取关注
|
||||
|
||||
## 较上一版本(1.9.6)变化
|
||||
`env.js`无
|
||||
`my_config.js`无
|
||||
只需替换可执行文件
|
||||
|
||||
|
||||
## 主要变化(1.9.6)
|
||||
去除对unzipper的依赖
|
||||
专栏转发率达一半以上时跳过
|
||||
|
||||
## 较上一版本变更
|
||||
`env.js`无
|
||||
`my_config.js`无
|
||||
只需替换可执行文件
|
||||
|
||||
|
||||
## 主要新增功能(1.9.5)
|
||||
可从专栏里获取抽奖动态
|
||||
|
||||
## 较上一版本变更
|
||||
`env.js`无变化
|
||||
`my_config.js`去掉部分设置,新增部分设置
|
||||
|
||||
## 1.9.0
|
||||
|
||||
修复Bug后的稳定版(大概
|
||||
- 21/7/21 附加bat脚本增加对小白的友好性
|
||||
|
||||
## 1.8
|
||||
|
||||
fix: 开奖时间过滤失效
|
||||
|
||||
# 1.7
|
||||
|
||||
change 修复一处bug
|
||||
change 重新上传zip
|
||||
change 重新上传zip
|
||||
|
||||
|
||||
## 1.6
|
||||
|
||||
perf: 重构代码
|
||||
|
||||
- 分离动态筛选部分的网络请求和数据处理
|
||||
- 优化部分ifelse判断
|
||||
feat:
|
||||
- 新增NOT_GO_LOTTERY环境变量
|
||||
- 边转边存dyid
|
||||
- 滤除的dyid也进行存储
|
||||
fix: 修复部分bug
|
||||
|
||||
|
||||
|
||||
## 1.5
|
||||
|
||||
feat: 日志相关
|
||||
|
||||
- 彩色输出
|
||||
- 环境变量LOTTERY_LOG_LEVEL更改日志等级
|
||||
feat: 设置相关
|
||||
- lottery_loop_wait 抽奖循环
|
||||
- check_loop_wait 检奖循环
|
||||
- clear_loop_wait 清理循环
|
||||
|
||||
## 1.4
|
||||
|
||||
fix: 部分动态无法获取描述
|
||||
|
||||
## 1.3
|
||||
|
||||
feat: 新增loop_wait设置
|
||||
|
||||
|
||||
可执行文件压缩包
|
||||
|
||||
|
||||
# 命令行工具
|
||||
|
||||
可执行文件压缩包
|
||||
|
||||
|
||||
可执行文件压缩包
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 123 KiB After Width: | Height: | Size: 274 KiB |
+19
-14
@@ -19,12 +19,14 @@ async function isMe() {
|
||||
const MyAtInfo = await bili.getMyAtInfo();
|
||||
MyAtInfo.forEach(async AtInfo => {
|
||||
const { at_time, up_uname, business, source_content, url } = AtInfo
|
||||
desp += `发生时间: ${new Date(at_time * 1000).toLocaleString()} \n\n`
|
||||
desp += `用户: ${up_uname} \n\n`
|
||||
desp += `在${business}中@了你(${global_var.get("myUID")}) \n\n`
|
||||
desp += `原内容为: ${source_content} \n\n`
|
||||
desp += `[直达链接](${url}) \n\n`
|
||||
desp += `\n\n`
|
||||
desp += '## [at]检测结果\n\n'
|
||||
desp += '----------------------------------------------------------------\n\n'
|
||||
desp += `发生时间: ${new Date(at_time * 1000).toLocaleString()}\n\n`
|
||||
desp += `用户: ${up_uname}\n\n`
|
||||
desp += `在${business}中@了你(${global_var.get("myUID")})\n\n`
|
||||
desp += `原内容为: ${source_content}\n\n`
|
||||
desp += `[直达链接](${url})\n\n`
|
||||
desp += '----------------------------------------------------------------\n\n'
|
||||
});
|
||||
log.info('中奖检测', '--> OK');
|
||||
}
|
||||
@@ -34,18 +36,21 @@ async function isMe() {
|
||||
let MySession = await bili.getSessionInfo(type)
|
||||
for (const index of infiniteNumber()) {
|
||||
for (const Session of MySession.data) {
|
||||
const { content, sender_uid, session_ts, timestamp, unread_count, talker_id, msg_seqno } = Session;
|
||||
const { sender_uid, session_ts, timestamp, unread_count, talker_id, msg_seqno } = Session;
|
||||
session_t = session_ts;
|
||||
if (unread_count) {
|
||||
bili.updateSessionStatus(talker_id, type, msg_seqno);
|
||||
await delay(update_session_wait);
|
||||
const content = await bili.fetch_session_msgs(talker_id, unread_count);
|
||||
if (judge(content, notice_key_words)) {
|
||||
desp += `发生时间: ${new Date(timestamp * 1000).toLocaleString()} \n\n`
|
||||
desp += `用户: ${sender_uid} \n\n`
|
||||
desp += `私信你(${global_var.get("myUID")})说: ${content} \n\n`
|
||||
desp += `[直达链接](https://message.bilibili.com/#/whisper/mid${sender_uid}) \n\n`
|
||||
desp += `\n\n`
|
||||
desp += '## 私信检测结果\n\n'
|
||||
desp += '----------------------------------------------------------------\n\n'
|
||||
desp += `发生时间: ${new Date(timestamp * 1000).toLocaleString()}\n\n`
|
||||
desp += `用户: ${sender_uid}\n\n`
|
||||
desp += `私信你(${global_var.get("myUID")})说:\n${content}\n\n`
|
||||
desp += `[直达链接](https://message.bilibili.com/#/whisper/mid${sender_uid})\n\n`
|
||||
desp += '----------------------------------------------------------------\n\n'
|
||||
}
|
||||
await bili.updateSessionStatus(talker_id, type, msg_seqno);
|
||||
await delay(update_session_wait);
|
||||
}
|
||||
}
|
||||
if (MySession.has_more && index < 16) {
|
||||
|
||||
+16
-10
@@ -32,7 +32,7 @@ async function getFollowList() {
|
||||
* 清理动态和关注
|
||||
*/
|
||||
async function clear() {
|
||||
const { clear_white_list, clear_max_day, clear_quick_remove_attention, clear_remove_dynamic, clear_remove_attention, clear_remove_delay, clear_dynamic_type } = config;
|
||||
const { search_wait, clear_white_list, clear_max_day, clear_quick_remove_attention, clear_remove_dynamic, clear_remove_attention, clear_remove_delay, clear_dynamic_type } = config;
|
||||
let success = true;
|
||||
const uid_list = await getFollowList();
|
||||
if (!uid_list.length) {
|
||||
@@ -65,19 +65,17 @@ async function clear() {
|
||||
|
||||
for (const page of infiniteNumber()) {
|
||||
log.info('清理动态', `开始读取第${page + 1}页`);
|
||||
const { allModifyDynamicResArray, offset } = await Searcher.checkAllDynamic(MY_UID, 1, 5 * 1000, next_offset);
|
||||
const { allModifyDynamicResArray, offset } = await Searcher.checkAllDynamic(MY_UID, 1, search_wait, next_offset);
|
||||
next_offset = offset;
|
||||
for (const [index, dyinfo] of allModifyDynamicResArray.entries()) {
|
||||
log.info('清理动态', `第${page + 1}页中的第${index + 1}个动态`)
|
||||
const { type, dynamic_id, createtime } = dyinfo || {};
|
||||
const { type, dynamic_id, create_time, origin_uid } = dyinfo || {};
|
||||
if (typeof type !== 'undefined'
|
||||
&& clear_dynamic_type instanceof Array
|
||||
? clear_dynamic_type.includes(type)
|
||||
: clear_dynamic_type === type
|
||||
) {
|
||||
const
|
||||
{ origin_uid } = dyinfo,
|
||||
days_ago = (Now - createtime) / 86400;
|
||||
const days_ago = (Now - create_time) / 86400;
|
||||
|
||||
if (days_ago > clear_max_day) {
|
||||
/* 移除动态 */
|
||||
@@ -96,13 +94,21 @@ async function clear() {
|
||||
success = await bili.cancelAttention(origin_uid);
|
||||
}
|
||||
|
||||
if (!success) break;
|
||||
if (!success) {
|
||||
log.error("清理失败", "出现错误")
|
||||
break
|
||||
}
|
||||
/* 延时 */
|
||||
await delay(clear_remove_delay);
|
||||
} else {
|
||||
log.info('清理动态', `已设置跳过${clear_max_day}天 当前动态发布时间: ${~~days_ago}天前`)
|
||||
log.info('清理动态', `储存用户(${origin_uid})防止误删`)
|
||||
before_separate.push(origin_uid)
|
||||
log.info('清理动态', `已设置跳过${clear_max_day}天 当前动态(${dynamic_id})发布时间: ${~~days_ago}天前`)
|
||||
|
||||
if (origin_uid) {
|
||||
log.info('清理动态', `储存用户(${origin_uid})防止误删`)
|
||||
before_separate.push(origin_uid)
|
||||
} else {
|
||||
log.info('清理动态', `非转发动态`)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.info('清理动态', `此动态类型为${type} != 要清理的动态类型${clear_dynamic_type}`)
|
||||
|
||||
+34
-18
@@ -1,4 +1,4 @@
|
||||
const utils = require('../utils');
|
||||
const { log, hasEnv, shuffle, getRandomOne, delay, try_for_each } = require('../utils');
|
||||
const bili = require('../net/bili');
|
||||
const { sendNotify } = require('../helper/notify');
|
||||
const event_bus = require('../helper/event_bus');
|
||||
@@ -6,7 +6,6 @@ const { randomDynamic } = require('../helper/randomDynamic')
|
||||
const { Searcher } = require('./searcher');
|
||||
const global_var = require("../data/global_var");
|
||||
const config = require("../data/config");
|
||||
const { log, hasEnv } = utils;
|
||||
|
||||
/**
|
||||
* 监视器
|
||||
@@ -52,7 +51,7 @@ class Monitor extends Searcher {
|
||||
event_bus.emit('Turn_off_the_Monitor', '评论失败')
|
||||
break
|
||||
case 21:
|
||||
event_bus.emit('Turn_on_the_Monitor')
|
||||
event_bus.emit('Turn_off_the_Monitor', '关注出错')
|
||||
break
|
||||
case 22:
|
||||
log.warn('账号异常', `UID(${global_var.get('myUID')})异常号只会对部分UP出现关注异常`)
|
||||
@@ -83,13 +82,13 @@ class Monitor extends Searcher {
|
||||
async startLottery() {
|
||||
const allLottery = await this.filterLotteryInfo()
|
||||
, len = allLottery.length
|
||||
, { create_dy, create_dy_mode, wait } = config;
|
||||
, { create_dy, create_dy_mode, wait, filter_wait } = config;
|
||||
|
||||
log.info('筛选动态', `筛选完毕(${len})`);
|
||||
|
||||
if (len) {
|
||||
let is_exception = false;
|
||||
for (const [index, Lottery] of utils.shuffle(allLottery).entries()) {
|
||||
for (const [index, Lottery] of shuffle(allLottery).entries()) {
|
||||
let status = 0;
|
||||
|
||||
if (Lottery.isOfficialLottery) {
|
||||
@@ -100,10 +99,12 @@ class Monitor extends Searcher {
|
||||
}
|
||||
if (ts < ts_10) {
|
||||
log.info('过滤', '已过开奖时间')
|
||||
await delay(filter_wait)
|
||||
continue
|
||||
}
|
||||
if (ts > ts_10 + config.maxday * 86400) {
|
||||
log.info('过滤', '超过指定开奖时间')
|
||||
await delay(filter_wait)
|
||||
continue
|
||||
}
|
||||
} else if (Lottery.uid[0]) {
|
||||
@@ -113,6 +114,7 @@ class Monitor extends Searcher {
|
||||
}
|
||||
if (followerNum < config.minfollower) {
|
||||
log.info('过滤', `粉丝数(${followerNum})小于指定数量`)
|
||||
await delay(filter_wait)
|
||||
continue
|
||||
}
|
||||
}
|
||||
@@ -120,9 +122,9 @@ class Monitor extends Searcher {
|
||||
if (create_dy
|
||||
&& create_dy_mode instanceof Array
|
||||
&& index > 0
|
||||
&& index % utils.getRandomOne(create_dy_mode[0]) === 0
|
||||
&& index % getRandomOne(create_dy_mode[0]) === 0
|
||||
) {
|
||||
const number = utils.getRandomOne(create_dy_mode[1]) || 0;
|
||||
const number = getRandomOne(create_dy_mode[1]) || 0;
|
||||
randomDynamic(number)
|
||||
}
|
||||
|
||||
@@ -139,7 +141,7 @@ class Monitor extends Searcher {
|
||||
return status
|
||||
}
|
||||
|
||||
await utils.delay(wait * (Math.random() + 0.5));
|
||||
await delay(wait * (Math.random() + 0.5));
|
||||
}
|
||||
log.info('抽奖', '开始转发下一组动态');
|
||||
if (is_exception) {
|
||||
@@ -169,6 +171,9 @@ class Monitor extends Searcher {
|
||||
*/
|
||||
async filterLotteryInfo() {
|
||||
const { lottery_param, LotteryInfoMap, attentionList } = this;
|
||||
/**
|
||||
* @type {import("./searcher").LotteryInfo}
|
||||
*/
|
||||
let protoLotteryInfo = await LotteryInfoMap.get(lottery_param[0])(lottery_param[1]);
|
||||
|
||||
if (protoLotteryInfo === null)
|
||||
@@ -180,9 +185,13 @@ class Monitor extends Searcher {
|
||||
|
||||
/** 所有抽奖信息 */
|
||||
let alllotteryinfo = [];
|
||||
const { key_words, model, chatmodel, is_imitator, only_followed, at_users, blockword, blacklist } = config;
|
||||
const
|
||||
{ key_words, model, chatmodel, max_create_time, is_imitator, only_followed, at_users, blockword, blacklist } = config,
|
||||
now_ts = Date.now() / 1000;
|
||||
|
||||
/**Map<String, Boolean> */
|
||||
/**
|
||||
* @type {Map<String, Boolean>}
|
||||
*/
|
||||
let dyids_map = new Map();
|
||||
|
||||
/**去重 */
|
||||
@@ -195,15 +204,18 @@ class Monitor extends Searcher {
|
||||
});
|
||||
|
||||
/* 检查动态是否满足要求 */
|
||||
await utils.try_for_each(protoLotteryInfo, async function ({
|
||||
await try_for_each(protoLotteryInfo, async function ({
|
||||
lottery_info_type, is_liked,
|
||||
uids, uname, dyid,
|
||||
uids, uname, dyid, create_time,
|
||||
ctrl, rid, des, type,
|
||||
hasOfficialLottery
|
||||
}) {
|
||||
/* 遇到转发过就退出 */
|
||||
if (is_liked) return false;
|
||||
|
||||
/* 超过指定时间退出 */
|
||||
if (now_ts - create_time > max_create_time * 86400) return false;
|
||||
|
||||
const
|
||||
/**判断是转发源动态还是现动态 */
|
||||
uid = lottery_info_type === 'uid' ? uids[1] : uids[0],
|
||||
@@ -254,7 +266,7 @@ class Monitor extends Searcher {
|
||||
|
||||
let
|
||||
/**转发评语 */
|
||||
RandomStr = utils.getRandomOne(config.relay),
|
||||
RandomStr = getRandomOne(config.relay),
|
||||
/**控制字段 */
|
||||
new_ctrl = [];
|
||||
|
||||
@@ -323,7 +335,7 @@ class Monitor extends Searcher {
|
||||
* @param {LotteryOptions} option
|
||||
* @returns {Promise<number>}
|
||||
* 0 - 成功
|
||||
* 9 - 评论黑名单
|
||||
* 9 - 评论黑名单/评论区关闭/动态删除
|
||||
* 11 - 评论错误
|
||||
* 19 - 关注黑名单
|
||||
* 21 - 关注错误
|
||||
@@ -346,8 +358,8 @@ class Monitor extends Searcher {
|
||||
{ chat } = config,
|
||||
retry = [...new Array(5).keys()],
|
||||
max_retry_times = retry.length;
|
||||
await utils.try_for_each(retry, async (times) => {
|
||||
status = await bili.sendChat(rid, utils.getRandomOne(chat), chat_type)
|
||||
await try_for_each(retry, async (times) => {
|
||||
status = await bili.sendChat(rid, getRandomOne(chat), chat_type)
|
||||
switch (status) {
|
||||
case 0:
|
||||
return true
|
||||
@@ -357,7 +369,7 @@ class Monitor extends Searcher {
|
||||
default:
|
||||
log.error('抽奖信息', `uid: ${uid},dyid: ${dyid}`)
|
||||
log.info('自动评论', `将在 ${times + 1} 分钟后再次发送评论(${times + 1}/${max_retry_times})`)
|
||||
await utils.delay(60 * 1000 * (times + 1))
|
||||
await delay(60 * 1000 * (times + 1))
|
||||
return false
|
||||
}
|
||||
})
|
||||
@@ -367,12 +379,16 @@ class Monitor extends Searcher {
|
||||
/* 关注 */
|
||||
if (uid.length) {
|
||||
let status = 0
|
||||
await utils.try_for_each(uid, async (u) => {
|
||||
await try_for_each(uid, async (u) => {
|
||||
status = await bili.autoAttention(u)
|
||||
switch (status) {
|
||||
case 0:
|
||||
if (await bili.movePartition(u, this.tagid)) {
|
||||
log.error('抽奖信息', `uid: ${u},dyid: ${dyid}`)
|
||||
}
|
||||
return false
|
||||
case -1:
|
||||
case 2:
|
||||
log.warn('抽奖信息', `uid: ${u},dyid: ${dyid}`)
|
||||
return true
|
||||
default:
|
||||
|
||||
+22
-17
@@ -11,14 +11,14 @@ const { log } = utils
|
||||
* @property {number} uid
|
||||
* @property {string} uname
|
||||
* @property {boolean} is_liked
|
||||
* @property {number} createtime 10
|
||||
* @property {number} create_time 10
|
||||
* @property {string} rid_str
|
||||
* @property {string} dynamic_id
|
||||
* @property {number} type
|
||||
* @property {string} description
|
||||
* @property {boolean} hasOfficialLottery
|
||||
* @property {Array<Object.<string,string|number>>} ctrl
|
||||
*
|
||||
* @property {number} origin_create_time 10
|
||||
* @property {number} origin_uid
|
||||
* @property {string} origin_uname
|
||||
* @property {string} origin_rid_str
|
||||
@@ -27,6 +27,20 @@ const { log } = utils
|
||||
* @property {string} origin_description
|
||||
* @property {boolean} origin_hasOfficialLottery
|
||||
*
|
||||
* 整理后的抽奖信息
|
||||
* @typedef {object} LotteryInfo
|
||||
* @property {string} lottery_info_type
|
||||
* @property {number} create_time
|
||||
* @property {boolean} is_liked
|
||||
* @property {number[]} uids `[uid,ouid]`
|
||||
* @property {string} uname
|
||||
* @property {Array<{}>} ctrl
|
||||
* @property {string} dyid
|
||||
* @property {string} rid
|
||||
* @property {string} des
|
||||
* @property {number} type
|
||||
* @property {boolean} hasOfficialLottery 是否官方
|
||||
*
|
||||
* @param {object} dynamic_detail_card
|
||||
* @return {UsefulDynamicInfo}
|
||||
*/
|
||||
@@ -46,7 +60,7 @@ function parseDynamicCard(dynamic_detail_card) {
|
||||
/* 动态是否点过赞 */
|
||||
obj.is_liked = is_liked > 0
|
||||
/* 动态的ts10 */
|
||||
obj.createtime = desc.timestamp
|
||||
obj.create_time = desc.timestamp
|
||||
/* 动态类型 */
|
||||
obj.type = desc.type
|
||||
/* 用于发送评论 */
|
||||
@@ -65,6 +79,8 @@ function parseDynamicCard(dynamic_detail_card) {
|
||||
const { origin_extension, origin } = cardToJson
|
||||
, originToJson = strToJson(origin)
|
||||
, { user, item } = originToJson;
|
||||
/* 源动态的ts10 */
|
||||
obj.origin_create_time = desc.origin.timestamp;
|
||||
/* 被转发者的UID */
|
||||
obj.origin_uid = desc.origin.uid;
|
||||
/* 被转发者的rid(用于发评论) */
|
||||
@@ -131,20 +147,6 @@ function modifyDynamicRes(res) {
|
||||
*/
|
||||
class Searcher {
|
||||
constructor() { }
|
||||
/**
|
||||
* 整理后的抽奖信息
|
||||
* @typedef {object} LotteryInfo
|
||||
* @property {string} lottery_info_type
|
||||
* @property {boolean} is_liked
|
||||
* @property {number[]} uids `[uid,ouid]`
|
||||
* @property {string} uname
|
||||
* @property {Array<{}>} ctrl
|
||||
* @property {string} dyid
|
||||
* @property {string} rid
|
||||
* @property {string} des
|
||||
* @property {number} type
|
||||
* @property {boolean} hasOfficialLottery 是否官方
|
||||
*/
|
||||
/**
|
||||
* 检查指定用户的所有的动态信息
|
||||
* @param {number} hostuid 指定的用户UID
|
||||
@@ -247,6 +249,7 @@ class Searcher {
|
||||
|
||||
return [...results, {
|
||||
lottery_info_type: 'uid',
|
||||
create_time: cur.origin_create_time,
|
||||
is_liked,
|
||||
uids: [cur.uid, cur.origin_uid],
|
||||
uname: cur.origin_uname,
|
||||
@@ -307,6 +310,7 @@ class Searcher {
|
||||
const fomatdata = mDRdata.map(o => {
|
||||
return {
|
||||
lottery_info_type: 'tag',
|
||||
create_time: o.create_time,
|
||||
is_liked: o.is_liked,
|
||||
uids: [o.uid, o.origin_uid],
|
||||
uname: o.uname,
|
||||
@@ -386,6 +390,7 @@ class Searcher {
|
||||
const fomatdata = dyinfos.map(o => {
|
||||
return {
|
||||
lottery_info_type: 'article',
|
||||
create_time: o.create_time,
|
||||
is_liked: o.is_liked,
|
||||
uids: [o.uid, o.origin_uid],
|
||||
uname: o.uname,
|
||||
|
||||
+13
-1
@@ -41,6 +41,12 @@ const config = {
|
||||
*/
|
||||
chatmodel: '01',
|
||||
|
||||
/**
|
||||
* - 动态创建时间
|
||||
* - 多少天前
|
||||
*/
|
||||
max_create_time: 60,
|
||||
|
||||
/**
|
||||
* 不加判断的转发所监视的uid转发的动态
|
||||
*/
|
||||
@@ -93,7 +99,7 @@ const config = {
|
||||
* - 检索动态间隔
|
||||
* - 单位毫秒
|
||||
*/
|
||||
search_wait: 1000,
|
||||
search_wait: 2000,
|
||||
|
||||
/**
|
||||
* - 读取下一页私信间隔
|
||||
@@ -119,6 +125,12 @@ const config = {
|
||||
*/
|
||||
get_dynamic_detail_wait: 2000,
|
||||
|
||||
/**
|
||||
* - 过滤间隔(开奖时间/粉丝数)
|
||||
* - 单位毫秒
|
||||
*/
|
||||
filter_wait: 1000,
|
||||
|
||||
/**
|
||||
* - 随机动态间隔
|
||||
* - 单位毫秒
|
||||
|
||||
@@ -7,6 +7,7 @@ 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',
|
||||
LOTTERY_SVR_LOTTERY_NOTICE: 'https://api.vc.bilibili.com/lottery_svr/v1/lottery_svr/lottery_notice',
|
||||
|
||||
+65
-32
@@ -6,20 +6,23 @@ const API = require('./api.bili');
|
||||
class Line {
|
||||
/**
|
||||
* 智能线路切换
|
||||
* @typedef {string} ErrorMsg
|
||||
* @typedef {[ErrorMsg, any]} ResResult
|
||||
* @param {any} default_value
|
||||
* @typedef {boolean} iSwitch 是否切换
|
||||
* @typedef {string} Msg 信息说明
|
||||
* @typedef {[iSwitch, any, Msg]} ResResult
|
||||
* @param {string} line_name
|
||||
* @param {Array<(...arg) => Promise<ResResult | string>>} requests
|
||||
* @param {(responseText: string) => ResResult} [pub_handler]
|
||||
*/
|
||||
constructor(default_value, line_name, requests, pub_handler) {
|
||||
constructor(line_name, requests, pub_handler) {
|
||||
this.line_name = line_name
|
||||
this.requests = requests
|
||||
this.valid_line = 0
|
||||
this.switch_times = 0
|
||||
this.default_value = default_value
|
||||
if (pub_handler) this.pub_handler = pub_handler
|
||||
/**
|
||||
* @type {ResResult}
|
||||
*/
|
||||
this.res_result = [false, null, '']
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,26 +56,27 @@ class Line {
|
||||
*/
|
||||
async run(...args) {
|
||||
const
|
||||
{ line_name, requests, valid_line, default_value } = this,
|
||||
{ line_name, requests, valid_line } = this,
|
||||
resp = await requests[valid_line](...args);
|
||||
let err, value;
|
||||
if (typeof resp === 'string') {
|
||||
[err, value] = this.pub_handler(resp)
|
||||
this.res_result = this.pub_handler(resp)
|
||||
} else {
|
||||
[err, value] = resp
|
||||
this.res_result = resp
|
||||
}
|
||||
if (!err) {
|
||||
const [i_switch, value, msg] = this.res_result
|
||||
if (!i_switch) {
|
||||
log.info(line_name, msg)
|
||||
this.storeLine(valid_line)
|
||||
return value
|
||||
}
|
||||
if (this.switchLine()) {
|
||||
log.warn(line_name, err)
|
||||
log.warn(line_name, msg)
|
||||
log.warn(line_name, `切换线路(${valid_line + 1}/${requests.length})`)
|
||||
return await this.run()
|
||||
} else {
|
||||
log.error(line_name, err)
|
||||
log.error(line_name, msg)
|
||||
log.error(line_name, '所有备用线路均连接失败')
|
||||
return default_value
|
||||
return value
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -200,10 +204,9 @@ const bili_client = {
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 获取私信
|
||||
* 获取一页私信
|
||||
* @typedef SessionData
|
||||
* @property {string} session_ts
|
||||
* @property {string} content
|
||||
* @property {number} timestamp
|
||||
* @property {number} unread_count
|
||||
* @property {number} sender_uid
|
||||
@@ -237,8 +240,8 @@ const bili_client = {
|
||||
data = sessions.map(session => {
|
||||
const
|
||||
{ session_ts, last_msg, unread_count, talker_id } = session,
|
||||
{ content = '', timestamp = 0, sender_uid = 0, msg_seqno } = last_msg || {};
|
||||
return { session_ts, content, timestamp, sender_uid, unread_count, talker_id, msg_seqno };
|
||||
{ timestamp = 0, sender_uid = 0, msg_seqno } = last_msg || {};
|
||||
return { session_ts, timestamp, sender_uid, unread_count, talker_id, msg_seqno };
|
||||
});
|
||||
return { has_more, data };
|
||||
} else if (res.code === 2) {
|
||||
@@ -249,6 +252,34 @@ const bili_client = {
|
||||
return { has_more: 0, data: [] };
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 获取私信细节
|
||||
* @param {number} talker_id
|
||||
* @param {number} size
|
||||
*/
|
||||
async fetch_session_msgs(talker_id, size) {
|
||||
const
|
||||
responseText = await get({
|
||||
url: API.FETCH_SESSION_MSGS,
|
||||
query: {
|
||||
talker_id,
|
||||
session_type: 1,
|
||||
size
|
||||
}
|
||||
}),
|
||||
res = strToJson(responseText);
|
||||
if (res.code === 0) {
|
||||
const msgs = res.data.messages
|
||||
if (msgs instanceof Array) {
|
||||
log.info('私信细节', `${talker_id}有${size}条未读私信`)
|
||||
return msgs.map(it => it.content).join('\n')
|
||||
} else {
|
||||
log.warn('私信细节', `${talker_id}无私信`)
|
||||
}
|
||||
}
|
||||
log.error('私信细节', `获取失败`)
|
||||
return ''
|
||||
},
|
||||
/**
|
||||
* 获取未读私信数量
|
||||
* @returns {Promise<{ unfollow_unread: number, follow_unread: number }>}
|
||||
@@ -463,7 +494,7 @@ const bili_client = {
|
||||
/**
|
||||
* 获取粉丝数的所有有效方式
|
||||
*/
|
||||
_getUserInfo: new Line(-1, '获取粉丝数', [
|
||||
_getUserInfo: new Line('获取粉丝数', [
|
||||
/**
|
||||
* 线路一
|
||||
* @param {number} uid
|
||||
@@ -493,9 +524,9 @@ const bili_client = {
|
||||
], responseText => {
|
||||
const res = strToJson(responseText);
|
||||
if (res.code === 0) {
|
||||
return [null, res.data.follower];
|
||||
return [false, res.data.follower, 'ok'];
|
||||
} else {
|
||||
return [`出错 可能是访问过频繁\n${responseText}`, null]
|
||||
return [true, 1, `出错 可能是访问过频繁\n${responseText}`]
|
||||
}
|
||||
}),
|
||||
/**
|
||||
@@ -534,7 +565,7 @@ const bili_client = {
|
||||
};
|
||||
}
|
||||
},
|
||||
_autoAttention: new Line(1, '自动关注', [
|
||||
_autoAttention: new Line('自动关注', [
|
||||
(uid) => post({
|
||||
url: API.RELATION_MODIFY,
|
||||
config: {
|
||||
@@ -568,16 +599,15 @@ const bili_client = {
|
||||
const res = strToJson(responseText);
|
||||
switch (res.code) {
|
||||
case 0:
|
||||
log.info('自动关注', '关注+1');
|
||||
return [null, 0]
|
||||
return [false, 0, '关注+1']
|
||||
case 22002:
|
||||
return ['您已被对方拉入黑名单', -1]
|
||||
return [false, -1, '您已被对方拉入黑名单']
|
||||
case 22003:
|
||||
return ['黑名单用户无法关注', -1]
|
||||
return [false, -1, '黑名单用户无法关注', -1]
|
||||
case 22015:
|
||||
return ['账号异常', 2]
|
||||
return [false, 2, '账号异常', 2]
|
||||
default:
|
||||
return [`未知错误\n${responseText}`, 1]
|
||||
return [true, 1, `未知错误\n${responseText}`]
|
||||
}
|
||||
}),
|
||||
/**
|
||||
@@ -748,9 +778,9 @@ const bili_client = {
|
||||
contents,
|
||||
});
|
||||
if (/^{"code":0/.test(responseText)) {
|
||||
log.info('发布动态', '成功创建一条随机内容的动态');
|
||||
log.info('发布动态', `成功创建一条随机内容的动态\n${content}\n`);
|
||||
} else {
|
||||
log.error('发布动态', `发布动态失败\n${responseText}`);
|
||||
log.error('发布动态', `发布动态失败\n${content}\n${responseText}`);
|
||||
}
|
||||
},
|
||||
/**
|
||||
@@ -835,7 +865,7 @@ const bili_client = {
|
||||
* @returns {Promise<number>}
|
||||
* - 成功 0
|
||||
* - 失败 1
|
||||
* - 黑名单 -1
|
||||
* - 黑名单/评论区关闭/动态删除 -1
|
||||
*/
|
||||
async sendChat(rid, msg, type) {
|
||||
const
|
||||
@@ -855,10 +885,10 @@ const bili_client = {
|
||||
return 0;
|
||||
case -404:
|
||||
log.error('自动评论', '原动态已删除');
|
||||
return 0;
|
||||
return -1;
|
||||
case 12002:
|
||||
log.error('自动评论', '评论区已关闭');
|
||||
return 0;
|
||||
return -1;
|
||||
case 12015:
|
||||
log.error('自动评论', '需要输入验证码');
|
||||
return 1;
|
||||
@@ -868,6 +898,9 @@ const bili_client = {
|
||||
case 12053:
|
||||
log.error('自动评论', '黑名单用户无法互动');
|
||||
return -1;
|
||||
case 12061:
|
||||
log.error('自动评论', 'UP主已关闭评论区');
|
||||
return -1;
|
||||
default:
|
||||
log.error('自动评论', `未知错误\n${responseText}`);
|
||||
return 1;
|
||||
|
||||
+3
-3
@@ -26,7 +26,7 @@
|
||||
* @property {string} url 完整链接
|
||||
* @property {boolean} [stream] 是否流式数据
|
||||
* @property {RequestConfig} [config] 设置
|
||||
* @property {string} [proxy] 代理 IP:PORT
|
||||
* @property {string} [proxy] HTTP代理 IP:PORT
|
||||
* @property {Object.<string, string|number>} [query] 查询选项
|
||||
* @property {Object.<string, string|number> | string} [contents] 内容
|
||||
* @property {HttpHeaders} [headers] 请求头
|
||||
@@ -65,7 +65,7 @@ function send(detail) {
|
||||
const { timeout, wait, retry, redirect, retry_times } = config;
|
||||
const thisURL = new URL(url)
|
||||
, content = formatContents(headers["content-type"], contents)
|
||||
, request = thisURL.protocol === 'https:' ? https_request : http_request;
|
||||
, request = (thisURL.protocol === 'https:') && !proxy ? https_request : http_request;
|
||||
let options = {
|
||||
timeout,
|
||||
method: method.toUpperCase(),
|
||||
@@ -82,7 +82,7 @@ function send(detail) {
|
||||
if (proxy) {
|
||||
options.headers.host = thisURL.host;
|
||||
options.path = thisURL.href;
|
||||
[options.hostname, options.port] = proxy.split(':');
|
||||
[options.host, options.port] = proxy.split(':');
|
||||
}
|
||||
const req = request(options, res => {
|
||||
let protodata = '';
|
||||
|
||||
+15
-1
@@ -177,7 +177,21 @@ const utils = {
|
||||
* @param {String} [split] 分隔符
|
||||
*/
|
||||
proPrint(msg, split = ' ') {
|
||||
console.log([msg].flat().join(split))
|
||||
if (msg instanceof Array) {
|
||||
msg = msg.join(split)
|
||||
}
|
||||
console.log(msg)
|
||||
},
|
||||
/**
|
||||
* @param {Array<string>} msg
|
||||
* @returns
|
||||
*/
|
||||
rainbow(msg) {
|
||||
const
|
||||
colors = ['red', 'yellow', 'green', 'cyan', 'blue', 'magenta'],
|
||||
colorsCount = colors.length;
|
||||
|
||||
this.proPrint(msg.map(it => it.split('').map((l, i) => chalk[colors[i % colorsCount]](l)).join('')), '\n')
|
||||
},
|
||||
debug(context, msg) {
|
||||
if (this.level > 3) {
|
||||
|
||||
@@ -88,7 +88,8 @@ async function main() {
|
||||
return `提供了错误的[OPTIONS] -> ${mode}\n\n` + help_msg
|
||||
}
|
||||
} else {
|
||||
return 'Cookie已失效, 切换账号时不要点击退出账号而应直接删除Cookie退出'
|
||||
log.error('Cookie已失效', '切换账号时不要点击退出账号而应直接删除Cookie退出')
|
||||
return ''
|
||||
}
|
||||
} else {
|
||||
return '请查看README文件, 在env.js指定位置填入cookie'
|
||||
@@ -142,7 +143,7 @@ function initConfig() {
|
||||
}
|
||||
|
||||
(async function () {
|
||||
log.proPrint(metainfo, '\n')
|
||||
log.rainbow(metainfo)
|
||||
|
||||
if (initEnv() || initConfig()) return;
|
||||
|
||||
|
||||
+13
-1
@@ -53,6 +53,12 @@ module.exports = Object.freeze({
|
||||
*/
|
||||
chatmodel: '01',
|
||||
|
||||
/**
|
||||
* - 动态创建时间
|
||||
* - 多少天前
|
||||
*/
|
||||
max_create_time: 60,
|
||||
|
||||
/**
|
||||
* 不加判断的转发所监视的uid转发的动态
|
||||
*/
|
||||
@@ -105,7 +111,7 @@ module.exports = Object.freeze({
|
||||
* - 检索动态间隔
|
||||
* - 单位毫秒
|
||||
*/
|
||||
search_wait: 1000,
|
||||
search_wait: 2000,
|
||||
|
||||
/**
|
||||
* - 读取下一页私信间隔
|
||||
@@ -131,6 +137,12 @@ module.exports = Object.freeze({
|
||||
*/
|
||||
get_dynamic_detail_wait: 2000,
|
||||
|
||||
/**
|
||||
* - 过滤间隔(开奖时间/粉丝数)
|
||||
* - 单位毫秒
|
||||
*/
|
||||
filter_wait: 1000,
|
||||
|
||||
/**
|
||||
* - 随机动态间隔
|
||||
* - 单位毫秒
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "lottery-auto-script",
|
||||
"version": "2.2.5",
|
||||
"version": "2.3.0",
|
||||
"description": "自动参与B站动态抽奖",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user