mirror of
https://github.com/whyour/qinglong.git
synced 2025-07-27 14:46:06 +08:00
按pr要求修改
This commit is contained in:
parent
8f70329698
commit
08df6175ed
|
@ -152,14 +152,15 @@ export default class NotificationService {
|
|||
|
||||
private async serverChan() {
|
||||
const { serverChanKey } = this.params;
|
||||
const url = serverChanKey.startsWith('sctp')
|
||||
? `https://${serverChanKey}.push.ft07.com/send`
|
||||
const matchResult = serverChanKey.match(/^sctp(\d+)t/i);
|
||||
const url = matchResult && matchResult[1]
|
||||
? `https://${matchResult[1]}.push.ft07.com/send/${serverChanKey}.send`
|
||||
: `https://sctapi.ftqq.com/${serverChanKey}.send`;
|
||||
try {
|
||||
const res: any = await got
|
||||
.post(url, {
|
||||
...this.gotOption,
|
||||
body: `title=${this.title}&desp=${this.content}`,
|
||||
body: `title=${encodeURIComponent(this.title)}&desp=${encodeURIComponent(this.content)}`,
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||
})
|
||||
.json();
|
||||
|
|
|
@ -228,11 +228,13 @@ function serverNotify(text, desp) {
|
|||
if (PUSH_KEY) {
|
||||
// 微信server酱推送通知一个\n不会换行,需要两个\n才能换行,故做此替换
|
||||
desp = desp.replace(/[\n\r]/g, '\n\n');
|
||||
|
||||
const matchResult = PUSH_KEY.match(/^sctp(\d+)t/i);
|
||||
const options = {
|
||||
url: PUSH_KEY.startsWith('sctp')
|
||||
? `https://${PUSH_KEY}.push.ft07.com/send`
|
||||
url: matchResult && matchResult[1]
|
||||
? `https://${matchResult[1]}.push.ft07.com/send/${PUSH_KEY}.send`
|
||||
: `https://sctapi.ftqq.com/${PUSH_KEY}.send`,
|
||||
body: `text=${text}&desp=${desp}`,
|
||||
body: `text=${encodeURIComponent(text)}&desp=${encodeURIComponent(desp)}`,
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
|
@ -1194,7 +1196,7 @@ function webhookNotify(text, desp) {
|
|||
|
||||
function ntfyNotify(text, desp) {
|
||||
function encodeRFC2047(text) {
|
||||
const encodedBase64 = btoa(String.fromCharCode(...new TextEncoder().encode(text)));
|
||||
const encodedBase64 = Buffer.from(text).toString('base64');
|
||||
return `=?utf-8?B?${encodedBase64}?=`;
|
||||
}
|
||||
|
||||
|
|
|
@ -780,10 +780,6 @@ def chronocat(title: str, content: str) -> None:
|
|||
else:
|
||||
print(f"QQ群消息:{ids}推送失败!")
|
||||
|
||||
|
||||
import base64
|
||||
import requests
|
||||
|
||||
def ntfy(title: str, content: str) -> None:
|
||||
"""
|
||||
通过 Ntfy 推送消息
|
||||
|
|
Loading…
Reference in New Issue
Block a user