Compare commits

..
2 Commits
Author SHA1 Message Date
shanmiteko 156c31a3f5 docs: 更新CHANGELOG 2021-10-20 19:33:05 +08:00
shanmiteko 051a181210 feat: 私信检查所有未读消息 2021-10-20 19:21:52 +08:00
5 changed files with 54 additions and 9 deletions
+16
View File
@@ -1,3 +1,19 @@
## 主要变化(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)
## 问题修复
+5 -4
View File
@@ -36,20 +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 += '## 私信检测结果\n\n'
desp += '----------------------------------------------------------------\n\n'
desp += `发生时间: ${new Date(timestamp * 1000).toLocaleString()}\n\n`
desp += `用户: ${sender_uid}\n\n`
desp += `私信你(${global_var.get("myUID")})说: ${content}\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) {
+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',
+31 -4
View File
@@ -204,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
@@ -241,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) {
@@ -253,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 }>}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "lottery-auto-script",
"version": "2.2.9",
"version": "2.3.0",
"description": "自动参与B站动态抽奖",
"main": "main.js",
"scripts": {