mirror of
https://github.com/whyour/qinglong.git
synced 2026-07-01 04:40:38 +08:00
改进ntfy通知,将中文标题进行编码后发送 (#2541)
* 1.改进ntfy通知,将中文标题进行编码后发送,可以直接展示中文标题;2.改进notify.py和notify.js中ntfy的推送; --------- Co-authored-by: qiaoyun680 <qiaoyun680>
This commit is contained in:
+10
-4
@@ -1195,14 +1195,19 @@ function webhookNotify(text, desp) {
|
||||
}
|
||||
|
||||
function ntfyNotify(text, desp) {
|
||||
function encodeRFC2047(text) {
|
||||
const encodedBase64 = Buffer.from(text).toString('base64');
|
||||
return `=?utf-8?B?${encodedBase64}?=`;
|
||||
}
|
||||
|
||||
return new Promise((resolve) => {
|
||||
const { NTFY_URL, NTFY_TOPIC, NTFY_PRIORITY } = push_config;
|
||||
if (NTFY_TOPIC) {
|
||||
const options = {
|
||||
url: NTFY_URL || `https://ntfy.sh`,
|
||||
body: `${desp}\n${text}`,
|
||||
url: `${NTFY_URL || 'https://ntfy.sh'}/${NTFY_TOPIC}`,
|
||||
body: `${desp}`,
|
||||
headers: {
|
||||
'Title': 'qinglong',
|
||||
'Title': `${encodeRFC2047(text)}`,
|
||||
'Priority': NTFY_PRIORITY || '3'
|
||||
},
|
||||
timeout,
|
||||
@@ -1212,7 +1217,7 @@ function ntfyNotify(text, desp) {
|
||||
if (err) {
|
||||
console.log('Ntfy 通知调用API失败😞\n', err);
|
||||
} else {
|
||||
if (data.success) {
|
||||
if (data.id) {
|
||||
console.log('Ntfy 发送通知消息成功🎉\n');
|
||||
} else {
|
||||
console.log(`Ntfy 发送通知消息异常 ${JSON.stringify(data)}`);
|
||||
@@ -1230,6 +1235,7 @@ function ntfyNotify(text, desp) {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function parseString(input, valueFormatFn) {
|
||||
const regex = /(\w+):\s*((?:(?!\n\w+:).)*)/g;
|
||||
const matches = {};
|
||||
|
||||
Reference in New Issue
Block a user