feat: 可选通知现阶段运行到哪个账号(#132)

新增设置`notice_running_state`
 Fixed #132
This commit is contained in:
shanmite 2022-03-02 19:44:27 +08:00
parent 39d69e0448
commit b1f478cb8e
4 changed files with 20 additions and 3 deletions

View File

@ -317,6 +317,11 @@ const config = {
"~你预约的直播已开始"
],
/**
* 是否发送运行状态通知
*/
notice_running_state: false,
/**
* - 获取私信页数
*/

View File

@ -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<void>}
*/
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();

View File

@ -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('中奖检测', '检查是否中奖');

View File

@ -336,6 +336,11 @@ module.exports = Object.freeze({
"~你预约的直播已开始"
],
/**
* 是否发送运行状态通知
*/
notice_running_state: false,
/**
* - 获取私信页数
*/