mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-22 22:36:06 +08:00
parent
185fd2ff91
commit
ecc55883f0
|
@ -152,14 +152,16 @@ export default class NotificationService {
|
||||||
|
|
||||||
private async serverChan() {
|
private async serverChan() {
|
||||||
const { serverChanKey } = this.params;
|
const { serverChanKey } = this.params;
|
||||||
const url = serverChanKey.startsWith('sctp')
|
const matchResult = serverChanKey.match(/^sctp(\d+)t/i);
|
||||||
? `https://${serverChanKey}.push.ft07.com/send`
|
const url = matchResult && matchResult[1]
|
||||||
|
? `https://${matchResult[1]}.push.ft07.com/send/${serverChanKey}.send`
|
||||||
: `https://sctapi.ftqq.com/${serverChanKey}.send`;
|
: `https://sctapi.ftqq.com/${serverChanKey}.send`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res: any = await got
|
const res: any = await got
|
||||||
.post(url, {
|
.post(url, {
|
||||||
...this.gotOption,
|
...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' },
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||||
})
|
})
|
||||||
.json();
|
.json();
|
||||||
|
|
|
@ -228,11 +228,13 @@ function serverNotify(text, desp) {
|
||||||
if (PUSH_KEY) {
|
if (PUSH_KEY) {
|
||||||
// 微信server酱推送通知一个\n不会换行,需要两个\n才能换行,故做此替换
|
// 微信server酱推送通知一个\n不会换行,需要两个\n才能换行,故做此替换
|
||||||
desp = desp.replace(/[\n\r]/g, '\n\n');
|
desp = desp.replace(/[\n\r]/g, '\n\n');
|
||||||
|
|
||||||
|
const matchResult = PUSH_KEY.match(/^sctp(\d+)t/i);
|
||||||
const options = {
|
const options = {
|
||||||
url: PUSH_KEY.startsWith('sctp')
|
url: matchResult && matchResult[1]
|
||||||
? `https://${PUSH_KEY}.push.ft07.com/send`
|
? `https://${matchResult[1]}.push.ft07.com/send/${PUSH_KEY}.send`
|
||||||
: `https://sctapi.ftqq.com/${PUSH_KEY}.send`,
|
: `https://sctapi.ftqq.com/${PUSH_KEY}.send`,
|
||||||
body: `text=${text}&desp=${desp}`,
|
body: `text=${encodeURIComponent(text)}&desp=${encodeURIComponent(desp)}`,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/x-www-form-urlencoded',
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
},
|
},
|
||||||
|
|
|
@ -302,10 +302,14 @@ def serverJ(title: str, content: str) -> None:
|
||||||
print("serverJ 服务启动")
|
print("serverJ 服务启动")
|
||||||
|
|
||||||
data = {"text": title, "desp": content.replace("\n", "\n\n")}
|
data = {"text": title, "desp": content.replace("\n", "\n\n")}
|
||||||
if push_config.get("PUSH_KEY").startswith("sctp"):
|
|
||||||
url = f'https://{push_config.get("PUSH_KEY")}.push.ft07.com/send'
|
match = re.match(r'sctp(\d+)t', push_config.get("PUSH_KEY"))
|
||||||
|
if match:
|
||||||
|
num = match.group(1)
|
||||||
|
url = f'https://{num}.push.ft07.com/send/{push_config.get("PUSH_KEY")}.send'
|
||||||
else:
|
else:
|
||||||
url = f'https://sctapi.ftqq.com/{push_config.get("PUSH_KEY")}.send'
|
url = f'https://sctapi.ftqq.com/{push_config.get("PUSH_KEY")}.send'
|
||||||
|
|
||||||
response = requests.post(url, data=data).json()
|
response = requests.post(url, data=data).json()
|
||||||
|
|
||||||
if response.get("errno") == 0 or response.get("code") == 0:
|
if response.get("errno") == 0 or response.get("code") == 0:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user