


























@@ -23,6 +23,7 @@ export type TelegramProbeOptions = {
2323network?: TelegramNetworkConfig;
2424accountId?: string;
2525apiRoot?: string;
26+includeWebhookInfo?: boolean;
2627};
27282829const probeFetcherCache = new Map<string, typeof fetch>();
@@ -102,6 +103,7 @@ export async function probeTelegram(
102103const timeoutBudgetMs = Math.max(1, Math.floor(timeoutMs));
103104const deadlineMs = started + timeoutBudgetMs;
104105const options = resolveProbeOptions(proxyOrOptions);
106+const includeWebhookInfo = options?.includeWebhookInfo !== false;
105107const fetcher = resolveProbeFetcher(token, options);
106108const apiBase = resolveTelegramApiBase(options?.apiRoot);
107109const base = `${apiBase}/bot${token}`;
@@ -184,29 +186,31 @@ export async function probeTelegram(
184186 : null,
185187};
186188187-// Try to fetch webhook info, but don't fail health if it errors.
188-try {
189-const webhookRemainingBudgetMs = resolveRemainingBudgetMs();
190-if (webhookRemainingBudgetMs > 0) {
191-const webhookRes = await fetchWithTimeout(
192-`${base}/getWebhookInfo`,
193-{},
194-Math.max(1, Math.min(timeoutBudgetMs, webhookRemainingBudgetMs)),
195-fetcher,
196-);
197-const webhookJson = (await webhookRes.json()) as {
198-ok?: boolean;
199-result?: { url?: string; has_custom_certificate?: boolean };
200-};
201-if (webhookRes.ok && webhookJson?.ok) {
202-result.webhook = {
203-url: webhookJson.result?.url ?? null,
204-hasCustomCert: webhookJson.result?.has_custom_certificate ?? null,
189+if (includeWebhookInfo) {
190+// Try to fetch webhook info, but don't fail health if it errors.
191+try {
192+const webhookRemainingBudgetMs = resolveRemainingBudgetMs();
193+if (webhookRemainingBudgetMs > 0) {
194+const webhookRes = await fetchWithTimeout(
195+`${base}/getWebhookInfo`,
196+{},
197+Math.max(1, Math.min(timeoutBudgetMs, webhookRemainingBudgetMs)),
198+fetcher,
199+);
200+const webhookJson = (await webhookRes.json()) as {
201+ok?: boolean;
202+result?: { url?: string; has_custom_certificate?: boolean };
205203};
204+if (webhookRes.ok && webhookJson?.ok) {
205+result.webhook = {
206+url: webhookJson.result?.url ?? null,
207+hasCustomCert: webhookJson.result?.has_custom_certificate ?? null,
208+};
209+}
206210}
211+} catch {
212+// ignore webhook errors for probe
207213}
208-} catch {
209-// ignore webhook errors for probe
210214}
211215212216result.ok = true;
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。