Telegram: cast fetch to grammy client type

This commit is contained in:
Tobias Bischoff
2026-01-08 15:16:53 +01:00
committed by Peter Steinberger
parent a0bb2bccaf
commit 897685a2de
2 changed files with 16 additions and 8 deletions

View File

@@ -1,5 +1,4 @@
import type { ApiClientOptions } from "grammy";
import { Bot } from "grammy";
import { Bot, type ApiClientOptions } from "grammy";
import { resolveTelegramFetch } from "./fetch.js";
export async function setTelegramWebhook(opts: {
@@ -12,7 +11,10 @@ export async function setTelegramWebhook(opts: {
const client: ApiClientOptions | undefined = fetchImpl
? { fetch: fetchImpl as unknown as ApiClientOptions["fetch"] }
: undefined;
const bot = new Bot(opts.token, client ? { client } : undefined);
const bot = new Bot(
opts.token,
client ? { client } : undefined,
);
await bot.api.setWebhook(opts.url, {
secret_token: opts.secret,
drop_pending_updates: opts.dropPendingUpdates ?? false,
@@ -24,6 +26,9 @@ export async function deleteTelegramWebhook(opts: { token: string }) {
const client: ApiClientOptions | undefined = fetchImpl
? { fetch: fetchImpl as unknown as ApiClientOptions["fetch"] }
: undefined;
const bot = new Bot(opts.token, client ? { client } : undefined);
const bot = new Bot(
opts.token,
client ? { client } : undefined,
);
await bot.api.deleteWebhook();
}