美化输出

This commit is contained in:
smallfawn
2023-07-11 16:00:31 +08:00
committed by GitHub
parent fc051ba83a
commit 3a13889925

View File

@@ -213,6 +213,7 @@ async function sendNotify(
) { ) {
let pushType = ["smallfawnPushWhite", "smallfawnPushBlack", 'default'] let pushType = ["smallfawnPushWhite", "smallfawnPushBlack", 'default']
/* 判断 黑白名单 或默认模式 */
function checkSmallfawnPushType() { function checkSmallfawnPushType() {
if (process.env.hasOwnProperty(pushType[0]) !== false) { if (process.env.hasOwnProperty(pushType[0]) !== false) {
return pushType[0]; return pushType[0];
@@ -222,6 +223,11 @@ async function sendNotify(
return pushType[2]; return pushType[2];
} }
} }
/**
* 检测 smallfawnPushWhite 或 smallfawnPushBlack 的变量
* @param {*} variable smallfawnPushWhite 或 smallfawnPushBlack
* @returns 数组
*/
function checkSmallfawnPush(variable) { function checkSmallfawnPush(variable) {
if (typeof variable === 'string') { if (typeof variable === 'string') {
if (variable.includes('&') || variable.includes('#') || variable.includes('@')) { if (variable.includes('&') || variable.includes('#') || variable.includes('@')) {
@@ -235,24 +241,23 @@ async function sendNotify(
return []; return [];
} }
} }
let type = checkSmallfawnPushType() let type = checkSmallfawnPushType()
console.log(`\n\n============================================= \nsmallfawn脚本通知 - 北京时间(UTC+8)${new Date(
new Date().getTime() + new Date().getTimezoneOffset() * 60 * 1000 +
8 * 60 * 60 * 1000).toLocaleString()}`)
// 主要 //
//判断是否是默认通知方式
if (type !== pushType[2]) { if (type !== pushType[2]) {
//判断数组长度
if (checkSmallfawnPush(process.env[type]).length == 0) { if (checkSmallfawnPush(process.env[type]).length == 0) {
console.log(`[${type}]长度为0 默认形式发送`); console.log(`[${type}]长度为0 默认形式发送`);
await push() await push()
return
} else { } else {
//判断黑白名单模式
if (type == pushType[0]) { if (type == pushType[0]) {
console.log(`通知变量为白名单模式`); console.log(`通知变量为白名单模式`);
/*for (let sm of checkSmallfawnPush(process.env[pushType[0]])) {
if (text == sm) {
console.log(`根据[${type}]变量来选择通知`);
await push()
return
} else {
//console.log(`[${type}]未含有该脚本的env名字不通知`)
}
}*/
if (checkSmallfawnPush(process.env[pushType[0]]).includes(text)) { if (checkSmallfawnPush(process.env[pushType[0]]).includes(text)) {
console.log(`根据[${type}]变量来选择通知`); console.log(`根据[${type}]变量来选择通知`);
await push(); await push();
@@ -261,15 +266,6 @@ async function sendNotify(
} }
} else if (type == pushType[1]) { } else if (type == pushType[1]) {
console.log(`通知变量为黑名单模式`); console.log(`通知变量为黑名单模式`);
/*for (let sm of checkSmallfawnPush(process.env[pushType[1]])) {
if (text == sm) {
console.log(`根据[${type}]变量来选择不通知`);
} else {
console.log(`[${type}]未含有该脚本的env名字通知`);
await push()
return
}
}*/
if (checkSmallfawnPush(process.env[pushType[1]]).includes(text)) { if (checkSmallfawnPush(process.env[pushType[1]]).includes(text)) {
console.log(`根据[${type}]变量来选择不通知`); console.log(`根据[${type}]变量来选择不通知`);
await push(); await push();
@@ -281,10 +277,8 @@ async function sendNotify(
} else { } else {
console.log(`不启动黑白名单模式 启动默认形式发送`); console.log(`不启动黑白名单模式 启动默认形式发送`);
await push() await push()
return
} }
async function push() { async function push() {
//提供6种通知 //提供6种通知
desp += author; //增加作者信息,防止被贩卖等 desp += author; //增加作者信息,防止被贩卖等