mirror of
https://github.com/shanmiteko/LotteryAutoScript.git
synced 2026-06-04 21:01:17 +08:00
parent
8bf5070459
commit
847e6806c6
@ -66,7 +66,7 @@ class Monitor extends Searcher {
|
||||
case 2004:
|
||||
log.warn('账号异常', `UID(${global_var.get('myUID')})异常号只会对部分UP出现关注异常`)
|
||||
if (!config.is_exception) {
|
||||
await sendNotify('[动态抽奖]账号异常通知', `UID: ${global_var.get('myUID')}\n\n异常号只会对部分UP出现关注异常\n\n可在设置中令is_exception为true关闭此推送`)
|
||||
await sendNotify('[动态抽奖]账号异常通知', `UID: ${global_var.get('myUID')}\n异常号只会对部分UP出现关注异常\n可在设置中令is_exception为true关闭此推送\n${log._cache.filter(it => /Error|\[抽奖信息\]/.test(it)).join('\n')}`)
|
||||
}
|
||||
config.is_exception = true;
|
||||
event_bus.emit('Turn_on_the_Monitor')
|
||||
@ -74,7 +74,7 @@ class Monitor extends Searcher {
|
||||
case 2005:
|
||||
log.warn('关注已达上限', `UID(${global_var.get('myUID')})关注已达上限,已临时进入只转已关注模式`)
|
||||
if (!config.is_outof_maxfollow) {
|
||||
await sendNotify('[动态抽奖]关注已达上限', `UID: ${global_var.get('myUID')}\n\n关注已达上限,已临时进入只转已关注模式\n\n可在设置中令is_outof_maxfollow为true关闭此推送`)
|
||||
await sendNotify('[动态抽奖]关注已达上限', `UID: ${global_var.get('myUID')}\n关注已达上限,已临时进入只转已关注模式\n可在设置中令is_outof_maxfollow为true关闭此推送\n${log._cache.filter(it => /Error|\[抽奖信息\]/.test(it)).join('\n')}`)
|
||||
}
|
||||
config.is_outof_maxfollow = true;
|
||||
config.only_followed = true;
|
||||
|
||||
@ -34,9 +34,6 @@ async function createRandomDynamic(num) {
|
||||
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");
|
||||
@ -56,11 +53,12 @@ function start(num) {
|
||||
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);
|
||||
if (config.notice_running_state) {
|
||||
sendNotify(`动态抽奖-帐号${num}结束抽奖`, `${log._cache.filter(it => /抽奖\]|Error|\[抽奖信息\]/.test(it)).join('\n')}`);
|
||||
}
|
||||
log._cache.length = 0;
|
||||
await createRandomDynamic(config.create_dy_num);
|
||||
event_bus.flush();
|
||||
resolve();
|
||||
})
|
||||
|
||||
48
lib/utils.js
48
lib/utils.js
@ -189,8 +189,8 @@ const utils = {
|
||||
chalk.hex('#64B3FF'), chalk.grey, chalk.hex('#FFA500'),
|
||||
chalk.hex('#0070BB'), chalk.hex('#48BB31'), chalk.hex('#BBBB23'), chalk.hex('#FF0006')
|
||||
],
|
||||
_iso_time: () => new Date(Date.now() + 288e5).toISOString().slice(0, -1) + '+08'
|
||||
,
|
||||
_iso_time: () => new Date(Date.now() + 288e5).toISOString().slice(0, -1) + '+08',
|
||||
_cache: [],
|
||||
/**
|
||||
* 初始化默认level为3
|
||||
*/
|
||||
@ -229,20 +229,50 @@ const utils = {
|
||||
debug(context, msg) {
|
||||
if (this._level > 3) {
|
||||
if (msg instanceof Object) msg = JSON.stringify(msg, null, 4);
|
||||
this.proPrint([this._colors[0](`[${this._iso_time()}]`), this._colors[1]("[Debug]"), this._colors[2](`[帐号${process.env["NUMBER"]} ${context}]`), this._colors[3](`[\n${msg}\n]`)])
|
||||
let color_text_pair = [
|
||||
[this._colors[0], `[${this._iso_time()}]`],
|
||||
[this._colors[1], "[Debug]"],
|
||||
[this._colors[2], `[帐号${process.env["NUMBER"]} ${context}]`],
|
||||
[this._colors[3], `[\n${msg}\n]`],
|
||||
];
|
||||
this.proPrint(color_text_pair.map(([color, text]) => color(text)))
|
||||
}
|
||||
},
|
||||
info(context, msg) {
|
||||
if (this._level > 2)
|
||||
this.proPrint([this._colors[0](`[${this._iso_time()}]`), this._colors[1]("[Info]"), this._colors[2](`[帐号${process.env["NUMBER"]} ${context}]`), this._colors[4](`[${msg}]`)])
|
||||
if (this._level > 2) {
|
||||
let color_text_pair = [
|
||||
[this._colors[0], `[${this._iso_time()}]`],
|
||||
[this._colors[1], "[Info]"],
|
||||
[this._colors[2], `[帐号${process.env["NUMBER"]} ${context}]`],
|
||||
[this._colors[4], `[${msg}]`],
|
||||
];
|
||||
this._cache.push(color_text_pair.map(it => it[1]).join(' '));
|
||||
this.proPrint(color_text_pair.map(([color, text]) => color(text)))
|
||||
}
|
||||
},
|
||||
warn(context, msg) {
|
||||
if (this._level > 1)
|
||||
this.proPrint([this._colors[0](`[${this._iso_time()}]`), this._colors[1]("[Warn]"), this._colors[2](`[帐号${process.env["NUMBER"]} ${context}]`), this._colors[5](`[\n${msg}\n]`)])
|
||||
if (this._level > 1) {
|
||||
let color_text_pair = [
|
||||
[this._colors[0], `[${this._iso_time()}]`],
|
||||
[this._colors[1], "[Warn]"],
|
||||
[this._colors[2], `[帐号${process.env["NUMBER"]} ${context}]`],
|
||||
[this._colors[5], `[\n${msg}\n]`],
|
||||
];
|
||||
this._cache.push(color_text_pair.map(it => it[1]).join(' '));
|
||||
this.proPrint(color_text_pair.map(([color, text]) => color(text)))
|
||||
}
|
||||
},
|
||||
error(context, msg) {
|
||||
if (this._level > 0)
|
||||
this.proPrint([this._colors[0](`[${this._iso_time()}]`), this._colors[1]("[Error]"), this._colors[2](`[帐号${process.env["NUMBER"]} ${context}]`), this._colors[6](`[\n${msg}\n]`)])
|
||||
if (this._level > 0) {
|
||||
let color_text_pair = [
|
||||
[this._colors[0], `[${this._iso_time()}]`],
|
||||
[this._colors[1], "[Error]"],
|
||||
[this._colors[2], `[帐号${process.env["NUMBER"]} ${context}]`],
|
||||
[this._colors[6], `[\n${msg}\n]`],
|
||||
];
|
||||
this._cache.push(color_text_pair.map(it => it[1]).join(' '));
|
||||
this.proPrint(color_text_pair.map(([color, text]) => color(text)))
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user