fix(telegram): gate native fetch to bun

This commit is contained in:
Peter Steinberger
2026-01-08 08:10:10 +01:00
parent c1e97fab80
commit c241cb25bd
5 changed files with 27 additions and 19 deletions

View File

@@ -7,9 +7,11 @@ export async function setTelegramWebhook(opts: {
secret?: string;
dropPendingUpdates?: boolean;
}) {
const bot = new Bot(opts.token, {
client: { fetch: resolveTelegramFetch() },
});
const fetchImpl = resolveTelegramFetch();
const bot = new Bot(
opts.token,
fetchImpl ? { client: { fetch: fetchImpl } } : undefined,
);
await bot.api.setWebhook(opts.url, {
secret_token: opts.secret,
drop_pending_updates: opts.dropPendingUpdates ?? false,
@@ -17,8 +19,10 @@ export async function setTelegramWebhook(opts: {
}
export async function deleteTelegramWebhook(opts: { token: string }) {
const bot = new Bot(opts.token, {
client: { fetch: resolveTelegramFetch() },
});
const fetchImpl = resolveTelegramFetch();
const bot = new Bot(
opts.token,
fetchImpl ? { client: { fetch: fetchImpl } } : undefined,
);
await bot.api.deleteWebhook();
}