mirror of
https://github.com/sub-store-org/Sub-Store.git
synced 2026-11-27 23:13:43 +00:00
feat: 通知支持 shoutrrr(需自行安装或使用打包好的 Docker 镜像)
This commit is contained in:
2 files changed
+55
-22
No files matched your search
@@ -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": {
|
||||
|
||||
Vendored
+54
-21
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user