Add Bark APP notification API.

This commit is contained in:
NobyDa 2021-09-22 23:55:44 +08:00
parent 8f882c9634
commit 97cd13996d
No known key found for this signature in database
GPG Key ID: E6B0AC788D373C5B
5 changed files with 161 additions and 107 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
/*
爱奇艺会员签到脚本
更新时间: 2020.9.6
更新时间: 2021.9.22
脚本兼容: QuantumultX, Surge4, Loon, JsBox, Node.js
电报频道: @NobyDa
问题反馈: @NobyDa_bot
@ -20,6 +20,8 @@ JsBox, Node.js用户抓取Cookie说明
var cookie = ''
var barkKey = ''; //Bark APP 通知推送Key
/*********************
QuantumultX 远程脚本配置:
**********************
@ -124,8 +126,8 @@ function Checkin() {
if (obj.data.signInfo.code == "A00000") {
var AwardName = obj.data.signInfo.data.rewards[0].name;
var quantity = obj.data.signInfo.data.rewards[0].value;
var continued = obj.data.signInfo.data.continueSignDaysSum;
$nobyda.data = "签到成功: " + AwardName + quantity + ", 已连签" + continued + "天 🎉"
var continued = obj.data.signInfo.data.cumulateSignDaysSum;
$nobyda.data = "签到成功: " + AwardName + quantity + ", 累计签到" + continued + "天 🎉"
console.log(`爱奇艺-${$nobyda.data} ${Details}`)
} else {
$nobyda.data = "签到失败: " + obj.data.signInfo.msg + " ⚠️"
@ -162,7 +164,7 @@ function Lottery(s) {
$nobyda.data += !$nobyda.last ? `\n抽奖成功: ${obj.awardName.replace(/《.+》/, "未中奖")} 🎉` : `\n抽奖失败: 今日已抽奖 ⚠️`
console.log(`爱奇艺-抽奖明细: ${obj.awardName.replace(/《.+》/, "未中奖")} 🎉 (${$nobyda.times}) ${Details}`)
} else if (data.match(/\"errorReason\"/)) {
msg = data.match(/msg=.+?\)/) ? data.match(/msg=(.+?)\)/)[1].replace(/用户(未登录|不存在)/, "Cookie无效") : ""
const msg = data.match(/msg=.+?\)/) ? data.match(/msg=(.+?)\)/)[1].replace(/用户(未登录|不存在)/, "Cookie无效") : ""
$nobyda.data += `\n抽奖失败: ${msg || `未知错误`} ⚠️`
console.log(`爱奇艺-抽奖失败: ${msg || `未知错误`} ⚠️ (${$nobyda.times}) ${msg ? Details : `response:\n${data}`}`)
} else {
@ -174,7 +176,8 @@ function Lottery(s) {
await Lottery(s)
} else {
const expires = $nobyda.expire ? $nobyda.expire.replace(/\u5230\u671f/, "") : "获取失败 ⚠️"
if (!$nobyda.isNode) $nobyda.notify("爱奇艺", "到期时间: " + expires, $nobyda.data)
if (!$nobyda.isNode) $nobyda.notify("爱奇艺", "到期时间: " + expires, $nobyda.data);
if (barkKey) await BarkNotify($nobyda, barkKey, '爱奇艺', `到期时间: ${expires}\n${$nobyda.data}`);
}
resolve()
})
@ -209,6 +212,8 @@ function GetCookie() {
}
}
async function BarkNotify(c,k,t,b){for(let i=0;i<3;i++){console.log(`🔷Bark notify >> Start push (${i+1})`);const s=await new Promise((n)=>{c.post({url:'https://api.day.app/push',headers:{'Content-Type':'application/json'},body:JSON.stringify({title:t,body:b,device_key:k,ext_params:{group:t}})},(e,r,d)=>r&&r.status==200?n(1):n(d||e))});if(s===1){console.log('✅Push success!');break}else{console.log(`❌Push failed! >> ${s.message||s}`)}}}
function nobyda() {
const times = 0
const start = Date.now()
@ -288,6 +293,42 @@ function nobyda() {
$http.get(options);
}
}
const post = (options, callback) => {
if (isQuanX) {
if (typeof options == "string") options = {
url: options
}
options["method"] = "POST"
$task.fetch(options).then(response => {
callback(null, adapterStatus(response), response.body)
}, reason => callback(reason.error, null, null))
}
if (isSurge) {
options.headers['X-Surge-Skip-Scripting'] = false
$httpClient.post(options, (error, response, body) => {
callback(error, adapterStatus(response), body)
})
}
if (isNode) {
node.request.post(options, (error, response, body) => {
callback(error, adapterStatus(response), body)
})
}
if (isJSBox) {
if (typeof options == "string") options = {
url: options
}
options["header"] = options["headers"]
options["handler"] = function(resp) {
let error = resp.error;
if (error) error = JSON.stringify(resp.error)
let body = resp.data;
if (typeof body == "object") body = JSON.stringify(resp.data)
callback(error, adapterStatus(resp.response), body)
}
$http.post(options);
}
}
const log = (message) => console.log(message)
const time = () => {
@ -305,6 +346,7 @@ function nobyda() {
write,
read,
get,
post,
log,
time,
times,