Compare commits

...
4 Commits
Author SHA1 Message Date
shanmite 731b8475ec docs: 更新CHANGELOG 2022-01-15 14:48:55 +08:00
shanmite 043fee21e7 feat: 新增设置sneaktopic(#104)
偷塔模式不检查是否重复转发
* 偷塔模式: 临近开奖时参与抽奖
`sneaktopic: true`
2022-01-15 14:23:22 +08:00
shanmite ae34c691b1 feat: 新增设置is_repost_then_chat(#103)
转发并评论
2022-01-05 18:13:48 +08:00
shanmite 7496bc58a8 feat: 中奖检查时增加回复信息读取(#102) 2022-01-05 16:37:49 +08:00
8 changed files with 124 additions and 35 deletions
+7
View File
@@ -1,5 +1,12 @@
<!-- markdownlint-disable MD036 MD024-->
# CHANGELOG
## 主要变化(2.4.6)
* 043fee2 feat: 新增设置`sneaktopic`(#104)
* ae34c69 feat: 新增设置`is_repost_then_chat`(#103)
* 7496bc5 feat: 中奖检查时增加回复信息读取(#102)
_如果之前版本小于上一版本,请查看[CHANGELOG](CHANGELOG.md)变更说明_
## 主要变化(2.4.5)
* ef969bb feat: 每组显示动态转发数(#97)
* 0cbacd6 feat: 推送携带帐号编号(#98)
+34 -15
View File
@@ -12,23 +12,42 @@ async function isMe(num) {
let desp = '';
const
{ notice_key_words, update_session_wait, get_session_wait, check_session_pages } = config,
UnreadAtNum = await bili.getUnreadAtNum(),
UnreadSessionNum = await bili.getUnreadSessionNum(),
{ follow_unread, unfollow_unread } = UnreadSessionNum || { unfollow_unread: 0, follow_unread: 0 };
if (UnreadAtNum > 0) {
{ at: unread_at_num, reply: unread_reply_num } = await bili.getUnreadNum(),
unread_session_num = await bili.getUnreadSessionNum(),
{ follow_unread, unfollow_unread } = unread_session_num || { unfollow_unread: 0, follow_unread: 0 };
if (unread_at_num) {
log.info('中奖检测', '<-- 正在检查at');
const MyAtInfo = await bili.getMyAtInfo();
MyAtInfo.forEach(async AtInfo => {
const { at_time, up_uname, business, source_content, url } = AtInfo
desp += '## [at]检测结果\n\n'
desp += '----------------------------------------------------------------\n\n'
desp += `发生时间: ${new Date(at_time * 1000).toLocaleString()}\n\n`
desp += `用户: ${up_uname}\n\n`
desp += `${business}中@了你(https://space.bilibili.com/${global_var.get("myUID")})\n\n`
desp += `原内容为: ${source_content}\n\n`
desp += `[直达链接](${url})\n\n`
desp += '----------------------------------------------------------------\n\n'
});
MyAtInfo
.slice(0, unread_at_num)
.forEach(({ at_time, up_uname, business, source_content, url }) => {
desp += '## [at]检测结果\n\n'
desp += '----------------------------------------------------------------\n\n'
desp += `发生时间: ${new Date(at_time * 1000).toLocaleString()}\n\n`
desp += `用户: ${up_uname}\n\n`
desp += `${business}中@了你(https://space.bilibili.com/${global_var.get("myUID")})\n\n`
desp += `原内容为: ${source_content}\n\n`
desp += `[直达链接](${url})\n\n`
desp += '----------------------------------------------------------------\n\n'
});
log.info('中奖检测', '--> OK');
}
if (unread_reply_num) {
log.info('中奖检测', '<-- 正在检查回复');
const replys = await bili.getReplyMsg();
replys
.slice(0, unread_reply_num)
.forEach(({ nickname, uri, source, timestamp }) => {
if (judge(source, notice_key_words)) {
desp += '## 回复检测结果\n\n'
desp += '----------------------------------------------------------------\n\n'
desp += `发生时间: ${new Date(timestamp * 1000).toLocaleString()}\n\n`
desp += `用户: ${nickname}\n\n`
desp += `回复你(https://space.bilibili.com/${global_var.get("myUID")})说:\n${source}\n\n`
desp += `[直达链接](${uri})\n\n`
desp += '----------------------------------------------------------------\n\n'
}
})
log.info('中奖检测', '--> OK');
}
if (follow_unread + unfollow_unread > 0) {
+21 -11
View File
@@ -308,15 +308,21 @@ class Monitor extends Searcher {
log.debug('正在筛选的动态信息', lottery_info);
/* 遇到转发过就退出 */
if (
((!check_if_duplicated || check_if_duplicated === 2)
&& is_liked)
|| ((check_if_duplicated === 1 || check_if_duplicated === 2)
&& dyids_map.get(dyid))
) {
log.info("筛选动态", `已转发(https://t.bilibili.com/${dyid})`)
return false
switch (lottery_info_type) {
case 'sneaktopic':
log.info("筛选动态", `偷塔模式(https://t.bilibili.com/${dyid})`)
break;
default:
/* 遇到转发过就退出 */
if (
((!check_if_duplicated || check_if_duplicated === 2)
&& is_liked)
|| ((check_if_duplicated === 1 || check_if_duplicated === 2)
&& dyids_map.get(dyid))
) {
log.info("筛选动态", `已转发(https://t.bilibili.com/${dyid})`)
return false
}
}
/* 超过指定时间退出 */
@@ -519,7 +525,7 @@ class Monitor extends Searcher {
let status = 0
const
{ uid, dyid, chat_type, rid, relay_chat, ctrl } = option,
{ chat, check_if_duplicated } = config;
{ chat, check_if_duplicated, is_repost_then_chat } = config;
/* 评论 */
if (rid && chat_type) {
@@ -527,7 +533,11 @@ class Monitor extends Searcher {
status = await retryfn(
5,
[1, 4],
() => bili.sendChat(rid, getRandomOne(chat), chat_type)
() => bili.sendChat(
rid,
is_repost_then_chat ? relay_chat : getRandomOne(chat),
chat_type
)
)
if (status) {
+12
View File
@@ -78,6 +78,12 @@ const config = {
*/
check_if_duplicated: 1,
/**
* 偷塔模式不检查是否重复转发
* * 偷塔模式: 临近开奖时参与抽奖
*/
sneaktopic: true,
/**
* 屏蔽动态类型
*
@@ -260,6 +266,12 @@ const config = {
*/
blockword: ["脚本", "抽奖号", "钓鱼"],
/**
* 转发并评论
* - 评论内容与转发内容相同
*/
is_repost_then_chat: false,
/**
* 转发评语
*/
+1
View File
@@ -12,6 +12,7 @@ module.exports = Object.freeze({
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',
MSGFEED_AT: 'https://api.bilibili.com/x/msgfeed/at',
MSGFEED_REPLAY: 'https://api.bilibili.com/x/msgfeed/reply',
MSGFEED_UNREAD: 'https://api.bilibili.com/x/msgfeed/unread',
READ_CV: 'https://www.bilibili.com/read/cv{{cv}}',
RELATION_BATCH_MODIFY: 'https://api.bilibili.com/x/relation/batch/modify',
+36 -8
View File
@@ -185,22 +185,50 @@ const bili_client = {
}
},
/**
* 获取未读@
* @returns {Promise<number>}
* 获取未读信息数量
* @returns {Promise<{at: number, reply: number}>}
*/
async getUnreadAtNum() {
async getUnreadNum() {
const
responseText = await get({
url: API.MSGFEED_UNREAD
}),
res = strToJson(responseText);
if (res.code === 0) {
const { at } = res.data;
log.info('获取未读@', `成功 数量: ${at}`);
return at;
log.info('获取未读信息', `成功`);
return res.data;
} else {
log.error('获取未读@', `失败\n${responseText}`);
return -1;
log.error('获取未读信息', `失败\n${responseText}`);
return {};
}
},
/**
* 获取一页回复
* @returns {Promise<Array<{nickname: string, source: string, uri: string, timestamp: number}>}>}
*/
async getReplyMsg() {
const
responseText = await get({
url: API.MSGFEED_REPLAY
}),
res = strToJson(responseText);
if (res.code === 0) {
const data = res.data || {},
items = data.items || [];
log.info('获取一页回复', `成功(${items.length})`);
return items
.filter(it => it.item.type === 'reply')
.map(it => {
return {
nickname: it.user.nickname,
source: it.item.source_content,
uri: it.item.uri,
timestamp: it.reply_time
}
});
} else {
log.error('获取一页回复', '失败');
return []
}
},
/**
+12
View File
@@ -92,6 +92,12 @@ module.exports = Object.freeze({
*/
check_if_duplicated: 1,
/**
* 偷塔模式不检查是否重复转发
* * 偷塔模式: 临近开奖时参与抽奖
*/
sneaktopic: true,
/**
* 屏蔽动态类型
*
@@ -275,6 +281,12 @@ module.exports = Object.freeze({
*/
blockword: ["脚本", "抽奖号", "钓鱼"],
/**
* 转发并评论
* - 评论内容与转发内容相同
*/
is_repost_then_chat: false,
/**
* 转发评语
*/
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "lottery-auto-script",
"version": "2.4.5",
"version": "2.4.6",
"description": "自动参与B站动态抽奖",
"main": "main.js",
"scripts": {