Update sendNotify.js

This commit is contained in:
Faker 2022-04-06 18:08:07 +08:00
parent 2acf16aff7
commit bc8b768d54

View File

@ -1,30 +1,13 @@
/* /*
* @Author: lxk0301 https://gitee.com/lxk0301
* @Date: 2020-08-19 16:12:40
* @Last Modified by: whyour
* @Last Modified time: 2021-5-1 15:00:54
* sendNotify 推送通知功能 * sendNotify 推送通知功能
* @param text 通知头 * @param text 通知头
* @param desp 通知体 * @param desp 通知体
* @param params 某些推送通知方式点击弹窗可跳转, { url: 'https://abc.com' } * @param params 某些推送通知方式点击弹窗可跳转, { url: 'https://abc.com' }
* @param author 作者仓库等信息 `本通知 Byhttps://github.com/whyour/qinglong` * @param author 作者仓库等信息 `本通知 Byhttps://github.com/whyour/qinglong`
部分变量设置
## 拆分通知
export BEANCHANGE_PERSENT="10"
## 如果通知标题在此变量里面存在(&隔开),则用屏蔽不发送通知
export NOTIFY_SKIP_LIST="京东CK检测&京东资产变动"
## 当接收到发送CK失效通知和Ninja 运行通知时候执行子线程任务
export NOTIFY_CKTASK="jd_CheckCK.js"
## 如果此变量(&隔开)的关键字在通知内容里面存在,则屏蔽不发送通知.
export NOTIFY_SKIP_TEXT="忘了种植&异常"
## 屏蔽任务脚本的ck失效通知
export NOTIFY_NOCKFALSE="true"
## 服务器空数据等错误不触发通知
export CKNOWARNERROR="true"
## 屏蔽青龙登陆成功通知登陆失败不屏蔽
export NOTIFY_NOLOGINSUCCESS="true"
## 通知底部显示
export NOTIFY_AUTHOR="来源于https://github.com/KingRan/KR"
## 增加NOTIFY_AUTHOR_BLANK 环境变量控制不显示底部信息
export NOTIFY_AUTHOR_BLANK="true"
## 增加NOTIFY_AUTOCHECKCK为true才开启通知脚本内置的自动禁用过期ck
export NOTIFY_AUTOCHECKCK=true
*/ */
//详细说明参考 https://github.com/ccwav/QLScript2. //详细说明参考 https://github.com/ccwav/QLScript2.
const querystring = require('querystring'); const querystring = require('querystring');
@ -200,9 +183,10 @@ if (process.env.NOTIFY_SHOWNAMETYPE) {
if (ShowRemarkType == "4") if (ShowRemarkType == "4")
console.log("检测到显示备注名称,格式为: 备注"); console.log("检测到显示备注名称,格式为: 备注");
} }
async function sendNotify(text, desp, params = {}, author = '\n\n本通知 By https://github.com/KingRan/KR',strsummary="") { async function sendNotify(text, desp, params = {}, author = '\n\n本通知 By ccwav Mod', strsummary = "") {
console.log(`开始发送通知...`); console.log(`开始发送通知...`);
//NOTIFY_FILTERBYFILE代码来自Ca11back.
if (process.env.NOTIFY_FILTERBYFILE) { if (process.env.NOTIFY_FILTERBYFILE) {
var no_notify = process.env.NOTIFY_FILTERBYFILE.split('&'); var no_notify = process.env.NOTIFY_FILTERBYFILE.split('&');
if (module.parent.filename) { if (module.parent.filename) {
@ -218,6 +202,7 @@ async function sendNotify(text, desp, params = {}, author = '\n\n本通知 By ht
} }
} }
} }
try { try {
//Reset 变量 //Reset 变量
UseGroupNotify = 1; UseGroupNotify = 1;
@ -420,7 +405,7 @@ async function sendNotify(text, desp, params = {}, author = '\n\n本通知 By ht
} }
if (strtext.indexOf("cookie已失效") != -1 || strdesp.indexOf("重新登录获取") != -1 || strtext == "Ninja 运行通知") { if (strtext.indexOf("cookie已失效") != -1 || strdesp.indexOf("重新登录获取") != -1 || strtext == "Ninja 运行通知") {
if (Notify_NoCKFalse == "true" && text != "Ninja 运行通知") { if (Notify_NoCKFalse == "true" && text != "Ninja 运行通知") {
console.log(`检测到NOTIFY_NOCKFALSE变量为true,不发送ck失效通知...`); console.log(`检测到NOTIFY_NOCKFALSE变量为true,不发送ck失效通知...`);
return; return;
} }
} }
@ -1390,7 +1375,7 @@ async function sendNotify(text, desp, params = {}, author = '\n\n本通知 By ht
} }
if (allCode) { if (allCode) {
desp += '\n' + '\n' + "格式化后的互助码:" + '\n' + allCode; desp += '\n' + '\n' + "ccwav格式化后的互助码:" + '\n' + allCode;
} }
} }
} }
@ -1477,6 +1462,7 @@ async function sendNotify(text, desp, params = {}, author = '\n\n本通知 By ht
$.Remark += Tempinfo; $.Remark += Tempinfo;
} }
} }
desp = desp.replace(new RegExp(`${$.UserName}|${$.nickName}`, 'gm'), $.Remark); desp = desp.replace(new RegExp(`${$.UserName}|${$.nickName}`, 'gm'), $.Remark);
strsummary = strsummary.replace(new RegExp(`${$.UserName}|${$.nickName}`, 'gm'), $.Remark); strsummary = strsummary.replace(new RegExp(`${$.UserName}|${$.nickName}`, 'gm'), $.Remark);
//额外处理2nickName不包含星号但是确实是手机号 //额外处理2nickName不包含星号但是确实是手机号
@ -1486,7 +1472,7 @@ async function sendNotify(text, desp, params = {}, author = '\n\n本通知 By ht
//console.log("额外处理2:"+tempname); //console.log("额外处理2:"+tempname);
text = text.replace(new RegExp(tempname, 'gm'), $.Remark); text = text.replace(new RegExp(tempname, 'gm'), $.Remark);
desp = desp.replace(new RegExp(tempname, 'gm'), $.Remark); desp = desp.replace(new RegExp(tempname, 'gm'), $.Remark);
strsummary = strsummary.replace(new RegExp(tempname, 'gm'), $.Remark); strsummary = strsummary.replace(new RegExp(tempname, 'gm'), $.Remark);
} }
} catch (err) { } catch (err) {
@ -1505,7 +1491,7 @@ async function sendNotify(text, desp, params = {}, author = '\n\n本通知 By ht
} }
console.log("处理完成,开始发送通知..."); console.log("处理完成,开始发送通知...");
if (strAllNotify) { if (strAllNotify) {
desp = strAllNotify+"\n" + desp; desp = strAllNotify + "\n" + desp;
} }
} }
} catch (error) { } catch (error) {
@ -1570,7 +1556,7 @@ async function sendNotify(text, desp, params = {}, author = '\n\n本通知 By ht
tgBotNotify(text, desp), //telegram 机器人 tgBotNotify(text, desp), //telegram 机器人
ddBotNotify(text, desp), //钉钉机器人 ddBotNotify(text, desp), //钉钉机器人
qywxBotNotify(text, desp), //企业微信机器人 qywxBotNotify(text, desp), //企业微信机器人
qywxamNotify(text, desp,strsummary), //企业微信应用消息推送 qywxamNotify(text, desp, strsummary), //企业微信应用消息推送
iGotNotify(text, desp, params), //iGot iGotNotify(text, desp, params), //iGot
gobotNotify(text, desp), //go-cqhttp gobotNotify(text, desp), //go-cqhttp
gotifyNotify(text, desp), //gotify gotifyNotify(text, desp), //gotify
@ -1583,7 +1569,7 @@ function getuuid(strRemark, PtPin) {
if (strRemark) { if (strRemark) {
var Tempindex = strRemark.indexOf("@@"); var Tempindex = strRemark.indexOf("@@");
if (Tempindex != -1) { if (Tempindex != -1) {
console.log(PtPin+": 检测到NVJDC的一对一格式,瑞思拜~!"); console.log(PtPin + ": 检测到NVJDC的一对一格式,瑞思拜~!");
var TempRemarkList = strRemark.split("@@"); var TempRemarkList = strRemark.split("@@");
for (let j = 1; j < TempRemarkList.length; j++) { for (let j = 1; j < TempRemarkList.length; j++) {
if (TempRemarkList[j]) { if (TempRemarkList[j]) {
@ -1647,7 +1633,6 @@ function getQLinfo(strCK, intcreated, strTimestamp, strRemark) {
} }
} }
return strReturn return strReturn
} }