fix: force telegram native fetch under bun

This commit is contained in:
Peter Steinberger
2026-01-08 04:40:29 +01:00
parent 3178a3014d
commit ab98ffe9fe
7 changed files with 101 additions and 11 deletions

View File

@@ -52,6 +52,7 @@ import type { RuntimeEnv } from "../runtime.js";
import { loadWebMedia } from "../web/media.js";
import { resolveTelegramAccount } from "./accounts.js";
import { createTelegramDraftStream } from "./draft-stream.js";
import { resolveTelegramFetch } from "./fetch.js";
import { markdownToTelegramHtml } from "./format.js";
import {
readTelegramAllowFromStore,
@@ -150,9 +151,10 @@ export function createTelegramBot(opts: TelegramBotOptions) {
throw new Error(`exit ${code}`);
},
};
const client: ApiClientOptions | undefined = opts.proxyFetch
? { fetch: opts.proxyFetch as unknown as ApiClientOptions["fetch"] }
: undefined;
const fetchImpl = resolveTelegramFetch(opts.proxyFetch);
const client: ApiClientOptions = {
fetch: fetchImpl as unknown as ApiClientOptions["fetch"],
};
const bot = new Bot(opts.token, { client });
bot.api.config.use(apiThrottler());