From b1f478cb8ec703349f6d556d4084aff58ffafbef Mon Sep 17 00:00:00 2001 From: shanmite Date: Wed, 2 Mar 2022 19:44:27 +0800 Subject: [PATCH] =?UTF-8?q?=20feat:=20=E5=8F=AF=E9=80=89=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E7=8E=B0=E9=98=B6=E6=AE=B5=E8=BF=90=E8=A1=8C=E5=88=B0=E5=93=AA?= =?UTF-8?q?=E4=B8=AA=E8=B4=A6=E5=8F=B7(#132)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增设置`notice_running_state` Fixed #132 --- lib/data/config.js | 5 +++++ lib/lottery.js | 11 +++++++++-- main.js | 2 +- my_config.example.js | 5 +++++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/data/config.js b/lib/data/config.js index 2d3b4d4..12c5eef 100644 --- a/lib/data/config.js +++ b/lib/data/config.js @@ -317,6 +317,11 @@ const config = { "~你预约的直播已开始" ], + /** + * 是否发送运行状态通知 + */ + notice_running_state: false, + /** * - 获取私信页数 */ diff --git a/lib/lottery.js b/lib/lottery.js index c19a727..4a14438 100644 --- a/lib/lottery.js +++ b/lib/lottery.js @@ -5,6 +5,7 @@ const { Searcher } = require('./core/searcher'); const { Monitor } = require('./core/monitor'); const config = require('./data/config'); const { randomDynamic } = require('./helper/randomDynamic'); +const { sendNotify } = require('./helper/notify'); const { log } = utils; async function createRandomDynamic(num) { @@ -23,12 +24,15 @@ async function createRandomDynamic(num) { /** * 抽奖主函数 - * @param {string} cookie + * @param {string} num * @returns {Promise} */ -function start() { +function start(num) { return new Promise(resolve => { let times = utils.counter(); + if (config.notice_running_state) { + sendNotify(`动态抽奖-帐号${num}开始抽奖`, "运行正常") + } /* 注册事件 */ event_bus.on('Turn_on_the_Monitor', async () => { const lotterys = global_var.get("Lottery"); @@ -48,6 +52,9 @@ function start() { await (new Monitor(lottery)).init(); }); event_bus.on('Turn_off_the_Monitor', async (msg) => { + if (config.notice_running_state) { + sendNotify(`动态抽奖-帐号${num}结束抽奖`, msg) + } await createRandomDynamic(config.create_dy_num); log.info('结束抽奖', '原因: ' + msg); event_bus.flush(); diff --git a/main.js b/main.js index 9d0fcb1..69ebb7f 100644 --- a/main.js +++ b/main.js @@ -61,7 +61,7 @@ async function main() { case 'start': log.info('抽奖', '开始运行'); loop_wait = lottery_loop_wait; - await start(); + await start(NUMBER); break; case 'check': log.info('中奖检测', '检查是否中奖'); diff --git a/my_config.example.js b/my_config.example.js index 88833a4..93de99c 100644 --- a/my_config.example.js +++ b/my_config.example.js @@ -336,6 +336,11 @@ module.exports = Object.freeze({ "~你预约的直播已开始" ], + /** + * 是否发送运行状态通知 + */ + notice_running_state: false, + /** * - 获取私信页数 */