From d2d9d31ebfc95ece4806e6b80188ab5ef18bad49 Mon Sep 17 00:00:00 2001 From: shanmite Date: Fri, 30 Jul 2021 17:24:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=82=B9=E8=B5=9E=E5=A4=B1=E8=B4=A5(#7)?= =?UTF-8?q?=20feat:=20=E6=96=B0=E5=A2=9E=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/Monitor.js | 18 +++++++----------- lib/clear.js | 4 ++-- lib/lottery-in-nodejs.js | 6 +++--- main.js | 2 +- my_config.example.js | 14 ++++++++++++++ 5 files changed, 27 insertions(+), 17 deletions(-) diff --git a/lib/Monitor.js b/lib/Monitor.js index d78ead0..fb56492 100644 --- a/lib/Monitor.js +++ b/lib/Monitor.js @@ -62,15 +62,12 @@ class Monitor extends Public { eventBus.emit('Turn_on_the_Monitor') break case 31: - eventBus.emit('Turn_on_the_Monitor') - break - case 41: eventBus.emit('Turn_off_the_Monitor', '转发失败') break - case 51: + case 41: eventBus.emit('Turn_off_the_Monitor', '获取开奖时间失败') break - case 61: + case 51: eventBus.emit('Turn_off_the_Monitor', '获取关注数失败') break default: @@ -95,7 +92,7 @@ class Monitor extends Public { let { ts } = await BiliAPI.getLotteryNotice(Lottery.dyid); const ts_10 = Date.now() / 1000; if (ts < 0) { - return 51 + return 41 } if (ts < ts_10) { log.info('过滤', '已过开奖时间') @@ -110,7 +107,7 @@ class Monitor extends Public { } else if (Lottery.uid[0]) { const followerNum = await BiliAPI.getUserInfo(Lottery.uid[0]); if (followerNum < 0) { - return 61 + return 51 } if (followerNum < config.minfollower) { log.info('过滤', `粉丝数(${followerNum})小于指定数量`) @@ -314,8 +311,7 @@ class Monitor extends Public { * 11 - 评论错误 * 21 - 关注错误 * 22 - 关注异常 - * 31 - 点赞失败 - * 41 - 转发失败 + * 31 - 转发失败 */ async go(option) { log.debug('正在转发的动态信息', option); @@ -356,10 +352,10 @@ class Monitor extends Public { } /* 点赞 */ - if (await BiliAPI.autolike(dyid)) return 31; + await BiliAPI.autolike(dyid) /* 转发 */ - if (await BiliAPI.autoRelay(GlobalVar.get("myUID"), dyid, relay_chat, ctrl)) return 41; + if (await BiliAPI.autoRelay(GlobalVar.get("myUID"), dyid, relay_chat, ctrl)) return 31; return 0 } diff --git a/lib/clear.js b/lib/clear.js index e791c97..5af6230 100644 --- a/lib/clear.js +++ b/lib/clear.js @@ -30,7 +30,7 @@ async function getFollowList() { * 清理动态和关注 */ async function clear() { - const { clear_white_list, clear_max_day, clear_remove_dynamic, clear_remove_attention, clear_remove_delay, clear_dynamic_type } = config; + const { 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) { @@ -38,7 +38,7 @@ async function clear() { } else { log.info('清理关注', `共有${uid_list.length}个关注`) } - if (!clear_remove_dynamic && clear_remove_attention) { + if (clear_quick_remove_attention) { log.info('清理关注', '进入只清理关注模式') /* 专清关注 */ for (const [index, uid] of uid_list.entries()) { diff --git a/lib/lottery-in-nodejs.js b/lib/lottery-in-nodejs.js index 9c022ec..5609a62 100644 --- a/lib/lottery-in-nodejs.js +++ b/lib/lottery-in-nodejs.js @@ -78,7 +78,7 @@ async function isMe() { desp += `在${business}中@了你(${GlobalVar.get("myUID")}) \n\n` desp += `原内容为: ${source_content} \n\n` desp += `[直达链接](${url}) \n\n` - desp += `\n\n\n\n` + desp += `\n\n` }); log.info('中奖检测', '--> OK'); } @@ -93,12 +93,12 @@ async function isMe() { if (talker_id) { BiliAPI.updateSessionStatus(talker_id); await Util.delay(1000); - if (/中奖|获得|填写|写上|提供|收货地址|支付宝账号|码|大会员/.test(content)) { + if (config.notice_key_words.some(it => new RegExp(it).test(content))) { desp += `发生时间: ${new Date(timestamp * 1000).toLocaleString()} \n\n` desp += `用户: ${sender_uid} \n\n` desp += `私信你(${GlobalVar.get("myUID")})说: ${content} \n\n` desp += `[直达链接](https://message.bilibili.com/#/whisper/mid${sender_uid}) \n\n` - desp += `\n\n\n\n` + desp += `\n\n` } } } diff --git a/main.js b/main.js index 210547b..7f2e20c 100644 --- a/main.js +++ b/main.js @@ -10,7 +10,7 @@ const metainfo = [ ` __/ | | | `, ` |___/ |_| `, ` `, - ` v2.0.0 by shanmite`, + ` v2.0.1 by shanmite`, ] /**多账号存储 */ let multiple_account = []; diff --git a/my_config.example.js b/my_config.example.js index 655f396..1d2c911 100644 --- a/my_config.example.js +++ b/my_config.example.js @@ -177,6 +177,14 @@ module.exports = { */ is_exception: false, + /** + * 中奖通知关键词(满足一个就推送) + * 符合js正则表达式的字符串 + */ + notice_key_words: [ + "中奖", "获得", "填写", "写上", "提供", "收货地址", "支付宝账号", "码", "大会员" + ], + /** * - 清理白名单uid或dyid * - 英文逗号分隔 如: 1,2,3 @@ -194,6 +202,12 @@ module.exports = { */ clear_max_day: 30, + /** + * - 快速移除关注 + * - 不加判断只去除关注 + */ + clear_quick_remove_attention: false, + /** * 是否移除动态 */