2024-06-28 07:47:44 +00:00
/ *
* @ Author : ccwav https : //github.com/ccwav/QLScript2
* sendNotify 推送通知功能 ( text , desp , params , author , strsummary )
* @ param text 通知标题 ( 必要 )
* @ param desp 通知内容 ( 必要 )
* @ param params 某些推送通知方式点击弹窗可跳转 , 例 : { url : 'https://abc.com' } , 没啥用 , 只是为了兼容旧脚本保留 ( 非必要 )
* @ param author 通知底部作者 ` (非必要)
* @ param strsummary 指定某些微信模板通知的预览信息 , 空则默认为desp ( 非必要 )
* sendNotifybyWxPucher 一对一推送通知功能 ( text , desp , PtPin , author , strsummary )
* @ param text 通知标题 ( 必要 )
* @ param desp 通知内容 ( 必要 )
* @ param PtPin CK的PTPIN ( 必要 )
* @ param author 通知底部作者 ` (非必要)
* @ param strsummary 指定某些微信模板通知的预览信息 , 空则默认为desp ( 非必要 )
* /
//详细说明参考 https://github.com/ccwav/QLScript2.
const querystring = require ( 'querystring' ) ;
const exec = require ( 'child_process' ) . exec ;
const $ = new Env ( ) ;
const timeout = 15000 ; //超时时间(单位毫秒)
2024-09-06 15:20:59 +00:00
//console.log("加载sendNotify, 当前版本: 20230712");
2024-06-28 07:47:44 +00:00
// =======================================go-cqhttp通知设置区域===========================================
//gobot_url 填写请求地址http://127.0.0.1/send_private_msg
//gobot_token 填写在go-cqhttp文件设置的访问密钥
//gobot_qq 填写推送到个人QQ或者QQ群号
//go-cqhttp相关API https://docs.go-cqhttp.org/api
let GOBOT _URL = '' ; // 推送到个人QQ: http://127.0.0.1/send_private_msg 群: http://127.0.0.1/send_group_msg
let GOBOT _TOKEN = '' ; //访问密钥
let GOBOT _QQ = '' ; // 如果GOBOT_URL设置 /send_private_msg 则需要填入 user_id=个人QQ 相反如果是 /send_group_msg 则需要填入 group_id=QQ群
// =======================================微信server酱通知设置区域===========================================
//此处填你申请的SCKEY.
//(环境变量名 PUSH_KEY)
let SCKEY = '' ;
// =======================================PushDeer通知设置区域===========================================
//此处填你申请的PushDeer KEY.
//(环境变量名 DEER_KEY)
let PUSHDEER _KEY = '' ;
// =======================================Bark App通知设置区域===========================================
//此处填你BarkAPP的信息(IP/设备码, 例如: https://api.day.app/XXXXXXXX)
let BARK _PUSH = '' ;
//BARK app推送铃声,铃声列表去APP查看复制填写
let BARK _SOUND = '' ;
//BARK app推送消息的分组, 默认为"QingLong"
let BARK _GROUP = 'QingLong' ;
// =======================================telegram机器人通知设置区域===========================================
//此处填你telegram bot 的Token, telegram机器人通知推送必填项.例如: 1077xxx4424:AAFjv0FcqxxxxxxgEMGfi22B4yh15R5uw
//(环境变量名 TG_BOT_TOKEN)
let TG _BOT _TOKEN = '' ;
//此处填你接收通知消息的telegram用户的id, telegram机器人通知推送必填项.例如: 129xxx206
//(环境变量名 TG_USER_ID)
let TG _USER _ID = '' ;
//tg推送HTTP代理设置(不懂可忽略,telegram机器人通知推送功能中非必填)
let TG _PROXY _HOST = '' ; //例如:127.0.0.1(环境变量名:TG_PROXY_HOST)
let TG _PROXY _PORT = '' ; //例如:1080(环境变量名:TG_PROXY_PORT)
let TG _PROXY _AUTH = '' ; //tg代理配置认证参数
//Telegram api自建的反向代理地址(不懂可忽略,telegram机器人通知推送功能中非必填),默认tg官方api(环境变量名:TG_API_HOST)
let TG _API _HOST = 'api.telegram.org' ;
// =======================================钉钉机器人通知设置区域===========================================
//此处填你钉钉 bot 的webhook, 例如: 5a544165465465645d0f31dca676e7bd07415asdasd
//(环境变量名 DD_BOT_TOKEN)
let DD _BOT _TOKEN = '' ;
//密钥, 机器人安全设置页面, 加签一栏下面显示的SEC开头的字符串
let DD _BOT _SECRET = '' ;
// =======================================企业微信机器人通知设置区域===========================================
//此处填你企业微信机器人的 webhook(详见文档 https://work.weixin.qq.com/api/doc/90000/90136/91770), 例如: 693a91f6-7xxx-4bc4-97a0-0ec2sifa5aaa
//(环境变量名 QYWX_KEY)
let QYWX _KEY = '' ;
// =======================================企业微信应用消息通知设置区域===========================================
/ *
此处填你企业微信应用消息的值 ( 详见文档 https : //work.weixin.qq.com/api/doc/90000/90135/90236)
环境变量名 QYWX _AM依次填入 corpid , corpsecret , touser ( 注 : 多个成员ID使用 | 隔开 ) , agentid , 消息类型 ( 选填 , 不填默认文本消息类型 )
注意用 , 号隔开 ( 英文输入法的逗号 ) , 例如 : wwcff56746d9adwers , B - 791548 lnzXBE6 _BWfxdf3kSTMJr9vFEPKAbh6WERQ , mingcheng , 1000001 , 2 COXgjH2UIfERF2zxrtUOKgQ9XklUqMdGSWLBoW _lSDAdafat
可选推送消息类型 ( 推荐使用图文消息 ( mpnews ) ) :
- 文本卡片消息 : 0 ( 数字零 )
- 文本消息 : 1 ( 数字一 )
- 图文消息 ( mpnews ) : 素材库图片id , 可查看此教程 ( http : //note.youdao.com/s/HMiudGkb)或者(https://note.youdao.com/ynoteshare1/index.html?id=1a0c8aff284ad28cbd011b29b3ad0191&type=note)
* /
let QYWX _AM = '' ;
// =======================================飞书机器人通知设置区域===========================================
//此处填你飞书机器人的 webhook(详见文档 https://open.feishu.cn/document/ukTMukTMukTM/ucTM5YjL3ETO24yNxkjN)
//(环境变量名 FS_KEY)
let FS _KEY = '' ;
// =======================================iGot聚合推送通知设置区域===========================================
//此处填您iGot的信息(推送key, 例如: https://push.hellyw.com/XXXXXXXX)
let IGOT _PUSH _KEY = '' ;
// =======================================push+设置区域=======================================
//官方文档: http://www.pushplus.plus/
//PUSH_PLUS_TOKEN: 微信扫码登录后一对一推送或一对多推送下面的token(您的Token), 不提供PUSH_PLUS_USER则默认为一对一推送
//PUSH_PLUS_USER: 一对多推送的“群组编码”(一对多推送下面->您的群组(如无则新建)->群组编码,如果您是创建群组人。也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送)
let PUSH _PLUS _TOKEN = '' ;
let PUSH _PLUS _USER = '' ;
// ======================================= WxPusher 通知设置区域 ===========================================
// 此处填你申请的 appToken. 官方文档: https://wxpusher.zjiecode.com/docs
// WP_APP_TOKEN 可在管理台查看: https://wxpusher.zjiecode.com/admin/main/app/appToken
// WP_TOPICIDS 群发, 发送目标的 topicId, 以 ; 分隔! 使用 WP_UIDS 单发的时候, 可以不传
// WP_UIDS 发送目标的 uid, 以 ; 分隔。注意 WP_UIDS 和 WP_TOPICIDS 可以同时填写, 也可以只填写一个。
// WP_URL 原文链接, 可选参数
let WP _APP _TOKEN = "" ;
let WP _TOPICIDS = "" ;
let WP _UIDS = "" ;
let WP _URL = "" ;
let WP _APP _TOKEN _ONE = "" ;
if ( process . env . WP _APP _TOKEN _ONE ) {
WP _APP _TOKEN _ONE = process . env . WP _APP _TOKEN _ONE ;
}
let WP _UIDS _ONE = "" ;
// =======================================gotify通知设置区域==============================================
//gotify_url 填写gotify地址,如https://push.example.de:8080
//gotify_token 填写gotify的消息应用token
//gotify_priority 填写推送消息优先级,默认为0
let GOTIFY _URL = '' ;
let GOTIFY _TOKEN = '' ;
let GOTIFY _PRIORITY = 0 ;
// =======================================BncrBot通知设置区域==============================================
//BncrHost 填写BncrHost地址,如https://192.168.31.192:9090
//BncrToken 填写Bncr的消息应用Token
let BncrHost = '' ;
let BncrToken = '' ;
let PushErrorTime = 0 ;
let strTitle = "" ;
let ShowRemarkType = "1" ;
let Notify _NoCKFalse = "false" ;
let Notify _NoLoginSuccess = "false" ;
let UseGroupNotify = 1 ;
//const {
// getEnvs,
// DisableCk,
// getEnvByPtPin
//} = require('./function/ql');
const fs = require ( 'fs' ) ;
let isnewql = fs . existsSync ( '/ql/data/config/auth.json' ) ;
let strCKFile = "" ;
let strUidFile = "" ;
if ( isnewql ) {
strCKFile = '/ql/data/scripts/CKName_cache.json' ;
strUidFile = '/ql/data/scripts/CK_WxPusherUid.json' ;
} else {
strCKFile = '/ql/scripts/CKName_cache.json' ;
strUidFile = '/ql/scripts/CK_WxPusherUid.json' ;
}
let Fileexists = fs . existsSync ( strCKFile ) ;
let TempCK = [ ] ;
if ( Fileexists ) {
//console.log("检测到别名缓存文件CKName_cache.json, 载入...");
TempCK = fs . readFileSync ( strCKFile , 'utf-8' ) ;
if ( TempCK ) {
TempCK = TempCK . toString ( ) ;
TempCK = JSON . parse ( TempCK ) ;
}
}
let UidFileexists = fs . existsSync ( strUidFile ) ;
let TempCKUid = [ ] ;
if ( UidFileexists ) {
//console.log("检测到一对一Uid文件WxPusherUid.json, 载入...");
TempCKUid = fs . readFileSync ( strUidFile , 'utf-8' ) ;
if ( TempCKUid ) {
TempCKUid = TempCKUid . toString ( ) ;
TempCKUid = JSON . parse ( TempCKUid ) ;
}
}
let tempAddCK = { } ;
let boolneedUpdate = false ;
let strCustom = "" ;
let strCustomArr = [ ] ;
let strCustomTempArr = [ ] ;
let Notify _CKTask = "" ;
let Notify _SkipText = [ ] ;
let isLogin = false ;
if ( process . env . NOTIFY _SHOWNAMETYPE ) {
ShowRemarkType = process . env . NOTIFY _SHOWNAMETYPE ;
}
async function sendNotify ( text , desp , params = { } , author = "\n================================\n好物推荐: https://u.jd.com/WLEVYTM" , strsummary = "" ) {
console . log ( ` 开始发送通知... ` ) ;
//NOTIFY_FILTERBYFILE代码来自Ca11back.
if ( process . env . NOTIFY _FILTERBYFILE ) {
var no _notify = process . env . NOTIFY _FILTERBYFILE . split ( '&' ) ;
if ( module . parent . filename ) {
const script _name = module . parent . filename . split ( '/' ) . slice ( - 1 ) [ 0 ] ;
if ( no _notify . some ( key _word => {
const flag = script _name . includes ( key _word ) ;
if ( flag ) {
console . log ( ` ${ script _name } 含有关键字 ${ key _word } ,不推送 ` ) ;
}
return flag ;
} ) ) {
return ;
}
}
}
try {
//Reset 变量
UseGroupNotify = 1 ;
strTitle = "" ;
GOBOT _URL = '' ;
GOBOT _TOKEN = '' ;
GOBOT _QQ = '' ;
SCKEY = '' ;
PUSHDEER _KEY = '' ;
BARK _PUSH = '' ;
BARK _SOUND = '' ;
BARK _GROUP = 'QingLong' ;
TG _BOT _TOKEN = '' ;
TG _USER _ID = '' ;
TG _PROXY _HOST = '' ;
TG _PROXY _PORT = '' ;
TG _PROXY _AUTH = '' ;
TG _API _HOST = 'api.telegram.org' ;
DD _BOT _TOKEN = '' ;
DD _BOT _SECRET = '' ;
QYWX _KEY = '' ;
QYWX _AM = '' ;
FS _KEY = '' ;
IGOT _PUSH _KEY = '' ;
PUSH _PLUS _TOKEN = '' ;
PUSH _PLUS _USER = '' ;
Notify _CKTask = "" ;
Notify _SkipText = [ ] ;
//变量开关
var Use _serverNotify = true ;
var Use _pushdeerNotify = true ;
var Use _pushPlusNotify = true ;
var Use _BarkNotify = true ;
var Use _tgBotNotify = true ;
var Use _ddBotNotify = true ;
var Use _qywxBotNotify = true ;
var Use _qywxamNotify = true ;
var Use _fsBotNotify = true ;
var Use _iGotNotify = true ;
var Use _gobotNotify = true ;
var Use _WxPusher = true ;
var strtext = text ;
var strdesp = desp ;
var titleIndex = - 1 ;
if ( process . env . NOTIFY _NOCKFALSE ) {
Notify _NoCKFalse = process . env . NOTIFY _NOCKFALSE ;
}
if ( process . env . NOTIFY _NOLOGINSUCCESS ) {
Notify _NoLoginSuccess = process . env . NOTIFY _NOLOGINSUCCESS ;
}
if ( process . env . NOTIFY _CKTASK ) {
Notify _CKTask = process . env . NOTIFY _CKTASK ;
}
if ( process . env . NOTIFY _SKIP _TEXT && desp ) {
Notify _SkipText = process . env . NOTIFY _SKIP _TEXT . split ( '&' ) ;
if ( Notify _SkipText . length > 0 ) {
for ( var Templ in Notify _SkipText ) {
if ( desp . indexOf ( Notify _SkipText [ Templ ] ) != - 1 ) {
console . log ( "检测内容到内容存在屏蔽推送的关键字(" + Notify _SkipText [ Templ ] + "),将跳过推送..." ) ;
return ;
}
}
}
}
if ( text . indexOf ( "cookie已失效" ) != - 1 || desp . indexOf ( "重新登录获取" ) != - 1 || text == "Ninja 运行通知" ) {
if ( Notify _CKTask ) {
console . log ( "触发CK脚本, 开始执行...." ) ;
await exec ( ` ps -ef|grep -v grep|grep ${ Notify _CKTask } ` , async function ( err , stdout , stderr ) {
if ( ! stdout ) {
Notify _CKTask = "task " + Notify _CKTask + " now" ;
console . log ( Notify _CKTask )
await exec ( Notify _CKTask ) ;
} else {
console . log ( '已有相同任务在执行,跳过此次执行!\n' )
return
}
} )
}
}
if ( process . env . NOTIFY _AUTOCHECKCK == "true" ) {
if ( text . indexOf ( "cookie已失效" ) != - 1 || desp . indexOf ( "重新登录获取" ) != - 1 ) {
console . log ( ` 捕获CK过期通知, 开始尝试处理... ` ) ;
var strPtPin = await GetPtPin ( text ) ;
var strdecPtPin = decodeURIComponent ( strPtPin ) ;
var llHaderror = false ;
if ( strPtPin ) {
var temptest = await getEnvByPtPin ( strdecPtPin ) ;
if ( temptest ) {
if ( temptest . status == 0 ) {
isLogin = true ;
await isLoginByX1a0He ( temptest . value ) ;
if ( ! isLogin ) {
var tempid = 0 ;
if ( temptest . _id ) {
tempid = temptest . _id ;
}
if ( temptest . id ) {
tempid = temptest . id ;
}
const DisableCkBody = await DisableCk ( tempid ) ;
strPtPin = temptest . value ;
strPtPin = ( strPtPin . match ( /pt_pin=([^; ]+)(?=;?)/ ) && strPtPin . match ( /pt_pin=([^; ]+)(?=;?)/ ) [ 1 ] ) ;
var strAllNotify = "" ;
var MessageUserGp2 = "" ;
var MessageUserGp3 = "" ;
var MessageUserGp4 = "" ;
var userIndex2 = - 1 ;
var userIndex3 = - 1 ;
var userIndex4 = - 1 ;
var strNotifyOneTemp = "" ;
if ( $ . isNode ( ) && process . env . BEANCHANGE _USERGP2 ) {
MessageUserGp2 = process . env . BEANCHANGE _USERGP2 ? process . env . BEANCHANGE _USERGP2 . split ( '&' ) : [ ] ;
}
if ( $ . isNode ( ) && process . env . BEANCHANGE _USERGP3 ) {
MessageUserGp3 = process . env . BEANCHANGE _USERGP3 ? process . env . BEANCHANGE _USERGP3 . split ( '&' ) : [ ] ;
}
if ( $ . isNode ( ) && process . env . BEANCHANGE _USERGP4 ) {
MessageUserGp4 = process . env . BEANCHANGE _USERGP4 ? process . env . BEANCHANGE _USERGP4 . split ( '&' ) : [ ] ;
}
if ( MessageUserGp4 ) {
userIndex4 = MessageUserGp4 . findIndex ( ( item ) => item === strPtPin ) ;
}
if ( MessageUserGp2 ) {
userIndex2 = MessageUserGp2 . findIndex ( ( item ) => item === strPtPin ) ;
}
if ( MessageUserGp3 ) {
userIndex3 = MessageUserGp3 . findIndex ( ( item ) => item === strPtPin ) ;
}
if ( userIndex2 != - 1 ) {
console . log ( ` 该账号属于分组2 ` ) ;
text = "京东CK检测#2" ;
}
if ( userIndex3 != - 1 ) {
console . log ( ` 该账号属于分组3 ` ) ;
text = "京东CK检测#3" ;
}
if ( userIndex4 != - 1 ) {
console . log ( ` 该账号属于分组4 ` ) ;
text = "京东CK检测#4" ;
}
if ( userIndex4 == - 1 && userIndex2 == - 1 && userIndex3 == - 1 ) {
text = "京东CK检测" ;
}
if ( process . env . CHECKCK _ALLNOTIFY ) {
strAllNotify = process . env . CHECKCK _ALLNOTIFY ;
/ * i f ( s t r T e m p N o t i f y . l e n g t h > 0 ) {
for ( var TempNotifyl in strTempNotify ) {
strAllNotify += strTempNotify [ TempNotifyl ] + '\n' ;
}
} * /
console . log ( ` 检测到设定了温馨提示,将在推送信息中置顶显示... ` ) ;
strAllNotify = ` \n 【✨✨✨✨温馨提示✨✨✨✨】 \n ` + strAllNotify ;
console . log ( strAllNotify ) ;
}
if ( DisableCkBody . code == 200 ) {
console . log ( ` 京东账号 ` + strdecPtPin + ` 已失效,自动禁用成功! \n ` ) ;
strNotifyOneTemp = ` 京东账号: ` + strdecPtPin + ` 已失效,已自动禁用! \n 如果要继续挂机, 请重新登录账号, 账号有效期为30天. ` ;
strNotifyOneTemp += "\n任务标题: " + strtext ;
if ( strAllNotify )
strNotifyOneTemp += ` \n ` + strAllNotify ;
desp = strNotifyOneTemp ;
if ( WP _APP _TOKEN _ONE ) {
await sendNotifybyWxPucher ( ` 账号过期下线通知 ` , strNotifyOneTemp , strdecPtPin ) ;
}
} else {
console . log ( ` 京东账号 ` + strPtPin + ` 已失效,自动禁用失败! \n ` ) ;
strNotifyOneTemp = ` 京东账号: ` + strdecPtPin + ` 已失效! \n 如果要继续挂机, 请重新登录账号, 账号有效期为30天. ` ;
strNotifyOneTemp += "\n任务标题: " + strtext ;
if ( strAllNotify )
strNotifyOneTemp += ` \n ` + strAllNotify ;
desp = strNotifyOneTemp ;
if ( WP _APP _TOKEN _ONE ) {
await sendNotifybyWxPucher ( ` 账号过期下线通知 ` , strNotifyOneTemp , strdecPtPin ) ;
}
}
} else {
console . log ( ` 该CK已经检测没有有效, 跳过通知... ` ) ;
llHaderror = true ;
}
} else {
console . log ( ` 该CK已经禁用不需要处理 ` ) ;
llHaderror = true ;
}
}
} else {
console . log ( ` CK过期通知处理失败... ` ) ;
}
if ( llHaderror )
return ;
}
}
if ( strtext . indexOf ( "cookie已失效" ) != - 1 || strdesp . indexOf ( "重新登录获取" ) != - 1 || strtext == "Ninja 运行通知" ) {
if ( Notify _NoCKFalse == "true" && text != "Ninja 运行通知" ) {
console . log ( ` 检测到NOTIFY_NOCKFALSE变量为true,不发送ck失效通知... ` ) ;
return ;
}
}
if ( text . indexOf ( "已可领取" ) != - 1 ) {
if ( text . indexOf ( "农场" ) != - 1 ) {
strTitle = "东东农场领取" ;
} else {
strTitle = "东东萌宠领取" ;
}
}
if ( text . indexOf ( "汪汪乐园养joy" ) != - 1 ) {
strTitle = "汪汪乐园养joy领取" ;
}
if ( text == "京喜工厂" ) {
if ( desp . indexOf ( "元造进行兑换" ) != - 1 ) {
strTitle = "京喜工厂领取" ;
}
}
if ( text . indexOf ( "任务" ) != - 1 && ( text . indexOf ( "新增" ) != - 1 || text . indexOf ( "删除" ) != - 1 ) ) {
strTitle = "脚本任务更新" ;
}
if ( strTitle ) {
const notifyRemindList = process . env . NOTIFY _NOREMIND ? process . env . NOTIFY _NOREMIND . split ( '&' ) : [ ] ;
titleIndex = notifyRemindList . findIndex ( ( item ) => item === strTitle ) ;
if ( titleIndex !== - 1 ) {
console . log ( ` ${ text } 在领取信息黑名单中,已跳过推送 ` ) ;
return ;
}
} else {
strTitle = text ;
}
if ( Notify _NoLoginSuccess == "true" ) {
if ( desp . indexOf ( "登陆成功" ) != - 1 ) {
console . log ( ` 登陆成功不推送 ` ) ;
return ;
}
}
if ( strTitle == "汪汪乐园养joy领取" && WP _APP _TOKEN _ONE ) {
console . log ( ` 捕获汪汪乐园养joy领取通知, 开始尝试一对一推送... ` ) ;
var strPtPin = await GetPtPin ( text ) ;
var strdecPtPin = decodeURIComponent ( strPtPin ) ;
if ( strPtPin ) {
await sendNotifybyWxPucher ( "汪汪乐园领取通知" , ` 【京东账号】 ${ strdecPtPin } \n 当前等级: 30 \n 请到京东极速版APP提现6.66 \n 活动入口: 京东极速版APP->我的->汪汪乐园->点礼包 ` , strdecPtPin ) ;
}
}
console . log ( "通知标题: " + strTitle ) ;
//检查黑名单屏蔽通知
const notifySkipList = process . env . NOTIFY _SKIP _LIST ? process . env . NOTIFY _SKIP _LIST . split ( '&' ) : [ ] ;
titleIndex = notifySkipList . findIndex ( ( item ) => item === strTitle ) ;
if ( titleIndex !== - 1 ) {
console . log ( ` ${ strTitle } 在推送黑名单中,已跳过推送 ` ) ;
return ;
}
//检查脚本名称是否需要通知到Group2,Group2读取原环境配置的变量名后加2的值.例如: QYWX_AM2
for ( lncount = 2 ; lncount < 20 ; lncount ++ ) {
if ( process . env [ "NOTIFY_GROUP" + lncount + "_LIST" ] ) {
const strtemp = process . env [ "NOTIFY_GROUP" + lncount + "_LIST" ] ;
const notifyGroupList = strtemp ? strtemp . split ( '&' ) : [ ] ;
const titleIndex = notifyGroupList . findIndex ( ( item ) => item === strTitle ) ;
if ( titleIndex !== - 1 ) {
console . log ( ` ${ strTitle } 在群组 ${ lncount } 推送名单中,初始化群组推送 ` ) ;
UseGroupNotify = lncount ;
}
}
}
if ( process . env . NOTIFY _CUSTOMNOTIFY ) {
strCustom = process . env . NOTIFY _CUSTOMNOTIFY ;
strCustomArr = strCustom . replace ( /^\[|\]$/g , "" ) . split ( "," ) ;
strCustomTempArr = [ ] ;
for ( var Tempj in strCustomArr ) {
strCustomTempArr = strCustomArr [ Tempj ] . split ( "&" ) ;
if ( strCustomTempArr . length > 1 ) {
if ( strTitle == strCustomTempArr [ 0 ] ) {
console . log ( "检测到自定义设定,开始执行配置..." ) ;
if ( strCustomTempArr [ 1 ] . indexOf ( "组" ) != - 1 ) {
UseGroupNotify = strCustomTempArr [ 1 ] . replace ( "组" , "" ) * 1 ;
console . log ( "自定义设定强制使用组" + UseGroupNotify + "配置通知..." ) ;
} else {
UseGroupNotify = 1 ;
}
if ( strCustomTempArr . length > 2 ) {
console . log ( "关闭所有通知变量..." ) ;
Use _serverNotify = false ;
Use _pushdeerNotify = false ;
Use _pushPlusNotify = false ;
Use _BarkNotify = false ;
Use _tgBotNotify = false ;
Use _ddBotNotify = false ;
Use _qywxBotNotify = false ;
Use _fsBotNotify = false ;
Use _qywxamNotify = false ;
Use _iGotNotify = false ;
Use _gobotNotify = false ;
for ( let Tempk = 2 ; Tempk < strCustomTempArr . length ; Tempk ++ ) {
var strTrmp = strCustomTempArr [ Tempk ] ;
switch ( strTrmp ) {
case "Server酱" :
Use _serverNotify = true ;
console . log ( "自定义设定启用Server酱进行通知..." ) ;
break ;
case "pushdeer" :
Use _pushdeerNotify = true ;
console . log ( "自定义设定启用pushdeer进行通知..." ) ;
break ;
case "pushplus" :
Use _pushPlusNotify = true ;
console . log ( "自定义设定启用pushplus(推送加)进行通知..." ) ;
break ;
case "Bark" :
Use _BarkNotify = true ;
console . log ( "自定义设定启用Bark进行通知..." ) ;
break ;
case "TG机器人" :
Use _tgBotNotify = true ;
console . log ( "自定义设定启用telegram机器人进行通知..." ) ;
break ;
case "钉钉" :
Use _ddBotNotify = true ;
console . log ( "自定义设定启用钉钉机器人进行通知..." ) ;
break ;
case "企业微信机器人" :
Use _qywxBotNotify = true ;
console . log ( "自定义设定启用企业微信机器人进行通知..." ) ;
break ;
case "企业微信应用消息" :
Use _qywxamNotify = true ;
console . log ( "自定义设定启用企业微信应用消息进行通知..." ) ;
break ;
case "飞书机器人" :
Use _fsBotNotify = true ;
console . log ( "自定义设定启用飞书机器人进行通知..." ) ;
break ;
case "iGotNotify" :
Use _iGotNotify = true ;
console . log ( "自定义设定启用iGot进行通知..." ) ;
break ;
case "gobotNotify" :
Use _gobotNotify = true ;
console . log ( "自定义设定启用go-cqhttp进行通知..." ) ;
break ;
case "WxPusher" :
Use _WxPusher = true ;
console . log ( "自定义设定启用WxPusher进行通知..." ) ;
break ;
}
}
}
}
}
}
}
if ( desp ) {
for ( lncount = 2 ; lncount < 20 ; lncount ++ ) {
if ( process . env [ "NOTIFY_INCLUDE_TEXT" + lncount ] ) {
Notify _IncludeText = process . env [ "NOTIFY_INCLUDE_TEXT" + lncount ] . split ( '&' ) ;
if ( Notify _IncludeText . length > 0 ) {
for ( var Templ in Notify _IncludeText ) {
if ( desp . indexOf ( Notify _IncludeText [ Templ ] ) != - 1 ) {
console . log ( "检测内容到内容存在组别推送的关键字(" + Notify _IncludeText [ Templ ] + "),将推送到组" + lncount + "..." ) ;
UseGroupNotify = lncount ;
break ;
}
}
}
}
}
}
if ( UseGroupNotify == 1 )
UseGroupNotify = "" ;
if ( process . env [ "GOBOT_URL" + UseGroupNotify ] && Use _gobotNotify ) {
GOBOT _URL = process . env [ "GOBOT_URL" + UseGroupNotify ] ;
}
if ( process . env [ "GOBOT_TOKEN" + UseGroupNotify ] && Use _gobotNotify ) {
GOBOT _TOKEN = process . env [ "GOBOT_TOKEN" + UseGroupNotify ] ;
}
if ( process . env [ "GOBOT_QQ" + UseGroupNotify ] && Use _gobotNotify ) {
GOBOT _QQ = process . env [ "GOBOT_QQ" + UseGroupNotify ] ;
}
if ( process . env [ "PUSH_KEY" + UseGroupNotify ] && Use _serverNotify ) {
SCKEY = process . env [ "PUSH_KEY" + UseGroupNotify ] ;
}
if ( process . env [ "DEER_KEY" + UseGroupNotify ] && Use _pushdeerNotify ) {
PUSHDEER _KEY = process . env [ "DEER_KEY" + UseGroupNotify ] ;
}
if ( process . env [ "WP_APP_TOKEN" + UseGroupNotify ] && Use _WxPusher ) {
WP _APP _TOKEN = process . env [ "WP_APP_TOKEN" + UseGroupNotify ] ;
}
if ( process . env [ "WP_TOPICIDS" + UseGroupNotify ] && Use _WxPusher ) {
WP _TOPICIDS = process . env [ "WP_TOPICIDS" + UseGroupNotify ] ;
}
if ( process . env [ "WP_UIDS" + UseGroupNotify ] && Use _WxPusher ) {
WP _UIDS = process . env [ "WP_UIDS" + UseGroupNotify ] ;
}
if ( process . env [ "WP_URL" + UseGroupNotify ] && Use _WxPusher ) {
WP _URL = process . env [ "WP_URL" + UseGroupNotify ] ;
}
if ( process . env [ "BARK_PUSH" + UseGroupNotify ] && Use _BarkNotify ) {
if ( process . env [ "BARK_PUSH" + UseGroupNotify ] . indexOf ( 'https' ) > - 1 || process . env [ "BARK_PUSH" + UseGroupNotify ] . indexOf ( 'http' ) > - 1 ) {
//兼容BARK自建用户
BARK _PUSH = process . env [ "BARK_PUSH" + UseGroupNotify ] ;
} else {
//兼容BARK本地用户只填写设备码的情况
BARK _PUSH = ` https://api.day.app/ ${ process . env [ "BARK_PUSH" + UseGroupNotify ] } ` ;
}
if ( process . env [ "BARK_SOUND" + UseGroupNotify ] ) {
BARK _SOUND = process . env [ "BARK_SOUND" + UseGroupNotify ] ;
}
if ( process . env [ "BARK_GROUP" + UseGroupNotify ] ) {
BARK _GROUP = process . env ;
}
}
if ( process . env [ "TG_BOT_TOKEN" + UseGroupNotify ] && Use _tgBotNotify ) {
TG _BOT _TOKEN = process . env [ "TG_BOT_TOKEN" + UseGroupNotify ] ;
}
if ( process . env [ "TG_USER_ID" + UseGroupNotify ] && Use _tgBotNotify ) {
TG _USER _ID = process . env [ "TG_USER_ID" + UseGroupNotify ] ;
}
if ( process . env [ "TG_PROXY_AUTH" ] )
TG _PROXY _AUTH = process . env [ "TG_PROXY_AUTH" ] ;
if ( process . env [ "TG_PROXY_HOST" ] )
TG _PROXY _HOST = process . env [ "TG_PROXY_HOST" ] ;
if ( process . env [ "TG_PROXY_PORT" ] )
TG _PROXY _PORT = process . env [ "TG_PROXY_PORT" ] ;
if ( process . env [ "TG_API_HOST" ] )
TG _API _HOST = process . env [ "TG_API_HOST" ] ;
if ( process . env [ "DD_BOT_TOKEN" + UseGroupNotify ] && Use _ddBotNotify ) {
DD _BOT _TOKEN = process . env [ "DD_BOT_TOKEN" + UseGroupNotify ] ;
if ( process . env [ "DD_BOT_SECRET" + UseGroupNotify ] ) {
DD _BOT _SECRET = process . env [ "DD_BOT_SECRET" + UseGroupNotify ] ;
}
}
if ( process . env [ "QYWX_KEY" + UseGroupNotify ] && Use _qywxBotNotify ) {
QYWX _KEY = process . env [ "QYWX_KEY" + UseGroupNotify ] ;
}
if ( process . env [ "QYWX_AM" + UseGroupNotify ] && Use _qywxamNotify ) {
QYWX _AM = process . env [ "QYWX_AM" + UseGroupNotify ] ;
}
if ( process . env [ "FS_KEY" + UseGroupNotify ] && Use _fsBotNotify ) {
FS _KEY = process . env [ "FS_KEY" + UseGroupNotify ] ;
}
if ( process . env [ "IGOT_PUSH_KEY" + UseGroupNotify ] && Use _iGotNotify ) {
IGOT _PUSH _KEY = process . env [ "IGOT_PUSH_KEY" + UseGroupNotify ] ;
}
if ( process . env [ "PUSH_PLUS_TOKEN" + UseGroupNotify ] && Use _pushPlusNotify ) {
PUSH _PLUS _TOKEN = process . env [ "PUSH_PLUS_TOKEN" + UseGroupNotify ] ;
}
if ( process . env [ "PUSH_PLUS_USER" + UseGroupNotify ] && Use _pushPlusNotify ) {
PUSH _PLUS _USER = process . env [ "PUSH_PLUS_USER" + UseGroupNotify ] ;
}
if ( process . env [ "GOTIFY_URL" + UseGroupNotify ] ) {
GOTIFY _URL = process . env [ "GOTIFY_URL" + UseGroupNotify ] ;
}
if ( process . env [ "GOTIFY_TOKEN" + UseGroupNotify ] ) {
GOTIFY _TOKEN = process . env [ "GOTIFY_TOKEN" + UseGroupNotify ] ;
}
if ( process . env [ "GOTIFY_PRIORITY" + UseGroupNotify ] ) {
GOTIFY _PRIORITY = process . env [ "GOTIFY_PRIORITY" + UseGroupNotify ] ;
}
if ( process . env [ "BncrHost" + UseGroupNotify ] ) {
BncrHost = process . env [ "BncrHost" + UseGroupNotify ] ;
}
if ( process . env [ "BncrToken" + UseGroupNotify ] ) {
BncrToken = process . env [ "BncrToken" + UseGroupNotify ] ;
}
//检查是否在不使用Remark进行名称替换的名单
const notifySkipRemarkList = process . env . NOTIFY _SKIP _NAMETYPELIST ? process . env . NOTIFY _SKIP _NAMETYPELIST . split ( '&' ) : [ ] ;
const titleIndex3 = notifySkipRemarkList . findIndex ( ( item ) => item === strTitle ) ;
if ( ShowRemarkType != "1" && titleIndex3 == - 1 ) {
console . log ( "sendNotify正在处理账号Remark....." ) ;
//开始读取青龙变量列表
const envs = await getEnvs ( ) ;
if ( envs [ 0 ] ) {
var strTempdesp = [ ] ;
var strAllNotify = "" ;
if ( text == "京东资产统计" || text == "京东资产统计#2" || text == "京东资产统计#3" || text == "京东资产统计#4" ) {
strTempdesp = desp . split ( '🎏🎏🎏🎏🎏🎏🎏🎏🎏🎏🎏🎏🎏' ) ;
if ( strTempdesp . length == 2 ) {
strAllNotify = strTempdesp [ 0 ] ;
desp = strTempdesp [ 1 ] ;
}
}
for ( let i = 0 ; i < envs . length ; i ++ ) {
cookie = envs [ i ] . value ;
$ . UserName = decodeURIComponent ( cookie . match ( /pt_pin=([^; ]+)(?=;?)/ ) && cookie . match ( /pt_pin=([^; ]+)(?=;?)/ ) [ 1 ] ) ;
$ . Remark = getRemark ( envs [ i ] . remarks ) ;
$ . nickName = "" ;
$ . FoundnickName = "" ;
$ . FoundPin = "" ;
//判断有没有Remark, 没有搞个屁, 有的继续
if ( $ . Remark ) {
//先查找缓存文件中有没有这个账号,有的话直接读取别名
if ( envs [ i ] . status == 0 ) {
if ( TempCK ) {
for ( let j = 0 ; j < TempCK . length ; j ++ ) {
if ( TempCK [ j ] . pt _pin == $ . UserName ) {
$ . FoundPin = TempCK [ j ] . pt _pin ;
$ . nickName = TempCK [ j ] . nickName ;
}
}
}
if ( ! $ . FoundPin ) {
//缓存文件中有没有这个账号,调用京东接口获取别名,并更新缓存文件
console . log ( $ . UserName + "好像是新账号,尝试获取别名....." ) ;
await GetnickName ( ) ;
if ( ! $ . nickName ) {
console . log ( "别名获取失败,尝试调用另一个接口获取别名....." ) ;
await GetnickName2 ( ) ;
}
if ( $ . nickName ) {
console . log ( "好像是新账号,从接口获取别名" + $ . nickName ) ;
} else {
console . log ( $ . UserName + "该账号没有别名....." ) ;
}
tempAddCK = {
"pt_pin" : $ . UserName ,
"nickName" : $ . nickName
} ;
TempCK . push ( tempAddCK ) ;
//标识,需要更新缓存文件
boolneedUpdate = true ;
}
}
$ . nickName = $ . nickName || $ . UserName ;
//开始替换内容中的名字
if ( ShowRemarkType == "2" ) {
$ . Remark = $ . nickName + "(" + $ . Remark + ")" ;
}
if ( ShowRemarkType == "3" ) {
$ . Remark = $ . UserName + "(" + $ . Remark + ")" ;
}
try {
//额外处理1, nickName包含星号
$ . nickName = $ . nickName . replace ( new RegExp ( ` [*] ` , 'gm' ) , "[*]" ) ;
text = text . replace ( new RegExp ( ` ${ $ . UserName } | ${ $ . nickName } ` , 'gm' ) , $ . Remark ) ;
if ( text == "京东资产统计" || text == "京东资产统计#2" || text == "京东资产统计#3" || text == "京东资产统计#4" ) {
var Tempinfo = "" ;
if ( envs [ i ] . created )
Tempinfo = getQLinfo ( cookie , envs [ i ] . created , envs [ i ] . timestamp , envs [ i ] . remarks ) ;
else
if ( envs [ i ] . updatedAt )
Tempinfo = getQLinfo ( cookie , envs [ i ] . createdAt , envs [ i ] . updatedAt , envs [ i ] . remarks ) ;
else
Tempinfo = getQLinfo ( cookie , envs [ i ] . createdAt , envs [ i ] . timestamp , envs [ i ] . remarks ) ;
if ( Tempinfo ) {
$ . Remark += Tempinfo ;
}
}
desp = desp . replace ( new RegExp ( ` ${ $ . UserName } | ${ $ . nickName } ` , 'gm' ) , $ . Remark ) ;
strsummary = strsummary . replace ( new RegExp ( ` ${ $ . UserName } | ${ $ . nickName } ` , 'gm' ) , $ . Remark ) ;
//额外处理2, nickName不包含星号, 但是确实是手机号
var tempname = $ . UserName ;
if ( tempname . length == 13 && tempname . substring ( 8 ) ) {
tempname = tempname . substring ( 0 , 3 ) + "[*][*][*][*][*]" + tempname . substring ( 8 ) ;
//console.log("额外处理2:"+tempname);
text = text . replace ( new RegExp ( tempname , 'gm' ) , $ . Remark ) ;
desp = desp . replace ( new RegExp ( tempname , 'gm' ) , $ . Remark ) ;
strsummary = strsummary . replace ( new RegExp ( tempname , 'gm' ) , $ . Remark ) ;
}
} catch ( err ) {
console . log ( "替换出错了" ) ;
console . log ( "Debug Name1 :" + $ . UserName ) ;
console . log ( "Debug Name2 :" + $ . nickName ) ;
console . log ( "Debug Remark :" + $ . Remark ) ;
}
//console.log($.nickName+$.Remark);
}
}
}
console . log ( "处理完成,开始发送通知..." ) ;
if ( strAllNotify ) {
desp = strAllNotify + "\n" + desp ;
}
}
} catch ( error ) {
console . error ( error ) ;
}
if ( boolneedUpdate ) {
var str = JSON . stringify ( TempCK , null , 2 ) ;
fs . writeFile ( strCKFile , str , function ( err ) {
if ( err ) {
console . log ( err ) ;
console . log ( "更新CKName_cache.json失败!" ) ;
} else {
console . log ( "缓存文件CKName_cache.json更新成功!" ) ;
}
} )
}
//提供6种通知
desp = buildLastDesp ( desp , author ) ;
await serverNotify ( text , desp ) ; //微信server酱
if ( PUSH _PLUS _TOKEN ) {
console . log ( "PUSH_PLUS TOKEN :" + PUSH _PLUS _TOKEN ) ;
}
if ( PUSH _PLUS _USER ) {
console . log ( "PUSH_PLUS USER :" + PUSH _PLUS _USER ) ;
}
PushErrorTime = 0 ;
await pushPlusNotify ( text , desp ) ; //pushplus(推送加)
if ( PushErrorTime > 0 ) {
console . log ( "等待1分钟后重试....." ) ;
await $ . wait ( 60000 ) ;
await pushPlusNotify ( text , desp ) ; //pushplus(推送加)
}
if ( PushErrorTime > 0 ) {
console . log ( "等待1分钟后重试....." ) ;
await $ . wait ( 60000 ) ;
await pushPlusNotify ( text , desp ) ; //pushplus(推送加)
}
//由于上述两种微信通知需点击进去才能查看到详情, 故text(标题内容)携带了账号序号以及昵称信息,方便不点击也可知道是哪个京东哪个活动
text = text . match ( /.*?(?=\s?-)/g ) ? text . match ( /.*?(?=\s?-)/g ) [ 0 ] : text ;
await Promise . all ( [
BarkNotify ( text , desp , params ) , //iOS Bark APP
tgBotNotify ( text , desp ) , //telegram 机器人
ddBotNotify ( text , desp ) , //钉钉机器人
qywxBotNotify ( text , desp ) , //企业微信机器人
qywxamNotify ( text , desp , strsummary ) , //企业微信应用消息推送
fsBotNotify ( text , desp ) , //飞书机器人
iGotNotify ( text , desp , params ) , //iGot
gobotNotify ( text , desp ) , //go-cqhttp
gotifyNotify ( text , desp ) , //gotify
bncrNotify ( text , desp ) , //bncr
wxpusherNotify ( text , desp ) , // wxpusher
PushDeerNotify ( text , desp ) //pushdeer推送
] ) ;
}
function getuuid ( strRemark , PtPin ) {
var strTempuuid = "" ;
if ( strRemark ) {
var Tempindex = strRemark . indexOf ( "@@" ) ;
if ( Tempindex != - 1 ) {
console . log ( PtPin + ": 检测到NVJDC的一对一格式,瑞思拜~!" ) ;
var TempRemarkList = strRemark . split ( "@@" ) ;
for ( let j = 0 ; j < TempRemarkList . length ; j ++ ) {
if ( TempRemarkList [ j ] ) {
if ( TempRemarkList [ j ] . length > 4 ) {
if ( TempRemarkList [ j ] . substring ( 0 , 4 ) == "UID_" ) {
strTempuuid = TempRemarkList [ j ] ;
break ;
}
}
}
}
if ( ! strTempuuid ) {
console . log ( "检索资料失败..." ) ;
}
}
}
if ( ! strTempuuid && TempCKUid ) {
console . log ( "正在从CK_WxPusherUid文件中检索资料..." ) ;
for ( let j = 0 ; j < TempCKUid . length ; j ++ ) {
if ( PtPin == decodeURIComponent ( TempCKUid [ j ] . pt _pin ) ) {
strTempuuid = TempCKUid [ j ] . Uid ;
break ;
}
}
}
return strTempuuid ;
}
function getQLinfo ( strCK , intcreated , strTimestamp , strRemark ) {
var strCheckCK = strCK . match ( /pt_key=([^; ]+)(?=;?)/ ) && strCK . match ( /pt_key=([^; ]+)(?=;?)/ ) [ 1 ] ;
var strPtPin = decodeURIComponent ( strCK . match ( /pt_pin=([^; ]+)(?=;?)/ ) && strCK . match ( /pt_pin=([^; ]+)(?=;?)/ ) [ 1 ] ) ;
var strReturn = "" ;
if ( strCheckCK . substring ( 0 , 3 ) == "AAJ" ) {
var DateCreated = new Date ( intcreated ) ;
var DateTimestamp = new Date ( strTimestamp ) ;
var DateToday = new Date ( ) ;
if ( strRemark ) {
var Tempindex = strRemark . indexOf ( "@@" ) ;
if ( Tempindex != - 1 ) {
//console.log(strPtPin + ": 检测到NVJDC的备注格式,尝试获取登录时间,瑞思拜~!");
var TempRemarkList = strRemark . split ( "@@" ) ;
for ( let j = 1 ; j < TempRemarkList . length ; j ++ ) {
if ( TempRemarkList [ j ] ) {
if ( TempRemarkList [ j ] . length == 13 ) {
DateTimestamp = new Date ( parseInt ( TempRemarkList [ j ] ) ) ;
//console.log(strPtPin + ": 获取登录时间成功:" + GetDateTime(DateTimestamp));
break ;
}
}
}
}
}
//过期时间
var UseDay = Math . ceil ( ( DateToday . getTime ( ) - DateCreated . getTime ( ) ) / 86400000 ) ;
var LogoutDay = 30 - Math . ceil ( ( DateToday . getTime ( ) - DateTimestamp . getTime ( ) ) / 86400000 ) ;
let Loginday = Math . ceil ( ( DateToday . getTime ( ) - DateTimestamp . getTime ( ) ) / 86400000 )
//if (LogoutDay < 1) {
strReturn = "\n【登录信息】已服务" + UseDay + "天(已登录" + Loginday + "天)"
//} else {
// strReturn = "\n【登录信息】已服务" + UseDay + "天(有效期约剩" + LogoutDay + "天)"
//}
}
return strReturn
}
function getRemark ( strRemark ) {
if ( strRemark ) {
var Tempindex = strRemark . indexOf ( "@@" ) ;
if ( Tempindex != - 1 ) {
var TempRemarkList = strRemark . split ( "@@" ) ;
return TempRemarkList [ 0 ] . trim ( ) ;
} else {
//这是为了处理ninjia的remark格式
strRemark = strRemark . replace ( "remark=" , "" ) ;
strRemark = strRemark . replace ( ";" , "" ) ;
return strRemark . trim ( ) ;
}
} else {
return "" ;
}
}
async function sendNotifybyWxPucher ( text , desp , PtPin , author = '\n================================\n好物推荐: <a href="https://u.jd.com/WLEVYTM">https://u.jd.com/WLEVYTM</a>' , strsummary = "" ) {
try {
var Uid = "" ;
var UserRemark = "" ;
var strTempdesp = [ ] ;
var strAllNotify = "" ;
if ( text == "京东资产统计" ) {
strTempdesp = desp . split ( '🎏🎏🎏🎏🎏🎏🎏🎏🎏🎏🎏🎏🎏' ) ;
if ( strTempdesp . length == 2 ) {
strAllNotify = strTempdesp [ 0 ] ;
desp = strTempdesp [ 1 ] ;
}
}
if ( WP _APP _TOKEN _ONE ) {
var tempEnv = await getEnvByPtPin ( PtPin ) ;
if ( tempEnv ) {
cookie = tempEnv . value ;
Uid = getuuid ( tempEnv . remarks , PtPin ) ;
UserRemark = getRemark ( tempEnv . remarks ) ;
if ( Uid ) {
console . log ( "查询到Uid : " + Uid ) ;
WP _UIDS _ONE = Uid ;
console . log ( "正在发送一对一通知,请稍后..." ) ;
if ( text == "京东资产统计" ) {
try {
$ . nickName = "" ;
$ . FoundPin = "" ;
$ . UserName = PtPin ;
if ( tempEnv . status == 0 ) {
if ( TempCK ) {
for ( let j = 0 ; j < TempCK . length ; j ++ ) {
if ( TempCK [ j ] . pt _pin == $ . UserName ) {
$ . FoundPin = TempCK [ j ] . pt _pin ;
$ . nickName = TempCK [ j ] . nickName ;
}
}
}
if ( ! $ . FoundPin ) {
//缓存文件中有没有这个账号,调用京东接口获取别名,并更新缓存文件
console . log ( $ . UserName + "好像是新账号,尝试获取别名....." ) ;
await GetnickName ( ) ;
if ( ! $ . nickName ) {
console . log ( "别名获取失败,尝试调用另一个接口获取别名....." ) ;
await GetnickName2 ( ) ;
}
}
}
$ . nickName = $ . nickName || $ . UserName ;
//额外处理1, nickName包含星号
$ . nickName = $ . nickName . replace ( new RegExp ( ` [*] ` , 'gm' ) , "[*]" ) ;
var Tempinfo = "" ;
if ( tempEnv . created )
Tempinfo = getQLinfo ( cookie , tempEnv . created , tempEnv . timestamp , tempEnv . remarks ) ;
else
if ( tempEnv . updatedAt )
Tempinfo = getQLinfo ( cookie , tempEnv . createdAt , tempEnv . updatedAt , tempEnv . remarks ) ;
else
Tempinfo = getQLinfo ( cookie , tempEnv . createdAt , tempEnv . timestamp , tempEnv . remarks ) ;
if ( Tempinfo ) {
Tempinfo = $ . nickName + Tempinfo ;
desp = desp . replace ( new RegExp ( ` ${ $ . UserName } | ${ $ . nickName } ` , 'gm' ) , Tempinfo ) ;
}
//额外处理2, nickName不包含星号, 但是确实是手机号
var tempname = $ . UserName ;
if ( tempname . length == 13 && tempname . substring ( 8 ) ) {
tempname = tempname . substring ( 0 , 3 ) + "[*][*][*][*][*]" + tempname . substring ( 8 ) ;
desp = desp . replace ( new RegExp ( tempname , 'gm' ) , $ . Remark ) ;
}
} catch ( err ) {
console . log ( "替换出错了" ) ;
console . log ( "Debug Name1 :" + $ . UserName ) ;
console . log ( "Debug Name2 :" + $ . nickName ) ;
console . log ( "Debug Remark :" + $ . Remark ) ;
}
}
if ( UserRemark ) {
text = text + " (" + UserRemark + ")" ;
}
console . log ( "处理完成,开始发送通知..." ) ;
desp = buildLastDesp ( desp , author ) ;
if ( strAllNotify ) {
desp = strAllNotify + "\n" + desp ;
}
await wxpusherNotifyByOne ( text , desp , strsummary ) ;
} else {
console . log ( "未查询到用户的Uid,取消一对一通知发送..." ) ;
}
}
} else {
console . log ( "变量WP_APP_TOKEN_ONE未配置WxPusher的appToken, 取消发送..." ) ;
}
} catch ( error ) {
console . error ( error ) ;
}
}
async function GetPtPin ( text ) {
try {
const TempList = text . split ( '- ' ) ;
if ( TempList . length > 1 ) {
var strNickName = TempList [ TempList . length - 1 ] ;
var strPtPin = "" ;
console . log ( ` 捕获别名: ` + strNickName ) ;
if ( TempCK ) {
for ( let j = 0 ; j < TempCK . length ; j ++ ) {
if ( TempCK [ j ] . nickName == strNickName ) {
strPtPin = TempCK [ j ] . pt _pin ;
break ;
}
if ( TempCK [ j ] . pt _pin == strNickName ) {
strPtPin = TempCK [ j ] . pt _pin ;
break ;
}
}
if ( strPtPin ) {
console . log ( ` 反查PtPin成功: ` + strPtPin ) ;
return strPtPin ;
} else {
console . log ( ` 别名反查PtPin失败: 1.用户更改了别名 2.可能是新用户,别名缓存还没有。 ` ) ;
return strNickName ;
}
}
} else {
console . log ( ` 标题格式无法捕获别名... ` ) ;
return "" ;
}
} catch ( error ) {
console . error ( error ) ;
return "" ;
}
}
async function isLoginByX1a0He ( cookie ) {
return new Promise ( ( resolve ) => {
const options = {
url : 'https://plogin.m.jd.com/cgi-bin/ml/islogin' ,
headers : {
"Cookie" : cookie ,
"referer" : "https://h5.m.jd.com/" ,
"User-Agent" : "jdapp;iPhone;10.1.2;15.0;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1" ,
} ,
}
$ . get ( options , ( err , resp , data ) => {
try {
if ( data ) {
data = JSON . parse ( data ) ;
if ( data . islogin === "1" ) {
console . log ( ` 使用X1a0He写的接口加强检测: Cookie有效 \n ` )
} else if ( data . islogin === "0" ) {
isLogin = false ;
console . log ( ` 使用X1a0He写的接口加强检测: Cookie无效 \n ` )
} else {
console . log ( ` 使用X1a0He写的接口加强检测: 未知返回,不作变更... \n ` )
}
}
} catch ( e ) {
console . log ( e ) ;
}
finally {
resolve ( ) ;
}
} ) ;
} ) ;
}
function bncrNotify ( text , desp ) {
return new Promise ( resolve => {
try {
if ( BncrHost && BncrToken ) {
const options = {
url : ` ${ BncrHost } /api/qinglongMessage ` ,
body : ` title= ${ encodeURIComponent ( text ) } &message= ${ encodeURIComponent (
desp
) } & token = $ { BncrToken } ` ,
headers : {
'Content-Type' : 'application/x-www-form-urlencoded' ,
} ,
} ;
$ . post ( options , ( err , resp , data ) => {
if ( err ) {
console . log ( '\nBncr发送通知调用API失败! ! \n' ) ;
console . log ( err ) ;
} else {
data = JSON . parse ( data ) ;
if ( data . code === 200 ) {
console . log ( '\nBncr发送通知消息成功🎉\n' ) ;
} else {
console . log ( ` \n Bncr发送通知调用API失败: ${ data . msg } \n ` ) ;
}
}
} ) ;
} else {
resolve ( ) ;
}
} catch ( e ) {
$ . logErr ( ` \n Bncr发送通知调用API失败: ` , e ) ;
} finally {
resolve ( ) ;
}
} ) ;
}
function gotifyNotify ( text , desp ) {
return new Promise ( ( resolve ) => {
if ( GOTIFY _URL && GOTIFY _TOKEN ) {
const options = {
url : ` ${ GOTIFY _URL } /message?token= ${ GOTIFY _TOKEN } ` ,
body : ` title= ${ encodeURIComponent ( text ) } &message= ${ encodeURIComponent ( desp ) } &priority= ${ GOTIFY _PRIORITY } ` ,
headers : {
'Content-Type' : 'application/x-www-form-urlencoded' ,
}
} ;
$ . post ( options , ( err , resp , data ) => {
try {
if ( err ) {
console . log ( 'gotify发送通知调用API失败! ! \n' ) ;
console . log ( err ) ;
} else {
data = JSON . parse ( data ) ;
if ( data . id ) {
console . log ( 'gotify发送通知消息成功🎉\n' ) ;
} else {
console . log ( ` ${ data . message } \n ` ) ;
}
}
} catch ( e ) {
$ . logErr ( e , resp ) ;
}
finally {
resolve ( ) ;
}
} ) ;
} else {
resolve ( ) ;
}
} ) ;
}
function gobotNotify ( text , desp , time = 2100 ) {
return new Promise ( ( resolve ) => {
if ( GOBOT _URL ) {
const options = {
url : ` ${ GOBOT _URL } ?access_token= ${ GOBOT _TOKEN } & ${ GOBOT _QQ } ` ,
json : {
message : ` ${ text } \n ${ desp } `
} ,
headers : {
'Content-Type' : 'application/json' ,
} ,
timeout ,
} ;
setTimeout ( ( ) => {
$ . post ( options , ( err , resp , data ) => {
try {
if ( err ) {
console . log ( '发送go-cqhttp通知调用API失败! ! \n' ) ;
console . log ( err ) ;
} else {
data = JSON . parse ( data ) ;
if ( data . retcode === 0 ) {
console . log ( 'go-cqhttp发送通知消息成功🎉\n' ) ;
} else if ( data . retcode === 100 ) {
console . log ( ` go-cqhttp发送通知消息异常: ${ data . errmsg } \n ` ) ;
} else {
console . log ( ` go-cqhttp发送通知消息异常 \n ${ JSON . stringify ( data ) } ` ) ;
}
}
} catch ( e ) {
$ . logErr ( e , resp ) ;
}
finally {
resolve ( data ) ;
}
} ) ;
} , time ) ;
} else {
resolve ( ) ;
}
} ) ;
}
function serverNotify ( text , desp , time = 2100 ) {
return new Promise ( ( resolve ) => {
if ( SCKEY ) {
//微信server酱推送通知一个\n不会换行, 需要两个\n才能换行, 故做此替换
desp = desp . replace ( /[\n\r]/g , '\n\n' ) ;
const options = {
url : SCKEY . includes ( 'SCT' ) ? ` https://sctapi.ftqq.com/ ${ SCKEY } .send ` : ` https://sc.ftqq.com/ ${ SCKEY } .send ` ,
body : ` text= ${ text } &desp= ${ desp } ` ,
headers : {
'Content-Type' : 'application/x-www-form-urlencoded' ,
} ,
timeout ,
} ;
setTimeout ( ( ) => {
$ . post ( options , ( err , resp , data ) => {
try {
if ( err ) {
console . log ( '发送通知调用API失败! ! \n' ) ;
console . log ( err ) ;
} else {
data = JSON . parse ( data ) ;
//server酱和Server酱·Turbo版的返回json格式不太一样
if ( data . errno === 0 || data . data . errno === 0 ) {
console . log ( 'server酱发送通知消息成功🎉\n' ) ;
} else if ( data . errno === 1024 ) {
// 一分钟内发送相同的内容会触发
console . log ( ` server酱发送通知消息异常: ${ data . errmsg } \n ` ) ;
} else {
console . log ( ` server酱发送通知消息异常 \n ${ JSON . stringify ( data ) } ` ) ;
}
}
} catch ( e ) {
$ . logErr ( e , resp ) ;
}
finally {
resolve ( data ) ;
}
} ) ;
} , time ) ;
} else {
resolve ( ) ;
}
} ) ;
}
function BarkNotify ( text , desp , params = { } ) {
return new Promise ( ( resolve ) => {
if ( BARK _PUSH ) {
const options = {
url : ` ${ BARK _PUSH } ` ,
json : {
title : text ,
body : desp ,
group : ` ${ BARK _GROUP } ` ,
//icon: `${BARK_ICON}`,
sound : ` ${ BARK _SOUND } ` ,
} ,
headers : {
'Content-Type' : 'application/json; charset=utf-8' ,
} ,
timeout ,
} ;
$ . post ( options , ( err , resp , data ) => {
try {
if ( err ) {
console . log ( 'Bark APP发送通知调用API失败! ! \n' ) ;
console . log ( err ) ;
} else {
data = JSON . parse ( data ) ;
if ( data . code === 200 ) {
console . log ( 'Bark APP发送通知消息成功🎉\n' ) ;
} else {
console . log ( ` ${ data . message } \n ` ) ;
}
}
} catch ( e ) {
$ . logErr ( e , resp ) ;
} finally {
resolve ( ) ;
}
} ) ;
} else {
resolve ( ) ;
}
} ) ;
}
function tgBotNotify ( text , desp ) {
return new Promise ( resolve => {
if ( TG _BOT _TOKEN && TG _USER _ID ) {
const options = {
url : ` https:// ${ TG _API _HOST } /bot ${ TG _BOT _TOKEN } /sendMessage ` ,
json : {
chat _id : ` ${ TG _USER _ID } ` ,
text : ` ${ text } \n \n ${ desp } ` ,
disable _web _page _preview : true
} ,
headers : {
'Content-Type' : 'application/json' ,
} ,
timeout
}
if ( TG _PROXY _HOST && TG _PROXY _PORT ) {
const tunnel = require ( "tunnel" ) ;
const agent = {
https : tunnel . httpsOverHttp ( {
proxy : {
host : TG _PROXY _HOST ,
port : TG _PROXY _PORT * 1 ,
proxyAuth : TG _PROXY _AUTH
}
} )
}
Object . assign ( options , { agent } )
}
$ . post ( options , ( err , resp , data ) => {
try {
if ( err ) {
console . log ( 'telegram发送通知消息失败! ! \n' )
console . log ( err ) ;
} else {
data = JSON . parse ( data ) ;
if ( data . ok ) {
console . log ( 'Telegram发送通知消息成功🎉\n' )
} else if ( data . error _code === 400 ) {
console . log ( '请主动给bot发送一条消息并检查接收用户ID是否正确。\n' )
} else if ( data . error _code === 401 ) {
console . log ( 'Telegram bot token 填写错误。\n' )
}
}
} catch ( e ) {
$ . logErr ( e , resp ) ;
} finally {
resolve ( data ) ;
}
} )
} else {
resolve ( )
}
} )
}
function ddBotNotify ( text , desp ) {
return new Promise ( ( resolve ) => {
const options = {
url : ` https://oapi.dingtalk.com/robot/send?access_token= ${ DD _BOT _TOKEN } ` ,
json : {
msgtype : 'text' ,
text : {
content : ` ${ text } \n \n ${ desp } ` ,
} ,
} ,
headers : {
'Content-Type' : 'application/json' ,
} ,
timeout ,
} ;
if ( DD _BOT _TOKEN && DD _BOT _SECRET ) {
const crypto = require ( 'crypto' ) ;
const dateNow = Date . now ( ) ;
const hmac = crypto . createHmac ( 'sha256' , DD _BOT _SECRET ) ;
hmac . update ( ` ${ dateNow } \n ${ DD _BOT _SECRET } ` ) ;
const result = encodeURIComponent ( hmac . digest ( 'base64' ) ) ;
options . url = ` ${ options . url } ×tamp= ${ dateNow } &sign= ${ result } ` ;
$ . post ( options , ( err , resp , data ) => {
try {
if ( err ) {
console . log ( '钉钉发送通知消息失败!!\n' ) ;
console . log ( err ) ;
} else {
data = JSON . parse ( data ) ;
if ( data . errcode === 0 ) {
console . log ( '钉钉发送通知消息成功🎉。\n' ) ;
} else {
console . log ( ` ${ data . errmsg } \n ` ) ;
}
}
} catch ( e ) {
$ . logErr ( e , resp ) ;
}
finally {
resolve ( data ) ;
}
} ) ;
} else if ( DD _BOT _TOKEN ) {
$ . post ( options , ( err , resp , data ) => {
try {
if ( err ) {
console . log ( '钉钉发送通知消息失败!!\n' ) ;
console . log ( err ) ;
} else {
data = JSON . parse ( data ) ;
if ( data . errcode === 0 ) {
console . log ( '钉钉发送通知消息完成。\n' ) ;
} else {
console . log ( ` ${ data . errmsg } \n ` ) ;
}
}
} catch ( e ) {
$ . logErr ( e , resp ) ;
}
finally {
resolve ( data ) ;
}
} ) ;
} else {
resolve ( ) ;
}
} ) ;
}
function qywxBotNotify ( text , desp ) {
return new Promise ( ( resolve ) => {
const options = {
url : ` https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key= ${ QYWX _KEY } ` ,
json : {
msgtype : 'text' ,
text : {
content : ` ${ text } \n \n ${ desp } ` ,
} ,
} ,
headers : {
'Content-Type' : 'application/json' ,
} ,
timeout ,
} ;
if ( QYWX _KEY ) {
$ . post ( options , ( err , resp , data ) => {
try {
if ( err ) {
console . log ( '企业微信发送通知消息失败!!\n' ) ;
console . log ( err ) ;
} else {
data = JSON . parse ( data ) ;
if ( data . errcode === 0 ) {
console . log ( '企业微信发送通知消息成功🎉。\n' ) ;
} else {
console . log ( ` ${ data . errmsg } \n ` ) ;
}
}
} catch ( e ) {
$ . logErr ( e , resp ) ;
}
finally {
resolve ( data ) ;
}
} ) ;
} else {
resolve ( ) ;
}
} ) ;
}
function fsBotNotify ( text , desp ) {
return new Promise ( ( resolve ) => {
const options = {
url : ` https://open.feishu.cn/open-apis/bot/v2/hook/ ${ FS _KEY } ` ,
json : {
msg _type : 'text' ,
content : {
text : ` ${ text } \n \n ${ desp } ` ,
} ,
} ,
headers : {
'Content-Type' : 'application/json' ,
} ,
timeout ,
} ;
if ( FS _KEY ) {
$ . post ( options , ( err , resp , data ) => {
try {
if ( err ) {
console . log ( '飞书发送通知消息失败!!\n' ) ;
console . log ( err ) ;
} else {
data = JSON . parse ( data ) ;
if ( data . errcode === 0 ) {
console . log ( '飞书发送通知消息成功🎉。\n' ) ;
} else {
console . log ( ` ${ data . errmsg } \n ` ) ;
}
}
} catch ( e ) {
$ . logErr ( e , resp ) ;
}
finally {
resolve ( data ) ;
}
} ) ;
} else {
resolve ( ) ;
}
} ) ;
}
function buildLastDesp ( desp , author = '' ) {
author = process . env . NOTIFY _AUTHOR || author ;
if ( process . env . NOTIFY _AUTHOR _BLANK || ! author ) {
return desp . trim ( ) ;
} else {
if ( ! author . match ( /本通知 By/ ) ) {
author = ` \n \n ${ author } `
}
return desp . trim ( ) + author + "\n现在时刻: " + GetDateTime ( new Date ( ) ) ;
}
}
function ChangeUserId ( desp ) {
const QYWX _AM _AY = QYWX _AM . split ( ',' ) ;
if ( QYWX _AM _AY [ 2 ] ) {
const userIdTmp = QYWX _AM _AY [ 2 ] . split ( '|' ) ;
let userId = '' ;
for ( let i = 0 ; i < userIdTmp . length ; i ++ ) {
const count = '账号' + ( i + 1 ) ;
const count2 = '签到号 ' + ( i + 1 ) ;
if ( desp . match ( count2 ) ) {
userId = userIdTmp [ i ] ;
}
}
if ( ! userId )
userId = QYWX _AM _AY [ 2 ] ;
return userId ;
} else {
return '@all' ;
}
}
function qywxamNotify ( text , desp , strsummary = "" ) {
return new Promise ( ( resolve ) => {
if ( QYWX _AM ) {
const QYWX _AM _AY = QYWX _AM . split ( ',' ) ;
const options _accesstoken = {
url : ` https://qyapi.weixin.qq.com/cgi-bin/gettoken ` ,
json : {
corpid : ` ${ QYWX _AM _AY [ 0 ] } ` ,
corpsecret : ` ${ QYWX _AM _AY [ 1 ] } ` ,
} ,
headers : {
'Content-Type' : 'application/json' ,
} ,
timeout ,
} ;
$ . post ( options _accesstoken , ( err , resp , data ) => {
html = desp . replace ( /\n/g , '<br/>' ) ;
html = ` <font size="3"> ${ html } </font> ` ;
if ( strsummary == "" ) {
strsummary = desp ;
}
var json = JSON . parse ( data ) ;
accesstoken = json . access _token ;
let options ;
switch ( QYWX _AM _AY [ 4 ] ) {
case '0' :
options = {
msgtype : 'textcard' ,
textcard : {
title : ` ${ text } ` ,
description : ` ${ strsummary } ` ,
url : 'https://github.com/whyour/qinglong' ,
btntxt : '更多' ,
} ,
} ;
break ;
case '1' :
options = {
msgtype : 'text' ,
text : {
content : ` ${ text } \n \n ${ desp } ` ,
} ,
} ;
break ;
default :
options = {
msgtype : 'mpnews' ,
mpnews : {
articles : [ {
title : ` ${ text } ` ,
thumb _media _id : ` ${ QYWX _AM _AY [ 4 ] } ` ,
author : ` 智能助手 ` ,
content _source _url : ` ` ,
content : ` ${ html } ` ,
digest : ` ${ strsummary } ` ,
} , ] ,
} ,
} ;
}
if ( ! QYWX _AM _AY [ 4 ] ) {
//如不提供第四个参数,则默认进行文本消息类型推送
options = {
msgtype : 'text' ,
text : {
content : ` ${ text } \n \n ${ desp } ` ,
} ,
} ;
}
options = {
url : ` https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token= ${ accesstoken } ` ,
json : {
touser : ` ${ ChangeUserId ( desp ) } ` ,
agentid : ` ${ QYWX _AM _AY [ 3 ] } ` ,
safe : '0' ,
... options ,
} ,
headers : {
'Content-Type' : 'application/json' ,
} ,
} ;
$ . post ( options , ( err , resp , data ) => {
try {
if ( err ) {
console . log ( '成员ID:' + ChangeUserId ( desp ) + '企业微信应用消息发送通知消息失败!!\n' ) ;
console . log ( err ) ;
} else {
data = JSON . parse ( data ) ;
if ( data . errcode === 0 ) {
console . log ( '成员ID:' + ChangeUserId ( desp ) + '企业微信应用消息发送通知消息成功🎉。\n' ) ;
} else {
console . log ( ` ${ data . errmsg } \n ` ) ;
}
}
} catch ( e ) {
$ . logErr ( e , resp ) ;
}
finally {
resolve ( data ) ;
}
} ) ;
} ) ;
} else {
resolve ( ) ;
}
} ) ;
}
function iGotNotify ( text , desp , params = { } ) {
return new Promise ( ( resolve ) => {
if ( IGOT _PUSH _KEY ) {
// 校验传入的IGOT_PUSH_KEY是否有效
const IGOT _PUSH _KEY _REGX = new RegExp ( '^[a-zA-Z0-9]{24}$' ) ;
if ( ! IGOT _PUSH _KEY _REGX . test ( IGOT _PUSH _KEY ) ) {
console . log ( '您所提供的IGOT_PUSH_KEY无效\n' ) ;
resolve ( ) ;
return ;
}
const options = {
url : ` https://push.hellyw.com/ ${ IGOT _PUSH _KEY . toLowerCase ( ) } ` ,
body : ` title= ${ text } &content= ${ desp } & ${ querystring . stringify ( params ) } ` ,
headers : {
'Content-Type' : 'application/x-www-form-urlencoded' ,
} ,
timeout ,
} ;
$ . post ( options , ( err , resp , data ) => {
try {
if ( err ) {
console . log ( '发送通知调用API失败! ! \n' ) ;
console . log ( err ) ;
} else {
if ( typeof data === 'string' )
data = JSON . parse ( data ) ;
if ( data . ret === 0 ) {
console . log ( 'iGot发送通知消息成功🎉\n' ) ;
} else {
console . log ( ` iGot发送通知消息失败: ${ data . errMsg } \n ` ) ;
}
}
} catch ( e ) {
$ . logErr ( e , resp ) ;
}
finally {
resolve ( data ) ;
}
} ) ;
} else {
resolve ( ) ;
}
} ) ;
}
function pushPlusNotify ( text , desp ) {
return new Promise ( ( resolve ) => {
if ( PUSH _PLUS _TOKEN ) {
//desp = `<font size="3">${desp}</font>`;
desp = desp . replace ( /[\n\r]/g , '<br>' ) ; // 默认为html, 不支持plaintext
const body = {
token : ` ${ PUSH _PLUS _TOKEN } ` ,
title : ` ${ text } ` ,
content : ` ${ desp } ` ,
topic : ` ${ PUSH _PLUS _USER } ` ,
} ;
const options = {
url : ` https://www.pushplus.plus/send ` ,
body : JSON . stringify ( body ) ,
headers : {
'Content-Type' : ' application/json' ,
} ,
timeout ,
} ;
$ . post ( options , ( err , resp , data ) => {
try {
if ( err ) {
console . log ( ` push+发送 ${ PUSH _PLUS _USER ? '一对多' : '一对一' } 通知消息失败!! \n ` ) ;
PushErrorTime += 1 ;
console . log ( err ) ;
} else {
data = JSON . parse ( data ) ;
if ( data . code === 200 ) {
console . log ( ` push+发送 ${ PUSH _PLUS _USER ? '一对多' : '一对一' } 通知消息完成。 \n ` ) ;
PushErrorTime = 0 ;
} else {
console . log ( ` push+发送 ${ PUSH _PLUS _USER ? '一对多' : '一对一' } 通知消息失败: ${ data . msg } \n ` ) ;
PushErrorTime += 1 ;
}
}
} catch ( e ) {
$ . logErr ( e , resp ) ;
}
finally {
resolve ( data ) ;
}
} ) ;
} else {
resolve ( ) ;
}
} ) ;
}
function wxpusherNotifyByOne ( text , desp , strsummary = "" ) {
return new Promise ( ( resolve ) => {
if ( WP _APP _TOKEN _ONE ) {
var WPURL = "" ;
if ( strsummary ) {
strsummary = text + "\n" + strsummary ;
} else {
strsummary = text + "\n" + desp ;
}
if ( strsummary . length > 96 ) {
strsummary = strsummary . substring ( 0 , 95 ) + "..." ;
}
let uids = [ ] ;
for ( let i of WP _UIDS _ONE . split ( ";" ) ) {
if ( i . length != 0 )
uids . push ( i ) ;
} ;
let topicIds = [ ] ;
//desp = `<font size="3">${desp}</font>`;
desp = desp . replace ( /[\n\r]/g , '<br>' ) ; // 默认为html, 不支持plaintext
desp = ` <section style="width: 24rem; max-width: 100%;border:none;border-style:none;margin:2.5rem auto;" id="shifu_imi_57"
donone = "shifuMouseDownPayStyle('shifu_imi_57')" >
< section
style = "margin: 0px auto;text-align: left;border: 2px solid #212122;padding: 10px 0px;box-sizing:border-box; width: 100%; display:inline-block;"
class = "ipaiban-bc" >
< section style = "margin-top: 1rem; float: left; margin-left: 1rem; margin-left: 1rem; font-size: 1.3rem; font-weight: bold;" >
< p style = "margin: 0; color: black" >
$ { text }
< / p >
< / s e c t i o n >
< section style = "display: block;width: 0;height: 0;clear: both;" > < / s e c t i o n >
< section
style = "margin-top:20px; display: inline-block; border-bottom: 1px solid #212122; padding: 4px 20px; box-sizing:border-box;"
class = "ipaiban-bbc" >
< section
style = "width:25px; height:25px; border-radius:50%; background-color:#212122;display:inline-block;line-height: 25px"
class = "ipaiban-bg" >
< p style = "text-align:center;font-weight:1000;margin:0" >
< span style = "color: #ffffff;font-size:20px;" > 📢 < / s p a n >
< / p >
< / s e c t i o n >
< section style = "display:inline-block;padding-left:10px;vertical-align: top;box-sizing:border-box;" >
< / s e c t i o n >
< / s e c t i o n >
< section style = "margin-top:0rem;padding: 0.8rem;box-sizing:border-box;" >
< p style = " line-height: 1.6rem; font-size: 1.1rem; " >
$ { desp }
< / p >
< / s e c t i o n >
< / s e c t i o n >
< / s e c t i o n > ` ;
const body = {
appToken : ` ${ WP _APP _TOKEN _ONE } ` ,
content : ` ${ desp } ` ,
summary : ` ${ strsummary } ` ,
contentType : 2 ,
topicIds : topicIds ,
uids : uids ,
url : ` ${ WPURL } ` ,
} ;
const options = {
url : ` http://wxpusher.zjiecode.com/api/send/message ` ,
body : JSON . stringify ( body ) ,
headers : {
"Content-Type" : "application/json" ,
} ,
timeout ,
} ;
$ . post ( options , ( err , resp , data ) => {
try {
if ( err ) {
console . log ( "WxPusher 发送通知调用 API 失败!!\n" ) ;
console . log ( err ) ;
} else {
data = JSON . parse ( data ) ;
if ( data . code === 1000 ) {
console . log ( "WxPusher 发送通知消息成功!\n" ) ;
}
}
} catch ( e ) {
$ . logErr ( e , resp ) ;
}
finally {
resolve ( data ) ;
}
} ) ;
} else {
resolve ( ) ;
}
} ) ;
}
function wxpusherNotify ( text , desp ) {
return new Promise ( ( resolve ) => {
if ( WP _APP _TOKEN ) {
let uids = [ ] ;
for ( let i of WP _UIDS . split ( ";" ) ) {
if ( i . length != 0 )
uids . push ( i ) ;
} ;
let topicIds = [ ] ;
for ( let i of WP _TOPICIDS . split ( ";" ) ) {
if ( i . length != 0 )
topicIds . push ( i ) ;
} ;
desp = ` <font size="4"><b> ${ text } </b></font> \n \n <font size="3"> ${ desp } </font> ` ;
desp = desp . replace ( /[\n\r]/g , '<br>' ) ; // 默认为html, 不支持plaintext
const body = {
appToken : ` ${ WP _APP _TOKEN } ` ,
content : ` ${ text } \n \n ${ desp } ` ,
summary : ` ${ text } ` ,
contentType : 2 ,
topicIds : topicIds ,
uids : uids ,
url : ` ${ WP _URL } ` ,
} ;
const options = {
url : ` http://wxpusher.zjiecode.com/api/send/message ` ,
body : JSON . stringify ( body ) ,
headers : {
"Content-Type" : "application/json" ,
} ,
timeout ,
} ;
$ . post ( options , ( err , resp , data ) => {
try {
if ( err ) {
console . log ( "WxPusher 发送通知调用 API 失败!!\n" ) ;
console . log ( err ) ;
} else {
data = JSON . parse ( data ) ;
if ( data . code === 1000 ) {
console . log ( "WxPusher 发送通知消息成功!\n" ) ;
}
}
} catch ( e ) {
$ . logErr ( e , resp ) ;
}
finally {
resolve ( data ) ;
}
} ) ;
} else {
resolve ( ) ;
}
} ) ;
}
function PushDeerNotify ( text , desp ) {
return new Promise ( ( resolve ) => {
if ( PUSHDEER _KEY ) {
desp = encodeURI ( desp ) ;
desp = desp . replace ( /%0A/g , '%0A%0A' ) ;
const options = {
url : ` https://api2.pushdeer.com/message/push ` ,
body : ` pushkey= ${ PUSHDEER _KEY } &text= ${ text } &desp= ${ desp } &type="markdown" ` ,
headers : {
'Content-Type' : 'application/x-www-form-urlencoded' ,
} ,
timeout : 5000 ,
} ;
$ . post ( options , ( err , resp , data ) => {
try {
if ( err ) {
console . log ( '发送通知调用API失败! ! \n' ) ;
console . log ( err ) ;
} else {
data = JSON . parse ( data ) ;
// 通过返回的result的长度来判断是否成功
if (
data . content . result . length !== undefined &&
data . content . result . length > 0
) {
console . log ( 'PushDeer发送通知消息成功🎉\n' ) ;
} else {
console . log (
` PushDeer发送通知消息异常 \n ${ JSON . stringify ( data ) } ` ,
) ;
}
}
} catch ( e ) {
$ . logErr ( e , resp ) ;
} finally {
resolve ( data ) ;
}
} ) ;
} else {
resolve ( ) ;
}
} ) ;
}
function GetDateTime ( date ) {
var timeString = "" ;
var timeString = date . getFullYear ( ) + "-" ;
if ( ( date . getMonth ( ) + 1 ) < 10 )
timeString += "0" + ( date . getMonth ( ) + 1 ) + "-" ;
else
timeString += ( date . getMonth ( ) + 1 ) + "-" ;
if ( ( date . getDate ( ) ) < 10 )
timeString += "0" + date . getDate ( ) + " " ;
else
timeString += date . getDate ( ) + " " ;
if ( ( date . getHours ( ) ) < 10 )
timeString += "0" + date . getHours ( ) + ":" ;
else
timeString += date . getHours ( ) + ":" ;
if ( ( date . getMinutes ( ) ) < 10 )
timeString += "0" + date . getMinutes ( ) + ":" ;
else
timeString += date . getMinutes ( ) + ":" ;
if ( ( date . getSeconds ( ) ) < 10 )
timeString += "0" + date . getSeconds ( ) ;
else
timeString += date . getSeconds ( ) ;
return timeString ;
}
function GetnickName ( ) {
return new Promise ( async resolve => {
const options = {
url : "https://me-api.jd.com/user_new/info/GetJDUserInfoUnion" ,
headers : {
Host : "me-api.jd.com" ,
Accept : "*/*" ,
Connection : "keep-alive" ,
Cookie : cookie ,
"User-Agent" : "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36 Edg/106.0.1370.42" ,
"Accept-Language" : "zh-cn" ,
"Referer" : "https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&" ,
"Accept-Encoding" : "gzip, deflate, br"
}
}
$ . get ( options , ( err , resp , data ) => {
try {
if ( err ) {
$ . logErr ( err )
} else {
if ( data ) {
data = JSON . parse ( data ) ;
if ( data [ 'retcode' ] === "1001" ) {
return ;
}
if ( data [ 'retcode' ] === "0" && data . data && data . data . hasOwnProperty ( "userInfo" ) ) {
$ . nickName = data . data . userInfo . baseInfo . nickname ;
}
} else {
$ . log ( '京东服务器返回空数据' ) ;
}
}
} catch ( e ) {
$ . logErr ( e )
}
finally {
resolve ( ) ;
}
} )
} )
}
function GetnickName2 ( ) {
return new Promise ( async ( resolve ) => {
const options = {
"url" : ` https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2 ` ,
"headers" : {
"Accept" : "application/json,text/plain, */*" ,
"Content-Type" : "application/x-www-form-urlencoded" ,
"Accept-Encoding" : "gzip, deflate, br" ,
"Accept-Language" : "zh-cn" ,
"Connection" : "keep-alive" ,
"Cookie" : cookie ,
"Referer" : "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2" ,
"User-Agent" : $ . isNode ( ) ? ( process . env . JD _USER _AGENT ? process . env . JD _USER _AGENT : ( require ( './USER_AGENTS' ) . USER _AGENT ) ) : ( $ . getdata ( 'JDUA' ) ? $ . getdata ( 'JDUA' ) : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1" )
}
} ;
$ . post ( options , ( err , resp , data ) => {
try {
if ( err ) {
$ . logErr ( err ) ;
} else {
if ( data ) {
data = JSON . parse ( data ) ;
if ( data [ 'retcode' ] === 13 ) {
$ . isLogin = false ; //cookie过期
return
}
if ( data [ 'retcode' ] === 0 ) {
$ . nickName = ( data [ 'base' ] && data [ 'base' ] . nickname ) || "" ;
}
} else {
$ . log ( '京东服务器返回空数据' ) ;
}
}
} catch ( e ) {
$ . logErr ( e ) ;
}
finally {
resolve ( ) ;
}
} ) ;
} ) ;
}
const got = require ( 'got' ) ;
require ( 'dotenv' ) . config ( ) ;
let exists = fs . existsSync ( '/ql/data/config/auth.json' ) ;
let authFile = "" ;
if ( exists )
authFile = "/ql/data/config/auth.json"
else
authFile = "/ql/config/auth.json"
const api = got . extend ( {
prefixUrl : 'http://127.0.0.1:5600' ,
retry : { limit : 0 } ,
} ) ;
async function getToken ( ) {
const authConfig = JSON . parse ( fs . readFileSync ( authFile ) ) ;
return authConfig . token ;
}
async function getEnvs ( ) {
const token = await getToken ( ) ;
const body = await api ( {
url : 'api/envs' ,
searchParams : {
searchValue : 'JD_COOKIE' ,
t : Date . now ( ) ,
} ,
headers : {
Accept : 'application/json' ,
authorization : ` Bearer ${ token } ` ,
} ,
} ) . json ( ) ;
return body . data ;
} ;
async function getEnvsCount ( ) {
const data = await getEnvs ( ) ;
return data . length ;
} ;
async function addEnv ( cookie , remarks ) {
const token = await getToken ( ) ;
const body = await api ( {
method : 'post' ,
url : 'api/envs' ,
params : { t : Date . now ( ) } ,
json : [ {
name : 'JD_COOKIE' ,
value : cookie ,
remarks ,
} ] ,
headers : {
Accept : 'application/json' ,
authorization : ` Bearer ${ token } ` ,
'Content-Type' : 'application/json;charset=UTF-8' ,
} ,
} ) . json ( ) ;
return body ;
}
async function updateEnv ( cookie , eid , remarks ) {
const token = await getToken ( ) ;
const body = await api ( {
method : 'put' ,
url : 'api/envs' ,
params : { t : Date . now ( ) } ,
json : {
name : 'JD_COOKIE' ,
value : cookie ,
_id : eid ,
remarks ,
} ,
headers : {
Accept : 'application/json' ,
authorization : ` Bearer ${ token } ` ,
'Content-Type' : 'application/json;charset=UTF-8' ,
} ,
} ) . json ( ) ;
return body ;
} ;
async function updateEnv11 ( cookie , eid , remarks ) {
const token = await getToken ( ) ;
const body = await api ( {
method : 'put' ,
url : 'api/envs' ,
params : { t : Date . now ( ) } ,
json : {
name : 'JD_COOKIE' ,
value : cookie ,
id : eid ,
remarks ,
} ,
headers : {
Accept : 'application/json' ,
authorization : ` Bearer ${ token } ` ,
'Content-Type' : 'application/json;charset=UTF-8' ,
} ,
} ) . json ( ) ;
return body ;
} ;
async function DisableCk ( eid ) {
const token = await getToken ( ) ;
const body = await api ( {
method : 'put' ,
url : 'api/envs/disable' ,
params : { t : Date . now ( ) } ,
body : JSON . stringify ( [ eid ] ) ,
headers : {
Accept : 'application/json' ,
authorization : ` Bearer ${ token } ` ,
'Content-Type' : 'application/json;charset=UTF-8' ,
} ,
} ) . json ( ) ;
return body ;
} ;
async function EnableCk ( eid ) {
const token = await getToken ( ) ;
const body = await api ( {
method : 'put' ,
url : 'api/envs/enable' ,
params : { t : Date . now ( ) } ,
body : JSON . stringify ( [ eid ] ) ,
headers : {
Accept : 'application/json' ,
authorization : ` Bearer ${ token } ` ,
'Content-Type' : 'application/json;charset=UTF-8' ,
} ,
} ) . json ( ) ;
return body ;
} ;
async function getstatus ( eid ) {
const envs = await getEnvs ( ) ;
var tempid = 0 ;
for ( let i = 0 ; i < envs . length ; i ++ ) {
tempid = 0 ;
if ( envs [ i ] . _id ) {
tempid = envs [ i ] . _id ;
}
if ( envs [ i ] . id ) {
tempid = envs [ i ] . id ;
}
if ( tempid == eid ) {
return envs [ i ] . status ;
}
}
return 99 ;
} ;
async function getEnvById ( eid ) {
const envs = await getEnvs ( ) ;
var tempid = 0 ;
for ( let i = 0 ; i < envs . length ; i ++ ) {
tempid = 0 ;
if ( envs [ i ] . _id ) {
tempid = envs [ i ] . _id ;
}
if ( envs [ i ] . id ) {
tempid = envs [ i ] . id ;
}
if ( tempid == eid ) {
return envs [ i ] . value ;
}
}
return "" ;
} ;
async function getEnvByPtPin ( Ptpin ) {
const envs = await getEnvs ( ) ;
for ( let i = 0 ; i < envs . length ; i ++ ) {
var tempptpin = decodeURIComponent ( envs [ i ] . value . match ( /pt_pin=([^; ]+)(?=;?)/ ) && envs [ i ] . value . match ( /pt_pin=([^; ]+)(?=;?)/ ) [ 1 ] ) ;
if ( tempptpin == Ptpin ) {
return envs [ i ] ;
}
}
return "" ;
} ;
async function delEnv ( eid ) {
const token = await getToken ( ) ;
const body = await api ( {
method : 'delete' ,
url : 'api/envs' ,
params : { t : Date . now ( ) } ,
body : JSON . stringify ( [ eid ] ) ,
headers : {
Accept : 'application/json' ,
authorization : ` Bearer ${ token } ` ,
'Content-Type' : 'application/json;charset=UTF-8' ,
} ,
} ) . json ( ) ;
return body ;
} ;
module . exports = {
sendNotify ,
sendNotifybyWxPucher ,
BARK _PUSH ,
} ;
// prettier-ignore
function Env ( t , s ) {
return new ( class {
constructor ( t , s ) {
( this . name = t ) ,
( this . data = null ) ,
( this . dataFile = 'box.dat' ) ,
( this . logs = [ ] ) ,
( this . logSeparator = '\n' ) ,
( this . startTime = new Date ( ) . getTime ( ) ) ,
Object . assign ( this , s ) ,
this . log ( '' , ` \u d83d \u dd14 ${ this . name } , \u 5f00 \u 59cb! ` ) ;
}
isNode ( ) {
return 'undefined' != typeof module && ! ! module . exports ;
}
isQuanX ( ) {
return 'undefined' != typeof $task ;
}
isSurge ( ) {
return 'undefined' != typeof $httpClient && 'undefined' == typeof $loon ;
}
isLoon ( ) {
return 'undefined' != typeof $loon ;
}
getScript ( t ) {
return new Promise ( ( s ) => {
$ . get ( {
url : t
} , ( t , e , i ) => s ( i ) ) ;
} ) ;
}
runScript ( t , s ) {
return new Promise ( ( e ) => {
let i = this . getdata ( '@chavy_boxjs_userCfgs.httpapi' ) ;
i = i ? i . replace ( /\n/g , '' ) . trim ( ) : i ;
let o = this . getdata ( '@chavy_boxjs_userCfgs.httpapi_timeout' ) ;
( o = o ? 1 * o : 20 ) ,
( o = s && s . timeout ? s . timeout : o ) ;
const [ h , a ] = i . split ( '@' ) ,
r = {
url : ` http:// ${ a } /v1/scripting/evaluate ` ,
body : {
script _text : t ,
mock _type : 'cron' ,
timeout : o
} ,
headers : {
'X-Key' : h ,
Accept : '*/*'
} ,
} ;
$ . post ( r , ( t , s , i ) => e ( i ) ) ;
} ) . catch ( ( t ) => this . logErr ( t ) ) ;
}
loaddata ( ) {
if ( ! this . isNode ( ) )
return { } ; {
( this . fs = this . fs ? this . fs : require ( 'fs' ) ) ,
( this . path = this . path ? this . path : require ( 'path' ) ) ;
const t = this . path . resolve ( this . dataFile ) ,
s = this . path . resolve ( process . cwd ( ) , this . dataFile ) ,
e = this . fs . existsSync ( t ) ,
i = ! e && this . fs . existsSync ( s ) ;
if ( ! e && ! i )
return { } ; {
const i = e ? t : s ;
try {
return JSON . parse ( this . fs . readFileSync ( i ) ) ;
} catch ( t ) {
return { } ;
}
}
}
}
writedata ( ) {
if ( this . isNode ( ) ) {
( this . fs = this . fs ? this . fs : require ( 'fs' ) ) ,
( this . path = this . path ? this . path : require ( 'path' ) ) ;
const t = this . path . resolve ( this . dataFile ) ,
s = this . path . resolve ( process . cwd ( ) , this . dataFile ) ,
e = this . fs . existsSync ( t ) ,
i = ! e && this . fs . existsSync ( s ) ,
o = JSON . stringify ( this . data ) ;
e ? this . fs . writeFileSync ( t , o ) : i ? this . fs . writeFileSync ( s , o ) : this . fs . writeFileSync ( t , o ) ;
}
}
lodash _get ( t , s , e ) {
const i = s . replace ( /\[(\d+)\]/g , '.$1' ) . split ( '.' ) ;
let o = t ;
for ( const t of i )
if ( ( ( o = Object ( o ) [ t ] ) , void 0 === o ) )
return e ;
return o ;
}
lodash _set ( t , s , e ) {
return Object ( t ) !== t ? t : ( Array . isArray ( s ) || ( s = s . toString ( ) . match ( /[^.[\]]+/g ) || [ ] ) , ( s . slice ( 0 , - 1 ) . reduce ( ( t , e , i ) => ( Object ( t [ e ] ) === t [ e ] ? t [ e ] : ( t [ e ] = Math . abs ( s [ i + 1 ] ) >> 0 == + s [ i + 1 ] ? [ ] : { } ) ) , t ) [ s [ s . length - 1 ] ] = e ) , t ) ;
}
getdata ( t ) {
let s = this . getval ( t ) ;
if ( /^@/ . test ( t ) ) {
const [ , e , i ] = /^@(.*?)\.(.*?)$/ . exec ( t ) ,
o = e ? this . getval ( e ) : '' ;
if ( o )
try {
const t = JSON . parse ( o ) ;
s = t ? this . lodash _get ( t , i , '' ) : s ;
} catch ( t ) {
s = '' ;
}
}
return s ;
}
setdata ( t , s ) {
let e = ! 1 ;
if ( /^@/ . test ( s ) ) {
const [ , i , o ] = /^@(.*?)\.(.*?)$/ . exec ( s ) ,
h = this . getval ( i ) ,
a = i ? ( 'null' === h ? null : h || '{}' ) : '{}' ;
try {
const s = JSON . parse ( a ) ;
this . lodash _set ( s , o , t ) ,
( e = this . setval ( JSON . stringify ( s ) , i ) ) ;
} catch ( s ) {
const h = { } ;
this . lodash _set ( h , o , t ) ,
( e = this . setval ( JSON . stringify ( h ) , i ) ) ;
}
} else
e = $ . setval ( t , s ) ;
return e ;
}
getval ( t ) {
return this . isSurge ( ) || this . isLoon ( ) ? $persistentStore . read ( t ) : this . isQuanX ( ) ? $prefs . valueForKey ( t ) : this . isNode ( ) ? ( ( this . data = this . loaddata ( ) ) , this . data [ t ] ) : ( this . data && this . data [ t ] ) || null ;
}
setval ( t , s ) {
return this . isSurge ( ) || this . isLoon ( ) ? $persistentStore . write ( t , s ) : this . isQuanX ( ) ? $prefs . setValueForKey ( t , s ) : this . isNode ( ) ? ( ( this . data = this . loaddata ( ) ) , ( this . data [ s ] = t ) , this . writedata ( ) , ! 0 ) : ( this . data && this . data [ s ] ) || null ;
}
initGotEnv ( t ) {
( this . got = this . got ? this . got : require ( 'got' ) ) ,
( this . cktough = this . cktough ? this . cktough : require ( 'tough-cookie' ) ) ,
( this . ckjar = this . ckjar ? this . ckjar : new this . cktough . CookieJar ( ) ) ,
t && ( ( t . headers = t . headers ? t . headers : { } ) , void 0 === t . headers . Cookie && void 0 === t . cookieJar && ( t . cookieJar = this . ckjar ) ) ;
}
get ( t , s = ( ) => { } ) {
t . headers && ( delete t . headers [ 'Content-Type' ] , delete t . headers [ 'Content-Length' ] ) ,
this . isSurge ( ) || this . isLoon ( ) ? $httpClient . get ( t , ( t , e , i ) => {
! t && e && ( ( e . body = i ) , ( e . statusCode = e . status ) ) ,
s ( t , e , i ) ;
} ) : this . isQuanX ( ) ? $task . fetch ( t ) . then ( ( t ) => {
const {
statusCode : e ,
statusCode : i ,
headers : o ,
body : h
} = t ;
s ( null , {
status : e ,
statusCode : i ,
headers : o ,
body : h
} , h ) ;
} , ( t ) => s ( t ) ) : this . isNode ( ) && ( this . initGotEnv ( t ) , this . got ( t ) . on ( 'redirect' , ( t , s ) => {
try {
const e = t . headers [ 'set-cookie' ] . map ( this . cktough . Cookie . parse ) . toString ( ) ;
this . ckjar . setCookieSync ( e , null ) ,
( s . cookieJar = this . ckjar ) ;
} catch ( t ) {
this . logErr ( t ) ;
}
} ) . then ( ( t ) => {
const {
statusCode : e ,
statusCode : i ,
headers : o ,
body : h
} = t ;
s ( null , {
status : e ,
statusCode : i ,
headers : o ,
body : h
} , h ) ;
} , ( t ) => s ( t ) ) ) ;
}
post ( t , s = ( ) => { } ) {
if ( ( t . body && t . headers && ! t . headers [ 'Content-Type' ] && ( t . headers [ 'Content-Type' ] = 'application/x-www-form-urlencoded' ) , delete t . headers [ 'Content-Length' ] , this . isSurge ( ) || this . isLoon ( ) ) )
$httpClient . post ( t , ( t , e , i ) => {
! t && e && ( ( e . body = i ) , ( e . statusCode = e . status ) ) ,
s ( t , e , i ) ;
} ) ;
else if ( this . isQuanX ( ) )
( t . method = 'POST' ) , $task . fetch ( t ) . then ( ( t ) => {
const {
statusCode : e ,
statusCode : i ,
headers : o ,
body : h
} = t ;
s ( null , {
status : e ,
statusCode : i ,
headers : o ,
body : h
} , h ) ;
} , ( t ) => s ( t ) ) ;
else if ( this . isNode ( ) ) {
this . initGotEnv ( t ) ;
const {
url : e ,
... i
} = t ;
this . got . post ( e , i ) . then ( ( t ) => {
const {
statusCode : e ,
statusCode : i ,
headers : o ,
body : h
} = t ;
s ( null , {
status : e ,
statusCode : i ,
headers : o ,
body : h
} , h ) ;
} , ( t ) => s ( t ) ) ;
}
}
time ( t ) {
let s = {
'M+' : new Date ( ) . getMonth ( ) + 1 ,
'd+' : new Date ( ) . getDate ( ) ,
'H+' : new Date ( ) . getHours ( ) ,
'm+' : new Date ( ) . getMinutes ( ) ,
's+' : new Date ( ) . getSeconds ( ) ,
'q+' : Math . floor ( ( new Date ( ) . getMonth ( ) + 3 ) / 3 ) ,
S : new Date ( ) . getMilliseconds ( ) ,
} ;
/(y+)/ . test ( t ) && ( t = t . replace ( RegExp . $1 , ( new Date ( ) . getFullYear ( ) + '' ) . substr ( 4 - RegExp . $1 . length ) ) ) ;
for ( let e in s )
new RegExp ( '(' + e + ')' ) . test ( t ) && ( t = t . replace ( RegExp . $1 , 1 == RegExp . $1 . length ? s [ e ] : ( '00' + s [ e ] ) . substr ( ( '' + s [ e ] ) . length ) ) ) ;
return t ;
}
msg ( s = t , e = '' , i = '' , o ) {
const h = ( t ) => ! t || ( ! this . isLoon ( ) && this . isSurge ( ) ) ? t : 'string' == typeof t ? this . isLoon ( ) ? t : this . isQuanX ( ) ? {
'open-url' : t
}
: void 0 : 'object' == typeof t && ( t [ 'open-url' ] || t [ 'media-url' ] ) ? this . isLoon ( ) ? t [ 'open-url' ] : this . isQuanX ( ) ? t : void 0 : void 0 ;
$ . isMute || ( this . isSurge ( ) || this . isLoon ( ) ? $notification . post ( s , e , i , h ( o ) ) : this . isQuanX ( ) && $notify ( s , e , i , h ( o ) ) ) ,
this . logs . push ( '' , '==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3==============' ) ,
this . logs . push ( s ) ,
e && this . logs . push ( e ) ,
i && this . logs . push ( i ) ;
}
log ( ... t ) {
t . length > 0 ? ( this . logs = [ ... this . logs , ... t ] ) : console . log ( this . logs . join ( this . logSeparator ) ) ;
}
logErr ( t , s ) {
const e = ! this . isSurge ( ) && ! this . isQuanX ( ) && ! this . isLoon ( ) ;
e ? $ . log ( '' , ` \u 2757 \u fe0f ${ this . name } , \u 9519 \u 8bef! ` , t . stack ) : $ . log ( '' , ` \u 2757 \u fe0f ${ this . name } , \u 9519 \u 8bef! ` , t ) ;
}
wait ( t ) {
return new Promise ( ( s ) => setTimeout ( s , t ) ) ;
}
done ( t = { } ) {
const s = new Date ( ) . getTime ( ) ,
e = ( s - this . startTime ) / 1e3 ;
this . log ( '' , ` \u d83d \u dd14 ${ this . name } , \u 7ed3 \u 675f! \u d83d \u dd5b ${ e } \u 79d2 ` ) ,
this . log ( ) ,
( this . isSurge ( ) || this . isQuanX ( ) || this . isLoon ( ) ) && $done ( t ) ;
}
} ) ( t , s ) ;
}