feat: 通知支持 shoutrrr(需自行安装或使用打包好的 Docker 镜像)

This commit is contained in:
xream committed 2025-08-30 17:24:11 +08:00
1 parent 12862444c3
commit bb443c857a
2 files changed
+55 -22

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.20.15",
"version": "2.20.16",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
"main": "src/main.js",
"scripts": {
+54 -21
View File
@@ -278,28 +278,61 @@ export class OpenAPI {
let push = eval('process.env.SUB_STORE_PUSH_SERVICE');
if (push) {
const url = push
.replace(
'[推送标题]',
encodeURIComponent(title || 'Sub-Store'),
)
.replace(
'[推送内容]',
encodeURIComponent(
[subtitle, content_].map((i) => i).join('\n'),
),
);
const $http = HTTP();
$http
.get({ url })
.then((resp) => {
console.log(
`[Push Service] URL: ${url}\nRES: ${resp.statusCode} ${resp.body}`,
if (/^https?:\/\//.test(push)) {
// 处理 HTTP/HTTPS URL
const url = push
.replace(
'[推送标题]',
encodeURIComponent(title || 'Sub-Store'),
)
.replace(
'[推送内容]',
encodeURIComponent(
[subtitle, content_].map((i) => i).join('\n'),
),
);
})
.catch((e) => {
console.log(`[Push Service] URL: ${url}\nERROR: ${e}`);
});
const $http = HTTP();
$http
.get({ url })
.then((resp) => {
console.log(
`[Push Service] URL: ${url}\nRES: ${resp.statusCode} ${resp.body}`,
);
})
.catch((e) => {
console.log(
`[Push Service] URL: ${url}\nERROR: ${e}`,
);
});
} else {
const { execFile } = eval(`require("child_process")`);
execFile(
'shoutrrr',
[
'send',
'--url',
push,
'--message',
`${title}\n${subtitle}\n${content_}`,
],
(error, stdout, stderr) => {
if (error) {
console.log(
`[Push Service] URL: ${push}\nERROR: ${error}`,
);
return;
}
if (stderr) {
console.log(
`[Push Service] URL: ${push}\nstderr: ${stderr}`,
);
}
console.log(
`[Push Service] URL: ${push}\nstdout: ${stdout}`,
);
},
);
}
}
}
if (isGUIforCores) {