优化Server酱Key相关的逻辑 (#2538)

* 优化sendkey的兼容

* 对title和desp encode
This commit is contained in:
Easy
2024-10-22 21:49:07 +08:00
committed by GitHub
parent 185fd2ff91
commit ecc55883f0
3 changed files with 17 additions and 9 deletions
+6 -4
View File
@@ -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`
: `https://sctapi.ftqq.com/${PUSH_KEY}.send`,
body: `text=${text}&desp=${desp}`,
url: matchResult && matchResult[1]
? `https://${matchResult[1]}.push.ft07.com/send/${PUSH_KEY}.send`
: `https://sctapi.ftqq.com/${PUSH_KEY}.send`,
body: `text=${encodeURIComponent(text)}&desp=${encodeURIComponent(desp)}`,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},