mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-24 07:16:08 +08:00
修复通知
This commit is contained in:
parent
aa08f489d7
commit
f482796cdf
|
@ -80,21 +80,25 @@ export default class NotificationService {
|
||||||
|
|
||||||
private async serverChan() {
|
private async serverChan() {
|
||||||
const { serverChanKey } = this.params;
|
const { serverChanKey } = this.params;
|
||||||
const url = serverChanKey.includes('SCT')
|
const url = serverChanKey.startsWith('SCT')
|
||||||
? `https://sctapi.ftqq.com/${SCKEY}.send`
|
? `https://sctapi.ftqq.com/${serverChanKey}.send`
|
||||||
: `https://sc.ftqq.com/${SCKEY}.send`;
|
: `https://sc.ftqq.com/${serverChanKey}.send`;
|
||||||
const res: any = await got
|
const res: any = await got
|
||||||
.post(url, {
|
.post(url, {
|
||||||
timeout: this.timeout,
|
timeout: this.timeout,
|
||||||
retry: 0,
|
retry: 0,
|
||||||
body: `text=${this.title}&desp=${this.content}`,
|
body: `title=${this.title}&desp=${this.content}`,
|
||||||
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||||
})
|
})
|
||||||
.json();
|
.json();
|
||||||
return res.errno === 0 || res.data.errno === 0;
|
return res.errno === 0 || res.data.errno === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async bark() {
|
private async bark() {
|
||||||
const { barkPush, barkSound, barkGroup } = this.params;
|
let { barkPush, barkSound, barkGroup } = this.params;
|
||||||
|
if (!barkPush.startsWith('http') && !barkPush.startsWith('https')) {
|
||||||
|
barkPush = `https://api.day.app/${barkPush}`;
|
||||||
|
}
|
||||||
const url = `${barkPush}/${encodeURIComponent(
|
const url = `${barkPush}/${encodeURIComponent(
|
||||||
this.title,
|
this.title,
|
||||||
)}/${encodeURIComponent(
|
)}/${encodeURIComponent(
|
||||||
|
@ -119,26 +123,32 @@ export default class NotificationService {
|
||||||
telegramBotToken,
|
telegramBotToken,
|
||||||
telegramBotUserId,
|
telegramBotUserId,
|
||||||
} = this.params;
|
} = this.params;
|
||||||
const url = `https://${telegramBotApiHost}/bot${telegramBotToken}/sendMessage`;
|
const url = `https://${
|
||||||
const options = {
|
telegramBotApiHost ? telegramBotApiHost : 'api.telegram.org'
|
||||||
keepAlive: true,
|
}/bot${telegramBotToken}/sendMessage`;
|
||||||
keepAliveMsecs: 1000,
|
let agent;
|
||||||
maxSockets: 256,
|
if (telegramBotProxyHost && telegramBotProxyPort) {
|
||||||
maxFreeSockets: 256,
|
const options: any = {
|
||||||
proxy: `http://${telegramBotProxyHost}:${telegramBotProxyPort}`,
|
keepAlive: true,
|
||||||
};
|
keepAliveMsecs: 1000,
|
||||||
const httpAgent = new HttpProxyAgent(options);
|
maxSockets: 256,
|
||||||
const httpsAgent = new HttpsProxyAgent(options);
|
maxFreeSockets: 256,
|
||||||
|
proxy: `http://${telegramBotProxyHost}:${telegramBotProxyPort}`,
|
||||||
|
};
|
||||||
|
const httpAgent = new HttpProxyAgent(options);
|
||||||
|
const httpsAgent = new HttpsProxyAgent(options);
|
||||||
|
agent = {
|
||||||
|
http: httpAgent,
|
||||||
|
https: httpsAgent,
|
||||||
|
};
|
||||||
|
}
|
||||||
const res: any = await got
|
const res: any = await got
|
||||||
.post(url, {
|
.post(url, {
|
||||||
timeout: this.timeout,
|
timeout: this.timeout,
|
||||||
retry: 0,
|
retry: 0,
|
||||||
body: `chat_id=${telegramBotUserId}&text=${this.title}\n\n${this.content}&disable_web_page_preview=true`,
|
body: `chat_id=${telegramBotUserId}&text=${this.title}\n\n${this.content}&disable_web_page_preview=true`,
|
||||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||||
agent: {
|
agent,
|
||||||
http: httpAgent,
|
|
||||||
https: httpsAgent,
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
.json();
|
.json();
|
||||||
return !!res.ok;
|
return !!res.ok;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user