forked from boos/BoosAPI
增加TG代理选项
This commit is contained in:
@@ -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}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user