Compare commits

..
16 Commits
14 changed files with 413 additions and 156 deletions
+2
View File
@@ -1,4 +1,6 @@
node_modules/
.vscode/
tests/
dyids/
dist/
package-lock.json
+219 -48
View File
@@ -1,7 +1,120 @@
## 主要变化(2.2.5)
<!-- markdownlint-disable MD036 MD024-->
# CHANGELOG
## 主要变化(2.3.1)
## 问题修复
- 因黑名单而关注失败(#45)
- 该动态不能转发分享(#60)
- 发布的动态内容未序列化(#47)
## 较上一版本变化
- `env.js`
- `my_config.js`
**替换可执行文件**
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
**Full Changelog**: <https://github.com/shanmiteko/LotteryAutoScript/compare/v2.3.0...v2.3.1>
## 主要变化(2.3.0)
- 私信检查所有未读消息
## 较上一版本变化
- `env.js`
- `my_config.js`
**替换可执行文件**
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
**Full Changelog**: <https://github.com/shanmiteko/LotteryAutoScript/compare/v2.2.9...v2.3.0>
## 主要变化(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`
@@ -10,38 +123,46 @@
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.2.4...v2.2.5
**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` 随机动态间隔
- `random_dynamic_wait` 随机动态间隔
**替换可执行文件和更改配置文件(建议修改)**
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.2.3...v2.2.4
**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`
@@ -50,12 +171,14 @@ _[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.2.2...v2.2.3
**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`
@@ -64,13 +187,14 @@ _[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.2.1...v2.2.2
**Full Changelog**: <https://github.com/shanmiteko/LotteryAutoScript/compare/v2.2.1...v2.2.2>
## 主要变化(2.2.1)
- 动态不存在时出错(#39)
## 较上一版本变化
- `env.js`
- `my_config.js`
@@ -79,13 +203,15 @@ _[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
**Full Changelog**: https://github.com/shanmiteko/LotteryAutoScript/compare/v2.2.0...v2.2.1
**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
@@ -94,10 +220,12 @@ _[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化(2.1.8)
- 设置支持热更新(#29)
## 较上一版本变化
- `env.js`文件格式更改
- `my_config.js`文件格式更改
@@ -106,10 +234,12 @@ _[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化(2.1.7)
- 设置支持热更新(#29)
## 较上一版本变化
- `env.js`文件格式更改
- `my_config.js`
@@ -118,10 +248,12 @@ _[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化(2.1.6)
- 新增设置not_check_article(#25)
## 较上一版本变化
- `env.js`
- `my_config.js`新增设置not_check_article
@@ -130,10 +262,12 @@ _[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化(2.1.5)
- 修复之前无法更新的问题
## 较上一版本变化
- `env.js`
- `my_config.js`
@@ -142,10 +276,12 @@ _[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化(2.1.4)
- 黑名单处理(#22)
## 较上一版本变化
- `env.js`
- `my_config.js`
@@ -154,10 +290,12 @@ _[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化(2.1.3)
- 错误码变更(#20)
- 错误码变更(#20)
## 较上一版本变化
- `env.js`
- `my_config.js`
@@ -166,12 +304,14 @@ _[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化(2.1.2)
- 支持arm平台运行
- 改变账号异常应对策略
- 修改dingtalk签名base64问题(#17)
## 较上一版本变化
- `env.js`
- `my_config.js`
@@ -180,10 +320,12 @@ _[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化(2.1.1)
- 获取未读私信接口变化
## 较上一版本变化
- `env.js`
- `my_config.js`
@@ -192,10 +334,12 @@ _[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化(2.1.0)
- 修复两处问题
## 较上一版本变化
- `env.js`
- `my_config.js`
@@ -204,10 +348,12 @@ _[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化(2.0.9)
- 账号异常自动切换线路(#14)
## 较上一版本变化
- `env.js`
- `my_config.js`
@@ -216,10 +362,12 @@ _[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化(2.0.8)
- 账号异常时未处理和发送通知
## 较上一版本变化
- `env.js`
- `my_config.js`
@@ -228,11 +376,13 @@ _[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化(2.0.7)
- 修复一处问题
- 日志时间UTC+8(#13)
## 较上一版本变化
- `env.js`
- `my_config.js`
@@ -241,11 +391,13 @@ _[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
_如果之前版本小于上一版本,请查看**历次更新**说明_
_[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
## 主要变化
- 支持更新检查
- 增加设置`update_loop_wait`
## 较上一版本(v2.0.5)变化
- `env.js`
- `my_config.js`增加设置`update_loop_wait`
@@ -253,72 +405,91 @@ _[查看链接](https://github.com/shanmiteko/LotteryAutoScript/releases)_
_如果之前版本小于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
# 9
## 较上一版本(2.0.1)变化
`env.js`
`my_config.js`
**仅需替换可执行文件**
## 新增特性
增加两处自定义设置(`my_config.js`)
- `clear_quick_remove_attention`
- `notice_key_words`
## 问题修复
#7
# 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`
只需替换可执行文件
@@ -326,44 +497,50 @@ edit: 替换release
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
@@ -376,7 +553,6 @@ change 修复一处bug
change 重新上传zip
change 重新上传zip
## 1.6
perf: 重构代码
@@ -389,8 +565,6 @@ feat:
- 滤除的dyid也进行存储
fix: 修复部分bug
## 1.5
feat: 日志相关
@@ -398,7 +572,7 @@ feat: 日志相关
- 彩色输出
- 环境变量LOTTERY_LOG_LEVEL更改日志等级
feat: 设置相关
- lottery_loop_wait 抽奖循环
- lottery_loop_wait 抽奖循环
- check_loop_wait 检奖循环
- clear_loop_wait 清理循环
@@ -410,13 +584,10 @@ fix: 部分动态无法获取描述
feat: 新增loop_wait设置
可执行文件压缩包
# 命令行工具
可执行文件压缩包
可执行文件压缩包
可执行文件压缩包
+19 -14
View File
@@ -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
View File
@@ -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}`)
+19 -5
View File
@@ -51,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出现关注异常`)
@@ -171,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)
@@ -182,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();
/**去重 */
@@ -199,13 +206,16 @@ class Monitor extends Searcher {
/* 检查动态是否满足要求 */
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],
@@ -325,7 +335,7 @@ class Monitor extends Searcher {
* @param {LotteryOptions} option
* @returns {Promise<number>}
* 0 - 成功
* 9 - 评论黑名单
* 9 - 评论黑名单/评论区关闭/动态删除
* 11 - 评论错误
* 19 - 关注黑名单
* 21 - 关注错误
@@ -373,8 +383,12 @@ class Monitor extends Searcher {
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
View File
@@ -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,
+10 -3
View File
@@ -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,
/**
* - 读取下一页私信间隔
@@ -223,10 +229,11 @@ const config = {
* - 中奖通知关键词(满足一个就推送)
* - 符合js正则表达式的字符串
* - 若以 ~ 开头则表示为黑名单规则
* - 优先级递增
*/
notice_key_words: [
"中奖|获得|填写|写上|提供|收货地址|支付宝账号|码|大会员",
"~有奖预约通知"
"~预约成功|预约主题",
"中奖|获得|填写|写上|提供|收货地址|支付宝账号|码|大会员"
],
/**
+1
View File
@@ -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',
+84 -46
View File
@@ -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}`]
}
}),
/**
@@ -691,22 +721,27 @@ const bili_client = {
if (len > 233) {
msg = msg.slice(0, 233 - len)
}
const responseText = await post({
url: API.DYNAMIC_REPOST_REPOST,
config: {
retry: false
},
contents: {
uid: `${uid}`,
dynamic_id: dyid,
content: msg,
ctrl,
csrf: GlobalVar.get("csrf")
}
});
if (/^{"code":0/.test(responseText)) {
const
responseText = await post({
url: API.DYNAMIC_REPOST_REPOST,
config: {
retry: false
},
contents: {
uid: `${uid}`,
dynamic_id: dyid,
content: msg,
ctrl,
csrf: GlobalVar.get("csrf")
}
}),
res = strToJson(responseText);
if (res.code === 0) {
log.info('转发动态', '成功转发一条动态');
return 0;
} else if (res.code === 1101004) {
log.warn('转发动态', '该动态不能转发分享');
return 0;
} else {
log.error('转发动态', `转发动态失败\n${responseText}`);
return 1;
@@ -748,9 +783,9 @@ const bili_client = {
contents,
});
if (/^{"code":0/.test(responseText)) {
log.info('发布动态', `成功创建一条随机内容的动态\n${content}\n`);
log.info('发布动态', `成功创建一条随机内容的动态\n${JSON.stringify(content)}\n`);
} else {
log.error('发布动态', `发布动态失败\n${content}\n${responseText}`);
log.error('发布动态', `发布动态失败\n${JSON.stringify(content)}\n${responseText}`);
}
},
/**
@@ -835,7 +870,7 @@ const bili_client = {
* @returns {Promise<number>}
* - 成功 0
* - 失败 1
* - 黑名单 -1
* - 黑名单/评论区关闭/动态删除 -1
*/
async sendChat(rid, msg, type) {
const
@@ -855,10 +890,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 +903,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
View File
@@ -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 = '';
+1 -1
View File
@@ -141,7 +141,7 @@ const utils = {
return array;
},
/**
* 关键词判断
* 关键词判断 优先级递增
* @param {string} text
* @param {string[]} key_words startwith '~' 表示黑名单
* @return {boolean}
+2 -1
View File
@@ -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'
+10 -3
View File
@@ -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,
/**
* - 读取下一页私信间隔
@@ -235,10 +241,11 @@ module.exports = Object.freeze({
* - 中奖通知关键词(满足一个就推送)
* - 符合js正则表达式的字符串
* - 若以 ~ 开头则表示为黑名单规则
* - 优先级递增
*/
notice_key_words: [
"中奖|获得|填写|写上|提供|收货地址|支付宝账号|码|大会员",
"~有奖预约通知"
"~预约成功|预约主题",
"中奖|获得|填写|写上|提供|收货地址|支付宝账号|码|大会员"
],
/**
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "lottery-auto-script",
"version": "2.2.6",
"version": "2.3.1",
"description": "自动参与B站动态抽奖",
"main": "main.js",
"scripts": {
@@ -45,11 +45,11 @@
},
"homepage": "https://github.com/shanmiteko/AutoScript#readme",
"devDependencies": {
"eslint": "^7.17.0",
"pkg": "^5.2.1"
"eslint": "^8.1.0",
"pkg": "^5.4.1"
},
"dependencies": {
"chalk": "^4.1.1",
"nodemailer": "^6.5.0"
"chalk": "^4.1.2",
"nodemailer": "^6.7.0"
}
}