11import { timingSafeEqual } from "node:crypto" ;
22import { createServer } from "node:http" ;
3- import { InputFile , webhookCallback } from "grammy" ;
3+ import * as grammy from "grammy" ;
44import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime" ;
55import { isDiagnosticsEnabled } from "openclaw/plugin-sdk/infra-runtime" ;
66import { formatErrorMessage } from "openclaw/plugin-sdk/infra-runtime" ;
@@ -21,6 +21,12 @@ import { createTelegramBot } from "./bot.js";
2121const TELEGRAM_WEBHOOK_MAX_BODY_BYTES = 1024 * 1024 ;
2222const TELEGRAM_WEBHOOK_BODY_TIMEOUT_MS = 30_000 ;
2323const TELEGRAM_WEBHOOK_CALLBACK_TIMEOUT_MS = 10_000 ;
24+ const InputFileCtor : typeof grammy . InputFile =
25+ typeof grammy . InputFile === "function"
26+ ? grammy . InputFile
27+ : ( class InputFileFallback {
28+ constructor ( public readonly path : string ) { }
29+ } as unknown as typeof grammy . InputFile ) ;
2430
2531async function listenHttpServer ( params : {
2632 server : ReturnType < typeof createServer > ;
@@ -137,7 +143,7 @@ export async function startTelegramWebhook(opts: {
137143 runtime,
138144 abortSignal : opts . abortSignal ,
139145 } ) ;
140- const handler = webhookCallback ( bot , "callback" , {
146+ const handler = grammy . webhookCallback ( bot , "callback" , {
141147 secretToken : secret ,
142148 onTimeout : "return" ,
143149 timeoutMilliseconds : TELEGRAM_WEBHOOK_CALLBACK_TIMEOUT_MS ,
@@ -270,7 +276,7 @@ export async function startTelegramWebhook(opts: {
270276 bot . api . setWebhook ( publicUrl , {
271277 secret_token : secret ,
272278 allowed_updates : resolveTelegramAllowedUpdates ( ) ,
273- certificate : opts . webhookCertPath ? new InputFile ( opts . webhookCertPath ) : undefined ,
279+ certificate : opts . webhookCertPath ? new InputFileCtor ( opts . webhookCertPath ) : undefined ,
274280 } ) ,
275281 } ) ;
276282 } catch ( err ) {
0 commit comments