增加TG代理选项

This commit is contained in:
Shinku
2026-03-20 00:57:40 +08:00
parent ee6eeaddeb
commit 54203d64a3
4 changed files with 56 additions and 20 deletions
+14 -9
View File
@@ -1,5 +1,6 @@
import { fetch } from 'undici';
import { config } from '../config.js';
import { withExplicitProxyRequestInit } from './siteProxy.js';
import nodemailer, { type Transporter } from 'nodemailer';
import {
createNotificationSignature,
@@ -224,15 +225,19 @@ export async function sendNotification(
tasks.push({
channel: 'telegram',
run: async () => {
const response = await fetch(telegramApiUrl, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
chat_id: config.telegramChatId,
text,
disable_web_page_preview: true,
}),
});
const telegramRequestInit = withExplicitProxyRequestInit(
config.telegramUseSystemProxy ? config.systemProxyUrl : null,
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
chat_id: config.telegramChatId,
text,
disable_web_page_preview: true,
}),
},
);
const response = await fetch(telegramApiUrl, telegramRequestInit);
if (!response.ok) {
throw new Error(`Telegram 响应状态 ${response.status}`);
}