mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-23 23:06:06 +08:00
parent
a266425348
commit
0cde9d07ee
|
@ -13,6 +13,13 @@
|
||||||
const querystring = require('querystring');
|
const querystring = require('querystring');
|
||||||
const $ = new Env();
|
const $ = new Env();
|
||||||
const timeout = 15000; //超时时间(单位毫秒)
|
const timeout = 15000; //超时时间(单位毫秒)
|
||||||
|
// =======================================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;
|
||||||
// =======================================go-cqhttp通知设置区域===========================================
|
// =======================================go-cqhttp通知设置区域===========================================
|
||||||
//gobot_url 填写请求地址http://127.0.0.1/send_private_msg
|
//gobot_url 填写请求地址http://127.0.0.1/send_private_msg
|
||||||
//gobot_token 填写在go-cqhttp文件设置的访问密钥
|
//gobot_token 填写在go-cqhttp文件设置的访问密钥
|
||||||
|
@ -84,6 +91,16 @@ let PUSH_PLUS_TOKEN = '';
|
||||||
let PUSH_PLUS_USER = '';
|
let PUSH_PLUS_USER = '';
|
||||||
|
|
||||||
//==========================云端环境变量的判断与接收=========================
|
//==========================云端环境变量的判断与接收=========================
|
||||||
|
if (process.env.GOTIFY_URL) {
|
||||||
|
GOTIFY_URL = process.env.GOTIFY_URL;
|
||||||
|
}
|
||||||
|
if (process.env.GOTIFY_TOKEN) {
|
||||||
|
GOTIFY_TOKEN = process.env.GOTIFY_TOKEN;
|
||||||
|
}
|
||||||
|
if (process.env.GOTIFY_PRIORITY) {
|
||||||
|
GOTIFY_PRIORITY = process.env.GOTIFY_PRIORITY;
|
||||||
|
}
|
||||||
|
|
||||||
if (process.env.GOBOT_URL) {
|
if (process.env.GOBOT_URL) {
|
||||||
GOBOT_URL = process.env.GOBOT_URL;
|
GOBOT_URL = process.env.GOBOT_URL;
|
||||||
}
|
}
|
||||||
|
@ -200,9 +217,45 @@ async function sendNotify(
|
||||||
qywxamNotify(text, desp), //企业微信应用消息推送
|
qywxamNotify(text, desp), //企业微信应用消息推送
|
||||||
iGotNotify(text, desp, params), //iGot
|
iGotNotify(text, desp, params), //iGot
|
||||||
gobotNotify(text, desp),//go-cqhttp
|
gobotNotify(text, desp),//go-cqhttp
|
||||||
|
gotifyNotify(text, desp),//gotify
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
function gobotNotify(text, desp, time = 2100) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
if (GOBOT_URL) {
|
if (GOBOT_URL) {
|
||||||
|
|
|
@ -51,6 +51,10 @@ push_config = {
|
||||||
# /send_group_msg 时填入 group_id=QQ群
|
# /send_group_msg 时填入 group_id=QQ群
|
||||||
'GOBOT_TOKEN': '', # go-cqhttp 的 access_token
|
'GOBOT_TOKEN': '', # go-cqhttp 的 access_token
|
||||||
|
|
||||||
|
'GOTIFY_URL': '', # gotify地址,如https://push.example.de:8080
|
||||||
|
'GOTIFY_TOKEN': '', # gotify的消息应用token
|
||||||
|
'GOTIFY_PRIORITY': 0, # 推送消息优先级,默认为0
|
||||||
|
|
||||||
'IGOT_PUSH_KEY': '', # iGot 聚合推送的 IGOT_PUSH_KEY
|
'IGOT_PUSH_KEY': '', # iGot 聚合推送的 IGOT_PUSH_KEY
|
||||||
|
|
||||||
'PUSH_KEY': '', # server 酱的 PUSH_KEY,兼容旧版与 Turbo 版
|
'PUSH_KEY': '', # server 酱的 PUSH_KEY,兼容旧版与 Turbo 版
|
||||||
|
@ -194,6 +198,25 @@ def go_cqhttp(title: str, content: str) -> None:
|
||||||
print("go-cqhttp 推送失败!")
|
print("go-cqhttp 推送失败!")
|
||||||
|
|
||||||
|
|
||||||
|
def gotify(title:str,content:str) -> None:
|
||||||
|
"""
|
||||||
|
使用 gotify 推送消息。
|
||||||
|
"""
|
||||||
|
if not push_config.get("GOTIFY_URL") or not push_config.get("GOTIFY_TOKEN"):
|
||||||
|
print("gotify 服务的 GOTIFY_URL 或 GOTIFY_TOKEN 未设置!!\n取消推送")
|
||||||
|
return
|
||||||
|
print("gotify 服务启动")
|
||||||
|
|
||||||
|
url = f'{push_config.get("GOTIFY_URL")}/message?token={push_config.get("GOTIFY_TOKEN")}'
|
||||||
|
data = {"title": title,"message": content,"priority": push_config.get("GOTIFY_PRIORITY")}
|
||||||
|
response = requests.post(url,data=data).json()
|
||||||
|
|
||||||
|
if response.get("id"):
|
||||||
|
print("gotify 推送成功!")
|
||||||
|
else:
|
||||||
|
print("gotify 推送失败!")
|
||||||
|
|
||||||
|
|
||||||
def iGot(title: str, content: str) -> None:
|
def iGot(title: str, content: str) -> None:
|
||||||
"""
|
"""
|
||||||
使用 iGot 推送消息。
|
使用 iGot 推送消息。
|
||||||
|
@ -473,6 +496,8 @@ if push_config.get("FSKEY"):
|
||||||
notify_function.append(feishu_bot)
|
notify_function.append(feishu_bot)
|
||||||
if push_config.get("GOBOT_URL") and push_config.get("GOBOT_QQ"):
|
if push_config.get("GOBOT_URL") and push_config.get("GOBOT_QQ"):
|
||||||
notify_function.append(go_cqhttp)
|
notify_function.append(go_cqhttp)
|
||||||
|
if push_config.get("GOTIFY_URL") and push_config.get("GOTIFY_TOKEN"):
|
||||||
|
notify_function.append(gotify)
|
||||||
if push_config.get("IGOT_PUSH_KEY"):
|
if push_config.get("IGOT_PUSH_KEY"):
|
||||||
notify_function.append(iGot)
|
notify_function.append(iGot)
|
||||||
if push_config.get("PUSH_KEY"):
|
if push_config.get("PUSH_KEY"):
|
||||||
|
|
|
@ -64,6 +64,7 @@ export default {
|
||||||
logs: '任务日志',
|
logs: '任务日志',
|
||||||
},
|
},
|
||||||
notificationModes: [
|
notificationModes: [
|
||||||
|
{ value: 'gotify', label: 'Gotify' },
|
||||||
{ value: 'goCqHttpBot', label: 'GoCqHttpBot' },
|
{ value: 'goCqHttpBot', label: 'GoCqHttpBot' },
|
||||||
{ value: 'serverChan', label: 'Server酱' },
|
{ value: 'serverChan', label: 'Server酱' },
|
||||||
{ value: 'bark', label: 'Bark' },
|
{ value: 'bark', label: 'Bark' },
|
||||||
|
@ -77,6 +78,15 @@ export default {
|
||||||
{ value: 'closed', label: '已关闭' },
|
{ value: 'closed', label: '已关闭' },
|
||||||
],
|
],
|
||||||
notificationModeMap: {
|
notificationModeMap: {
|
||||||
|
gotify: [
|
||||||
|
{
|
||||||
|
label: 'gotifyUrl',
|
||||||
|
tip: 'gotify的url地址,例如 https://push.example.de:8080',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{ label: 'gotifyToken', tip: 'gotify的消息应用token码', required: true },
|
||||||
|
{ label: 'gotifyPriority', tip: '推送消息的优先级' },
|
||||||
|
],
|
||||||
goCqHttpBot: [
|
goCqHttpBot: [
|
||||||
{
|
{
|
||||||
label: 'goCqHttpBotUrl',
|
label: 'goCqHttpBotUrl',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user