fix: promise包装start()

This commit is contained in:
shanmite 2021-02-23 11:22:27 +08:00
parent 9420037305
commit 8c53ddd23f
2 changed files with 25 additions and 20 deletions

View File

@ -59,29 +59,33 @@ const pushplus = (text, desp) => {
/**
* 主函数
* @param {string} cookie
* @returns {Promise<void>}
*/
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');
}
/**

View File

@ -29,4 +29,5 @@ const { NUMBER, CLEAR, COOKIE, SCKEY, PUSH_PLUS_TOKEN } = process.env;
break;
}
}
process.exit(0)
}))();