diff --git a/lib/lottery-in-nodejs.js b/lib/lottery-in-nodejs.js index 9f97e51..70b1e4b 100644 --- a/lib/lottery-in-nodejs.js +++ b/lib/lottery-in-nodejs.js @@ -59,29 +59,33 @@ const pushplus = (text, desp) => { /** * 主函数 * @param {string} cookie + * @returns {Promise} */ function start() { - let times = Base.counter(); - /* 注册事件 */ - eventBus.on('Turn_on_the_Monitor', () => { - if (times.value() === GlobalVar.Lottery.length) { - console.log('所有动态转发完毕'); - console.log('[运行结束]目前无抽奖信息,过一会儿再来看看吧'); - times.clear(); - Public.prototype.checkAllDynamic(GlobalVar.myUID, 1).then(Dynamic => { - if (Dynamic.allModifyDynamicResArray[0].type === 1) { - Base.getHiToKoTo().then(sentence => { - BiliAPI.createDynamic(sentence); - }) - } - }) - return; - } - const lottery = GlobalVar.Lottery[times.next()]; - const nlottery = Number(lottery); - (new Monitor(isNaN(nlottery) ? lottery : nlottery)).init(); + return new Promise(resolve => { + let times = Base.counter(); + /* 注册事件 */ + eventBus.on('Turn_on_the_Monitor', () => { + if (times.value() === GlobalVar.Lottery.length) { + console.log('所有动态转发完毕'); + console.log('[运行结束]目前无抽奖信息,过一会儿再来看看吧'); + times.clear(); + Public.prototype.checkAllDynamic(GlobalVar.myUID, 1).then(Dynamic => { + if (Dynamic.allModifyDynamicResArray[0].type === 1) { + Base.getHiToKoTo().then(sentence => { + BiliAPI.createDynamic(sentence); + }) + } + }) + resolve() + return + } + const lottery = GlobalVar.Lottery[times.next()]; + const nlottery = Number(lottery); + (new Monitor(isNaN(nlottery) ? lottery : nlottery)).init(); + }); + eventBus.emit('Turn_on_the_Monitor'); }); - eventBus.emit('Turn_on_the_Monitor'); } /** diff --git a/main.js b/main.js index 48ba076..0c7efe6 100644 --- a/main.js +++ b/main.js @@ -29,4 +29,5 @@ const { NUMBER, CLEAR, COOKIE, SCKEY, PUSH_PLUS_TOKEN } = process.env; break; } } + process.exit(0) }))();