diff --git a/.eslintrc.json b/.eslintrc.json index dfd27d8..5513ad5 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -5,11 +5,18 @@ "node": true }, "extends": "eslint:recommended", - "overrides": [ - ], "parserOptions": { "ecmaVersion": "latest" }, + "globals": { + "$persistentStore": true, + "$prefs": true, + "$httpClient": true, + "$task": true, + "$notification": true, + "$done": true, + "$notify": true + }, "rules": { "indent": ["warn", 2, {"SwitchCase": 1}], "brace-style": [1, "stroustrup", {"allowSingleLine": true}], diff --git a/bot.js b/bot.js index aa17301..9d58c6f 100644 --- a/bot.js +++ b/bot.js @@ -76,7 +76,7 @@ const requestApi = async (url, inputOptions = {}) => { const gotOptions = { method: options.method.toUpperCase(), - headers: options.headers, + headers: options.headers }; if (options.method === 'get') { diff --git a/env.js b/env.js index 43d7576..1e0e898 100644 --- a/env.js +++ b/env.js @@ -7,16 +7,16 @@ function Env(t, e) { } send(t, e = "GET") { t = "string" == typeof t ? { - url: t - } : + url: t + } : t; let s = this.get; return "POST" === e && (s = this.post), - new Promise((e, i) => { - s.call(this, t, (t, s, r) => { - t ? i(t) : e(s) - }) + new Promise((e, i) => { + s.call(this, t, (t, s) => { + t ? i(t) : e(s) }) + }) } get(t) { return this.send.call(this.env, t) @@ -29,16 +29,16 @@ function Env(t, e) { return new class { constructor(t, e) { this.name = t, - this.http = new s(this), - this.data = null, - this.dataFile = "box.dat", - this.logs = [], - this.isMute = !1, - this.isNeedRewrite = !1, - this.logSeparator = "\n", - this.startTime = (new Date).getTime(), - Object.assign(this, e), - this.log("", `🔔${this.name}, 开始!`) + this.http = new s(this), + this.data = null, + this.dataFile = "box.dat", + this.logs = [], + this.isMute = !1, + this.isNeedRewrite = !1, + this.logSeparator = "\n", + this.startTime = (new Date).getTime(), + Object.assign(this, e), + this.log("", `🔔${this.name}, 开始!`) } isNode() { return "undefined" != typeof module && !!module.exports @@ -55,30 +55,35 @@ function Env(t, e) { toObj(t, e = null) { try { return JSON.parse(t) - } catch { + } + catch { return e } } toStr(t, e = null) { try { return JSON.stringify(t) - } catch { + } + catch { return e } } getjson(t, e) { let s = e; const i = this.getdata(t); - if (i) + if (i) { try { s = JSON.parse(this.getdata(t)) - } catch {} + } + catch {} + } return s } setjson(t, e) { try { return this.setdata(JSON.stringify(t), e) - } catch { + } + catch { return !1 } } @@ -95,7 +100,7 @@ function Env(t, e) { i = i ? i.replace(/\n/g, "").trim() : i; let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); r = r ? 1 * r : 20, - r = e && e.timeout ? e.timeout : r; + r = e && e.timeout ? e.timeout : r; const [o, h] = i.split("@"), n = { url: `http://${h}/v1/scripting/evaluate`, @@ -113,20 +118,19 @@ function Env(t, e) { }).catch(t => this.logErr(t)) } loaddata() { - if (!this.isNode()) - return {}; { + if (!this.isNode()) {return {};} { this.fs = this.fs ? this.fs : require("fs"), - this.path = this.path ? this.path : require("path"); + this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e); - if (!s && !i) - return {}; { + if (!s && !i) {return {};} { const i = s ? t : e; try { return JSON.parse(this.fs.readFileSync(i)) - } catch (t) { + } + catch (t) { return {} } } @@ -135,7 +139,7 @@ function Env(t, e) { writedata() { if (this.isNode()) { this.fs = this.fs ? this.fs : require("fs"), - this.path = this.path ? this.path : require("path"); + this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), @@ -147,9 +151,9 @@ function Env(t, e) { lodash_get(t, e, s) { const i = e.replace(/\[(\d+)\]/g, ".$1").split("."); let r = t; - for (const t of i) - if (r = Object(r)[t], void 0 === r) - return s; + for (const t of i) { + if (r = Object(r)[t], void 0 === r) {return s;} + } return r } lodash_set(t, e, s) { @@ -160,13 +164,15 @@ function Env(t, e) { if (/^@/.test(t)) { const [, s, i] = /^@(.*?)\.(.*?)$/.exec(t), r = s ? this.getval(s) : ""; - if (r) + if (r) { try { const t = JSON.parse(r); e = t ? this.lodash_get(t, i, "") : e - } catch (t) { + } + catch (t) { e = "" } + } } return e } @@ -179,14 +185,15 @@ function Env(t, e) { try { const e = JSON.parse(h); this.lodash_set(e, r, t), - s = this.setval(JSON.stringify(e), i) - } catch (e) { + s = this.setval(JSON.stringify(e), i) + } + catch (e) { const o = {}; this.lodash_set(o, r, t), - s = this.setval(JSON.stringify(o), i) + s = this.setval(JSON.stringify(o), i) } - } else - s = this.setval(t, e); + } + else {s = this.setval(t, e);} return s } getval(t) { @@ -197,72 +204,74 @@ function Env(t, e) { } 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)) + 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, e = (() => {})) { t.headers && (delete t.headers["Content-Type"], delete t.headers["Content-Length"]), - this.isSurge() || this.isLoon() ? (this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { - "X-Surge-Skip-Scripting": !1 - })), $httpClient.get(t, (t, s, i) => { - !t && s && (s.body = i, s.statusCode = s.status), - e(t, s, i) - })) : this.isQuanX() ? (this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { - hints: !1 - })), $task.fetch(t).then(t => { - const { - statusCode: s, - statusCode: i, - headers: r, - body: o - } = t; - e(null, { - status: s, - statusCode: i, - headers: r, - body: o - }, o) - }, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => { - try { - if (t.headers["set-cookie"]) { - const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString(); - s && this.ckjar.setCookieSync(s, null), - e.cookieJar = this.ckjar - } - } catch (t) { - this.logErr(t) + this.isSurge() || this.isLoon() ? (this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { + "X-Surge-Skip-Scripting": !1 + })), $httpClient.get(t, (t, s, i) => { + !t && s && (s.body = i, s.statusCode = s.status), + e(t, s, i) + })) : this.isQuanX() ? (this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { + hints: !1 + })), $task.fetch(t).then(t => { + const { + statusCode: s, + statusCode: i, + headers: r, + body: o + } = t; + e(null, { + status: s, + statusCode: i, + headers: r, + body: o + }, o) + }, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => { + try { + if (t.headers["set-cookie"]) { + const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString(); + s && this.ckjar.setCookieSync(s, null), + e.cookieJar = this.ckjar } - }).then(t => { - const { - statusCode: s, - statusCode: i, - headers: r, - body: o - } = t; - e(null, { - status: s, - statusCode: i, - headers: r, - body: o - }, o) - }, t => { - const { - message: s, - response: i - } = t; - e(s, i, i && i.body) - })) + } + catch (t) { + this.logErr(t) + } + }).then(t => { + const { + statusCode: s, + statusCode: i, + headers: r, + body: o + } = t; + e(null, { + status: s, + statusCode: i, + headers: r, + body: o + }, o) + }, t => { + const { + message: s, + response: i + } = t; + e(s, i, i && i.body) + })) } post(t, e = (() => {})) { - if (t.body && t.headers && !t.headers["Content-Type"] && (t.headers["Content-Type"] = "application/x-www-form-urlencoded"), t.headers && delete t.headers["Content-Length"], this.isSurge() || this.isLoon()) + if (t.body && t.headers && !t.headers["Content-Type"] && (t.headers["Content-Type"] = "application/x-www-form-urlencoded"), t.headers && delete t.headers["Content-Length"], this.isSurge() || this.isLoon()) { this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.post(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), - e(t, s, i) + e(t, s, i) }); - else if (this.isQuanX()) + } + else if (this.isQuanX()) { t.method = "POST", this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { @@ -279,6 +288,7 @@ function Env(t, e) { body: o }, o) }, t => e(t)); + } else if (this.isNode()) { this.initGotEnv(t); const { @@ -309,7 +319,7 @@ function Env(t, e) { } time(t, e = null) { const s = e ? new Date(e) : new Date; - let i = { + const i = { "M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(), @@ -319,25 +329,24 @@ function Env(t, e) { S: s.getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); - for (let e in i) - new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).length))); + for (const e in i) {new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).length)));} return t } msg(e = t, s = "", i = "", r) { const o = t => { - if (!t) - return t; - if ("string" == typeof t) + if (!t) {return t;} + if ("string" == typeof t) { return this.isLoon() ? t : this.isQuanX() ? { - "open-url": t - } : + "open-url": t + } : this.isSurge() ? { url: t } : - void 0; + void 0; + } if ("object" == typeof t) { if (this.isLoon()) { - let e = t.openUrl || t.url || t["open-url"], + const e = t.openUrl || t.url || t["open-url"], s = t.mediaUrl || t["media-url"]; return { openUrl: e, @@ -345,7 +354,7 @@ function Env(t, e) { } } if (this.isQuanX()) { - let e = t["open-url"] || t.url || t.openUrl, + const e = t["open-url"] || t.url || t.openUrl, s = t["media-url"] || t.mediaUrl; return { "open-url": e, @@ -353,7 +362,7 @@ function Env(t, e) { } } if (this.isSurge()) { - let e = t.url || t.openUrl || t["open-url"]; + const e = t.url || t.openUrl || t["open-url"]; return { url: e } @@ -361,19 +370,19 @@ function Env(t, e) { } }; if (this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))), !this.isMuteLog) { - let t = ["", "==============📣系统通知📣=============="]; + const t = ["", "==============📣系统通知📣=============="]; t.push(e), - s && t.push(s), - i && t.push(i), - console.log(t.join("\n")), - this.logs = this.logs.concat(t) + s && t.push(s), + i && t.push(i), + console.log(t.join("\n")), + this.logs = this.logs.concat(t) } } log(...t) { t.length > 0 && (this.logs = [...this.logs, ...t]), - console.log(t.join(this.logSeparator)) + console.log(t.join(this.logSeparator)) } - logErr(t, e) { + logErr(t) { const s = !this.isSurge() && !this.isQuanX() && !this.isLoon(); s ? this.log("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) } @@ -384,8 +393,8 @@ function Env(t, e) { const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), - this.log(), - (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) + this.log(), + (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) } }(t, e); } diff --git a/sendNotify.js b/sendNotify.js index 006a961..a4f2af4 100644 --- a/sendNotify.js +++ b/sendNotify.js @@ -34,11 +34,6 @@ let GOBOT_QQ = ''; // 如果GOBOT_URL设置 /send_private_msg 则需要填入 us //(环境变量名 PUSH_KEY) let SCKEY = ''; -// =======================================PushDeer通知设置区域=========================================== -//此处填你申请的PushDeer KEY. -//(环境变量名 DEER_KEY) -let PUSHDEER_KEY = ''; - // =======================================Bark App通知设置区域=========================================== //此处填你BarkAPP的信息(IP/设备码,例如:https://api.day.app/XXXXXXXX) let BARK_PUSH = ''; @@ -122,18 +117,6 @@ if (process.env.PUSH_KEY) { SCKEY = process.env.PUSH_KEY; } -if (process.env.DEER_KEY) { - PUSHDEER_KEY = process.env.DEER_KEY; -} - -if (process.env.QQ_SKEY) { - QQ_SKEY = process.env.QQ_SKEY; -} - -if (process.env.QQ_MODE) { - QQ_MODE = process.env.QQ_MODE; -} - if (process.env.BARK_PUSH) { if ( process.env.BARK_PUSH.indexOf('https') > -1 || @@ -141,7 +124,8 @@ if (process.env.BARK_PUSH) { ) { //兼容BARK自建用户 BARK_PUSH = process.env.BARK_PUSH; - } else { + } + else { BARK_PUSH = `https://api.day.app/${process.env.BARK_PUSH}`; } if (process.env.BARK_ICON) { @@ -153,7 +137,8 @@ if (process.env.BARK_PUSH) { if (process.env.BARK_GROUP) { BARK_GROUP = process.env.BARK_GROUP; } -} else { +} +else { if ( BARK_PUSH && BARK_PUSH.indexOf('https') === -1 && @@ -169,10 +154,10 @@ if (process.env.TG_BOT_TOKEN) { if (process.env.TG_USER_ID) { TG_USER_ID = process.env.TG_USER_ID; } -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.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) { DD_BOT_TOKEN = process.env.DD_BOT_TOKEN; @@ -213,13 +198,13 @@ async function sendNotify( text, desp, params = {}, - author = '\n\n本通知 By:https://github.com/whyour/qinglong', + author = '\n\n本通知 By:https://github.com/whyour/qinglong' ) { //提供6种通知 desp += author; //增加作者信息,防止被贩卖等 await Promise.all([ serverNotify(text, desp), //微信server酱 - pushPlusNotify(text, desp), //pushplus(推送加) + pushPlusNotify(text, desp) //pushplus(推送加) ]); //由于上述两种微信通知需点击进去才能查看到详情,故text(标题内容)携带了账号序号以及昵称信息,方便不点击也可知道是哪个京东哪个活动 text = text.match(/.*?(?=\s?-)/g) ? text.match(/.*?(?=\s?-)/g)[0] : text; @@ -231,7 +216,7 @@ async function sendNotify( qywxamNotify(text, desp), //企业微信应用消息推送 iGotNotify(text, desp, params), //iGot gobotNotify(text, desp), //go-cqhttp - gotifyNotify(text, desp), //gotify + gotifyNotify(text, desp) //gotify ]); } @@ -241,32 +226,37 @@ function gotifyNotify(text, desp) { const options = { url: `${GOTIFY_URL}/message?token=${GOTIFY_TOKEN}`, body: `title=${encodeURIComponent(text)}&message=${encodeURIComponent( - desp, + desp )}&priority=${GOTIFY_PRIORITY}`, headers: { - 'Content-Type': 'application/x-www-form-urlencoded', - }, + 'Content-Type': 'application/x-www-form-urlencoded' + } }; $.post(options, (err, resp, data) => { try { if (err) { console.log('gotify发送通知调用API失败!!\n'); console.log(err); - } else { + } + else { data = JSON.parse(data); if (data.id) { console.log('gotify发送通知消息成功🎉\n'); - } else { + } + else { console.log(`${data.message}\n`); } } - } catch (e) { + } + catch (e) { $.logErr(e, resp); - } finally { + } + finally { resolve(); } }); - } else { + } + else { resolve(); } }); @@ -279,9 +269,9 @@ function gobotNotify(text, desp, time = 2100) { url: `${GOBOT_URL}?access_token=${GOBOT_TOKEN}&${GOBOT_QQ}`, json: { message: `${text}\n${desp}` }, headers: { - 'Content-Type': 'application/json', + 'Content-Type': 'application/json' }, - timeout, + timeout }; setTimeout(() => { $.post(options, (err, resp, data) => { @@ -289,26 +279,32 @@ function gobotNotify(text, desp, time = 2100) { if (err) { console.log('发送go-cqhttp通知调用API失败!!\n'); console.log(err); - } else { + } + else { data = JSON.parse(data); if (data.retcode === 0) { console.log('go-cqhttp发送通知消息成功🎉\n'); - } else if (data.retcode === 100) { + } + else if (data.retcode === 100) { console.log(`go-cqhttp发送通知消息异常: ${data.errmsg}\n`); - } else { + } + else { console.log( - `go-cqhttp发送通知消息异常\n${JSON.stringify(data)}`, + `go-cqhttp发送通知消息异常\n${JSON.stringify(data)}` ); } } - } catch (e) { + } + catch (e) { $.logErr(e, resp); - } finally { + } + finally { resolve(data); } }); }, time); - } else { + } + else { resolve(); } }); @@ -325,9 +321,9 @@ function serverNotify(text, desp, time = 2100) { : `https://sc.ftqq.com/${SCKEY}.send`, body: `text=${text}&desp=${desp}`, headers: { - 'Content-Type': 'application/x-www-form-urlencoded', + 'Content-Type': 'application/x-www-form-urlencoded' }, - timeout, + timeout }; setTimeout(() => { $.post(options, (err, resp, data) => { @@ -335,151 +331,34 @@ function serverNotify(text, desp, time = 2100) { if (err) { console.log('发送通知调用API失败!!\n'); console.log(err); - } else { + } + 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) { + } + else if (data.errno === 1024) { // 一分钟内发送相同的内容会触发 console.log(`server酱发送通知消息异常: ${data.errmsg}\n`); - } else { + } + else { console.log( - `server酱发送通知消息异常\n${JSON.stringify(data)}`, + `server酱发送通知消息异常\n${JSON.stringify(data)}` ); } } - } catch (e) { + } + catch (e) { $.logErr(e, resp); - } finally { + } + finally { resolve(data); } }); }, time); - } else { - resolve(); } - }); -} - -function PushDeerNotify(text, desp, time = 2100) { - return new Promise((resolve) => { - if (PUSHDEER_KEY) { - // PushDeer 建议对消息内容进行 urlencode - desp = encodeURI(desp); - 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, - }; - setTimeout(() => { - $.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); - } - }); - }, time); - } else { - resolve(); - } - }); -} - -function CoolPush(text, desp) { - return new Promise((resolve) => { - if (QQ_SKEY) { - let options = { - url: `https://push.xuthus.cc/${QQ_MODE}/${QQ_SKEY}`, - headers: { - 'Content-Type': 'application/json', - }, - }; - - // 已知敏感词 - text = text.replace(/京豆/g, '豆豆'); - desp = desp.replace(/京豆/g, ''); - desp = desp.replace(/🐶/g, ''); - desp = desp.replace(/红包/g, 'H包'); - - switch (QQ_MODE) { - case 'email': - options.json = { - t: text, - c: desp, - }; - break; - default: - options.body = `${text}\n\n${desp}`; - } - - let pushMode = function (t) { - switch (t) { - case 'send': - return '个人'; - case 'group': - return 'QQ群'; - case 'wx': - return '微信'; - case 'ww': - return '企业微信'; - case 'email': - return '邮件'; - default: - return '未知方式'; - } - }; - - $.post(options, (err, resp, data) => { - try { - if (err) { - console.log(`发送${pushMode(QQ_MODE)}通知调用API失败!!\n`); - console.log(err); - } else { - data = JSON.parse(data); - if (data.code === 200) { - console.log(`酷推发送${pushMode(QQ_MODE)}通知消息成功🎉\n`); - } else if (data.code === 400) { - console.log( - `QQ酷推(Cool Push)发送${pushMode(QQ_MODE)}推送失败:${ - data.msg - }\n`, - ); - } else if (data.code === 503) { - console.log(`QQ酷推出错,${data.message}:${data.data}\n`); - } else { - console.log(`酷推推送异常: ${JSON.stringify(data)}`); - } - } - } catch (e) { - $.logErr(e, resp); - } finally { - resolve(data); - } - }); - } else { + else { resolve(); } }); @@ -490,35 +369,40 @@ function BarkNotify(text, desp, params = {}) { if (BARK_PUSH) { const options = { url: `${BARK_PUSH}/${encodeURIComponent(text)}/${encodeURIComponent( - desp, + desp )}?icon=${BARK_ICON}?sound=${BARK_SOUND}&group=${BARK_GROUP}&${querystring.stringify( - params, + params )}`, headers: { - 'Content-Type': 'application/x-www-form-urlencoded', + 'Content-Type': 'application/x-www-form-urlencoded' }, - timeout, + timeout }; $.get(options, (err, resp, data) => { try { if (err) { console.log('Bark APP发送通知调用API失败!!\n'); console.log(err); - } else { + } + else { data = JSON.parse(data); if (data.code === 200) { console.log('Bark APP发送通知消息成功🎉\n'); - } else { + } + else { console.log(`${data.message}\n`); } } - } catch (e) { + } + catch (e) { $.logErr(e, resp); - } finally { + } + finally { resolve(); } }); - } else { + } + else { resolve(); } }); @@ -531,9 +415,9 @@ function tgBotNotify(text, desp) { url: `https://${TG_API_HOST}/bot${TG_BOT_TOKEN}/sendMessage`, body: `chat_id=${TG_USER_ID}&text=${text}\n\n${desp}&disable_web_page_preview=true`, headers: { - 'Content-Type': 'application/x-www-form-urlencoded', + 'Content-Type': 'application/x-www-form-urlencoded' }, - timeout, + timeout }; if (TG_PROXY_HOST && TG_PROXY_PORT) { const tunnel = require('tunnel'); @@ -542,9 +426,9 @@ function tgBotNotify(text, desp) { proxy: { host: TG_PROXY_HOST, port: TG_PROXY_PORT * 1, - proxyAuth: TG_PROXY_AUTH, - }, - }), + proxyAuth: TG_PROXY_AUTH + } + }) }; Object.assign(options, { agent }); } @@ -553,25 +437,31 @@ function tgBotNotify(text, desp) { if (err) { console.log('telegram发送通知消息失败!!\n'); console.log(err); - } else { + } + else { data = JSON.parse(data); if (data.ok) { console.log('Telegram发送通知消息成功🎉。\n'); - } else if (data.error_code === 400) { + } + else if (data.error_code === 400) { console.log( - '请主动给bot发送一条消息并检查接收用户ID是否正确。\n', + '请主动给bot发送一条消息并检查接收用户ID是否正确。\n' ); - } else if (data.error_code === 401) { + } + else if (data.error_code === 401) { console.log('Telegram bot token 填写错误。\n'); } } - } catch (e) { + } + catch (e) { $.logErr(e, resp); - } finally { + } + finally { resolve(data); } }); - } else { + } + else { resolve(); } }); @@ -583,13 +473,13 @@ function ddBotNotify(text, desp) { json: { msgtype: 'text', text: { - content: ` ${text}\n\n${desp}`, - }, + content: ` ${text}\n\n${desp}` + } }, headers: { - 'Content-Type': 'application/json', + 'Content-Type': 'application/json' }, - timeout, + timeout }; if (DD_BOT_TOKEN && DD_BOT_SECRET) { const crypto = require('crypto'); @@ -603,41 +493,51 @@ function ddBotNotify(text, desp) { if (err) { console.log('钉钉发送通知消息失败!!\n'); console.log(err); - } else { + } + else { data = JSON.parse(data); if (data.errcode === 0) { console.log('钉钉发送通知消息成功🎉。\n'); - } else { + } + else { console.log(`${data.errmsg}\n`); } } - } catch (e) { + } + catch (e) { $.logErr(e, resp); - } finally { + } + finally { resolve(data); } }); - } else if (DD_BOT_TOKEN) { + } + else if (DD_BOT_TOKEN) { $.post(options, (err, resp, data) => { try { if (err) { console.log('钉钉发送通知消息失败!!\n'); console.log(err); - } else { + } + else { data = JSON.parse(data); if (data.errcode === 0) { console.log('钉钉发送通知消息完成。\n'); - } else { + } + else { console.log(`${data.errmsg}\n`); } } - } catch (e) { + } + catch (e) { $.logErr(e, resp); - } finally { + } + finally { resolve(data); } }); - } else { + } + else { resolve(); } }); @@ -650,13 +550,13 @@ function qywxBotNotify(text, desp) { json: { msgtype: 'text', text: { - content: ` ${text}\n\n${desp}`, - }, + content: ` ${text}\n\n${desp}` + } }, headers: { - 'Content-Type': 'application/json', + 'Content-Type': 'application/json' }, - timeout, + timeout }; if (QYWX_KEY) { $.post(options, (err, resp, data) => { @@ -664,21 +564,26 @@ function qywxBotNotify(text, desp) { if (err) { console.log('企业微信发送通知消息失败!!\n'); console.log(err); - } else { + } + else { data = JSON.parse(data); if (data.errcode === 0) { console.log('企业微信发送通知消息成功🎉。\n'); - } else { + } + else { console.log(`${data.errmsg}\n`); } } - } catch (e) { + } + catch (e) { $.logErr(e, resp); - } finally { + } + finally { resolve(data); } }); - } else { + } + else { resolve(); } }); @@ -690,15 +595,15 @@ function ChangeUserId(desp) { 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]; + if (!userId) {userId = QYWX_AM_AY[2];} return userId; - } else { + } + else { return '@all'; } } @@ -711,17 +616,17 @@ function qywxamNotify(text, desp) { url: `https://qyapi.weixin.qq.com/cgi-bin/gettoken`, json: { corpid: `${QYWX_AM_AY[0]}`, - corpsecret: `${QYWX_AM_AY[1]}`, + corpsecret: `${QYWX_AM_AY[1]}` }, headers: { - 'Content-Type': 'application/json', + 'Content-Type': 'application/json' }, - timeout, + timeout }; $.post(options_accesstoken, (err, resp, data) => { - html = desp.replace(/\n/g, '
'); - var json = JSON.parse(data); - accesstoken = json.access_token; + const html = desp.replace(/\n/g, '
'); + const json = JSON.parse(data); + const accesstoken = json.access_token; let options; switch (QYWX_AM_AY[4]) { @@ -732,8 +637,8 @@ function qywxamNotify(text, desp) { title: `${text}`, description: `${desp}`, url: 'https://github.com/whyour/qinglong', - btntxt: '更多', - }, + btntxt: '更多' + } }; break; @@ -741,8 +646,8 @@ function qywxamNotify(text, desp) { options = { msgtype: 'text', text: { - content: `${text}\n\n${desp}`, - }, + content: `${text}\n\n${desp}` + } }; break; @@ -757,10 +662,10 @@ function qywxamNotify(text, desp) { author: `智能助手`, content_source_url: ``, content: `${html}`, - digest: `${desp}`, - }, - ], - }, + digest: `${desp}` + } + ] + } }; } if (!QYWX_AM_AY[4]) { @@ -768,8 +673,8 @@ function qywxamNotify(text, desp) { options = { msgtype: 'text', text: { - content: `${text}\n\n${desp}`, - }, + content: `${text}\n\n${desp}` + } }; } options = { @@ -778,11 +683,11 @@ function qywxamNotify(text, desp) { touser: `${ChangeUserId(desp)}`, agentid: `${QYWX_AM_AY[3]}`, safe: '0', - ...options, + ...options }, headers: { - 'Content-Type': 'application/json', - }, + 'Content-Type': 'application/json' + } }; $.post(options, (err, resp, data) => { @@ -791,29 +696,34 @@ function qywxamNotify(text, desp) { console.log( '成员ID:' + ChangeUserId(desp) + - '企业微信应用消息发送通知消息失败!!\n', + '企业微信应用消息发送通知消息失败!!\n' ); console.log(err); - } else { + } + else { data = JSON.parse(data); if (data.errcode === 0) { console.log( '成员ID:' + ChangeUserId(desp) + - '企业微信应用消息发送通知消息成功🎉。\n', + '企业微信应用消息发送通知消息成功🎉。\n' ); - } else { + } + else { console.log(`${data.errmsg}\n`); } } - } catch (e) { + } + catch (e) { $.logErr(e, resp); - } finally { + } + finally { resolve(data); } }); }); - } else { + } + else { resolve(); } }); @@ -833,30 +743,35 @@ function iGotNotify(text, desp, params = {}) { 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', + 'Content-Type': 'application/x-www-form-urlencoded' }, - timeout, + 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); + } + else { + if (typeof data === 'string') {data = JSON.parse(data);} if (data.ret === 0) { console.log('iGot发送通知消息成功🎉\n'); - } else { + } + else { console.log(`iGot发送通知消息失败:${data.errMsg}\n`); } } - } catch (e) { + } + catch (e) { $.logErr(e, resp); - } finally { + } + finally { resolve(data); } }); - } else { + } + else { resolve(); } }); @@ -870,15 +785,15 @@ function pushPlusNotify(text, desp) { token: `${PUSH_PLUS_TOKEN}`, title: `${text}`, content: `${desp}`, - topic: `${PUSH_PLUS_USER}`, + topic: `${PUSH_PLUS_USER}` }; const options = { url: `https://www.pushplus.plus/send`, body: JSON.stringify(body), headers: { - 'Content-Type': ' application/json', + 'Content-Type': ' application/json' }, - timeout, + timeout }; $.post(options, (err, resp, data) => { try { @@ -886,32 +801,37 @@ function pushPlusNotify(text, desp) { console.log( `push+发送${ PUSH_PLUS_USER ? '一对多' : '一对一' - }通知消息失败!!\n`, + }通知消息失败!!\n` ); console.log(err); - } else { + } + else { data = JSON.parse(data); if (data.code === 200) { console.log( `push+发送${ PUSH_PLUS_USER ? '一对多' : '一对一' - }通知消息完成。\n`, + }通知消息完成。\n` ); - } else { + } + else { console.log( `push+发送${ PUSH_PLUS_USER ? '一对多' : '一对一' - }通知消息失败:${data.msg}\n`, + }通知消息失败:${data.msg}\n` ); } } - } catch (e) { + } + catch (e) { $.logErr(e, resp); - } finally { + } + finally { resolve(data); } }); - } else { + } + else { resolve(); } }); @@ -919,8 +839,37 @@ function pushPlusNotify(text, desp) { module.exports = { sendNotify, - BARK_PUSH, + 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("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}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("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):$.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(s=>setTimeout(s,t))}done(t={}){const s=(new Date).getTime(),e=(s-this.startTime)/1e3;this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${e} \u79d2`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,s)} +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("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}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) {const 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 (const 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) {const e = !this.isSurge() && !this.isQuanX() && !this.isLoon(); e ? $.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack) : $.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t) {return new Promise(s=>setTimeout(s,t))}done(t = {}) {const s = (new Date).getTime(),e = (s - this.startTime) / 1e3; this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${e} \u79d2`),this.log(),(this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t)} + }(t,s) +}