import * as _gramio_callback_data from '@gramio/callback-data'; import { CallbackData } from '@gramio/callback-data'; export * from '@gramio/callback-data'; import * as _gramio_contexts from '@gramio/contexts'; import { UpdateName, MessageEventName, CustomEventName, Context, ContextsMapping, BotLike, ContextType, Attachment, AttachmentsMapping, Dice, MessageOriginUser, MessageOriginChat, MessageOriginChannel, MessageOriginHiddenUser, Message, MessageEntity, TextQuote, User, LinkPreviewOptions, ExternalReplyInfo, Chat, Giveaway, PaidMediaInfo, Game, StoryAttachment, Venue, MessageContext } from '@gramio/contexts'; export * from '@gramio/contexts'; import { FileSource, TelegramFileDownload } from '@gramio/files'; export * from '@gramio/files'; export * from '@gramio/format'; export * from '@gramio/keyboards'; import * as _gramio_types from '@gramio/types'; import { APIMethods, TelegramResponseParameters, TelegramAPIResponseError, TelegramReactionTypeEmojiEmoji, TelegramUser, APIMethodParams, APIMethodReturn, TelegramBotCommandScope, SetWebhookParams, TelegramUpdate, TelegramMessageEntity } from '@gramio/types'; export * from '@gramio/types'; import * as _gramio_composer from '@gramio/composer'; import { ComposerLike, MacroDefinitions, EventContextOf, EventComposer, MacroDef, Next, EventQueue, HandlerOptions, DeriveFromOptions } from '@gramio/composer'; export { ContextCallback, DeriveFromOptions, DeriveHandler, EventComposer, EventQueue, HandlerOptions, MacroDef, MacroDefinitions, MacroDeriveType, MacroHooks, MacroOptionType, Middleware, Next, WithCtx, WithDecorate, WithDerives, WithEventDerive, WithExtend, buildFromOptions, compose, noopNext, skip, stop } from '@gramio/composer'; /** * Telegram Bot API top-level update type name. * Valid values for `allowed_updates` in `getUpdates` / `setWebhook`. */ type AllowedUpdateName = Exclude; /** The 3 types Telegram excludes by default (must be explicitly requested). */ declare const OPT_IN_TYPES: readonly AllowedUpdateName[]; /** * Maps any event name to the `AllowedUpdateName` values needed in `allowed_updates`. * * - Top-level update names → themselves * - Sub-message events (MessageEventName) → all 5 message-carrying parent types * - Unknown names (filter names like "text") → `undefined` (skipped) */ declare function mapEventToAllowedUpdates(event: string): readonly AllowedUpdateName[] | undefined; /** * Detect which of the 3 opt-in types have handlers registered. * Used by `bot.start()` for default auto opt-in behavior. */ declare function detectOptInUpdates(registeredEvents: Set): AllowedUpdateName[]; /** * Fluent, immutable builder for the Telegram Bot API `allowed_updates` list. * * Instances directly extend `Array`, so they can be passed * wherever `allowedUpdates` is expected without any conversion. * * @example * ```typescript * import { AllowedUpdatesFilter } from "gramio"; * * // All updates (opt-in types included: chat_member, message_reaction, message_reaction_count) * bot.start({ allowedUpdates: AllowedUpdatesFilter.all }); * * // Telegram's default set (opt-in types excluded) * bot.start({ allowedUpdates: AllowedUpdatesFilter.default }); * * // Explicit list * bot.start({ allowedUpdates: AllowedUpdatesFilter.only("message", "callback_query") }); * * // All except poll events * bot.start({ allowedUpdates: AllowedUpdatesFilter.all.except("poll", "poll_answer") }); * * // Default + opt-in to chat_member * bot.start({ allowedUpdates: AllowedUpdatesFilter.default.add("chat_member") }); * ``` */ declare class AllowedUpdatesFilter extends Array { /** @internal use static factory methods instead */ constructor(updates: readonly AllowedUpdateName[]); /** * All update types, including the opt-in ones: * `chat_member`, `message_reaction`, and `message_reaction_count`. */ static get all(): AllowedUpdatesFilter; /** * Telegram's **default** update set. * * Receive all updates _except_ `chat_member`, `message_reaction`, and * `message_reaction_count` — the three types that Telegram requires to be * explicitly listed in `allowed_updates`. * * This matches what Telegram does when `allowed_updates` is omitted or * passed as an empty array. */ static get default(): AllowedUpdatesFilter; /** * Create a filter with **exactly** the specified update types. * * @example * ```typescript * AllowedUpdatesFilter.only("message", "callback_query", "inline_query") * ``` */ static only(...types: AllowedUpdateName[]): AllowedUpdatesFilter; /** * Return a new filter with the given types **added**. * Already-present types are silently deduplicated. * * @example * ```typescript * AllowedUpdatesFilter.default.add("chat_member", "message_reaction") * ``` */ add(...types: AllowedUpdateName[]): AllowedUpdatesFilter; /** * Return a new filter with the given types **removed**. * * @example * ```typescript * AllowedUpdatesFilter.all.except("poll", "poll_answer", "chosen_inline_result") * ``` */ except(...types: AllowedUpdateName[]): AllowedUpdatesFilter; /** Convert to a plain `AllowedUpdateName[]` array. */ toArray(): AllowedUpdateName[]; } /** * Build an {@link AllowedUpdatesFilter} automatically from a bot's registered * `.on()` handlers (including handlers from extended plugins). * * Returns **only** the update types that handlers explicitly register for. * Use this for strict filtering — Telegram will only send these update types. * * **Note:** filter-only `.on(filterFn, handler)` and `.use()` middleware * do not declare specific events and are not included. * Manually `.add()` additional types if needed. * * Call after all handlers/plugins are registered (or after `bot.init()`). * * @example * ```typescript * const bot = new Bot(token) * .command("start", handler) * .callbackQuery("data", handler); * * bot.start({ allowedUpdates: buildAllowedUpdates(bot) }); * // → allowed_updates: ["message", "business_message", "callback_query"] * * // With customization: * bot.start({ allowedUpdates: buildAllowedUpdates(bot).add("poll") }); * ``` */ declare function buildAllowedUpdates(bot: { updates: { composer: { registeredEvents(): Set; }; }; }): AllowedUpdatesFilter; /** Symbol to determine which error kind is it */ declare const ErrorKind: symbol; /** Represent {@link TelegramAPIResponseError} and thrown in API calls */ declare class TelegramError extends Error { /** Name of the API Method */ method: T; /** Params that were sent */ params: MaybeSuppressedParams; /** See {@link TelegramAPIResponseError.error_code}*/ code: number; /** Describes why a request was unsuccessful. */ payload?: TelegramResponseParameters; /** Construct new TelegramError */ constructor(error: TelegramAPIResponseError, method: T, params: MaybeSuppressedParams, callSite?: Error); } type MaybeArray = T | T[] | ReadonlyArray; type TelegramEventMap = { [K in keyof ContextsMapping]: InstanceType[K]>; }; /** Concrete context type without GetDerives (which collapses to any with AnyBot) */ type Ctx> = InstanceType[K]>; /** * Extends `ComposerLike` with the two internal members that method * bodies need: macro registry and the cross-method `chosenInlineResult` call. */ type GramIOLike = ComposerLike & { "~": { macros: MacroDefinitions; commandsMeta?: Map; Derives?: Record; }; chosenInlineResult(trigger: any, handler: any, macroOptions?: any): T; }; declare const methods: { reaction>(this: TThis, trigger: MaybeArray, handler: (context: Ctx<"message_reaction"> & EventContextOf) => unknown, macroOptions?: Record): TThis; callbackQuery, Trigger extends CallbackData | string | RegExp>(this: TThis, trigger: Trigger, handler: (context: Ctx<"callback_query"> & { queryData: Trigger extends CallbackData ? ReturnType : Trigger extends RegExp ? RegExpMatchArray : never; } & EventContextOf) => unknown, macroOptions?: Record): TThis; chosenInlineResult, Trigger extends CallbackData | RegExp | string | ((context: Ctx<"chosen_inline_result">) => boolean)>(this: TThis, trigger: Trigger, handler: (context: Ctx<"chosen_inline_result"> & { args: RegExpMatchArray | null; queryData: Trigger extends CallbackData ? ReturnType : never; } & EventContextOf) => unknown, macroOptions?: Record): TThis; inlineQuery>(this: TThis, triggerOrHandler: RegExp | string | ((context: Ctx<"inline_query">) => boolean) | ((context: Ctx<"inline_query"> & { args: RegExpMatchArray | null; } & EventContextOf) => unknown), maybeHandler?: (context: Ctx<"inline_query"> & { args: RegExpMatchArray | null; } & EventContextOf) => unknown, options?: { onResult?: (context: Ctx<"chosen_inline_result"> & { args: RegExpMatchArray | null; } & EventContextOf) => unknown; } & Record): TThis; guestQuery>(this: TThis, triggerOrHandler: RegExp | string | ((context: Ctx<"guest_message">) => boolean) | ((context: Ctx<"guest_message"> & { args: RegExpMatchArray | null; } & EventContextOf) => unknown), maybeHandler?: (context: Ctx<"guest_message"> & { args: RegExpMatchArray | null; } & EventContextOf) => unknown, macroOptions?: Record): TThis; hears, Trigger extends CallbackData | RegExp | MaybeArray | ((context: Ctx<"message">) => boolean)>(this: TThis, trigger: Trigger, handler: (context: Ctx<"message"> & { args: RegExpMatchArray | null; /** * Payload decoded from a reply-keyboard button's hidden suffix when * `trigger` is a {@link CallbackData} (otherwise `undefined`). A reply * tap arrives as a text message; the matching label hides the packed * payload in invisible characters, recovered here type-safely. */ replyData: Trigger extends CallbackData ? ReturnType : undefined; } & EventContextOf) => unknown, macroOptions?: Record): TThis; command>(this: TThis, command: MaybeArray, handlerOrMeta: ((context: Ctx<"message"> & { args: string | null; } & EventContextOf) => unknown) | CommandMeta, handlerOrOptions?: ((context: Ctx<"message"> & { args: string | null; } & EventContextOf) => unknown) | Record, macroOptions?: Record): TThis; startParameter>(this: TThis, parameter: RegExp | MaybeArray, handler: Handler & { rawStartPayload: string; } & EventContextOf>, macroOptions?: Record): TThis; }; /** Teach EventComposer about GramIO-specific overloads */ declare module "@gramio/composer" { interface EventComposer { extend

(plugin: P): EventComposer, TMethods, TMacros & P["_"]["Macros"]>; registeredEvents(): Set; callbackQuery: (typeof methods)["callbackQuery"]; command: (typeof methods)["command"]; hears: (typeof methods)["hears"]; reaction: (typeof methods)["reaction"]; inlineQuery: (typeof methods)["inlineQuery"]; guestQuery: (typeof methods)["guestQuery"]; chosenInlineResult: (typeof methods)["chosenInlineResult"]; startParameter: (typeof methods)["startParameter"]; } } declare const Composer: _gramio_composer.EventComposerConstructor, TelegramEventMap, { reaction>(this: TThis, trigger: MaybeArray, handler: (context: Ctx<"message_reaction"> & EventContextOf) => unknown, macroOptions?: Record): TThis; callbackQuery, Trigger extends CallbackData | string | RegExp>(this: TThis, trigger: Trigger, handler: (context: Ctx<"callback_query"> & { queryData: Trigger extends CallbackData ? ReturnType : Trigger extends RegExp ? RegExpMatchArray : never; } & EventContextOf) => unknown, macroOptions?: Record): TThis; chosenInlineResult, Trigger extends CallbackData | RegExp | string | ((context: Ctx<"chosen_inline_result">) => boolean)>(this: TThis, trigger: Trigger, handler: (context: Ctx<"chosen_inline_result"> & { args: RegExpMatchArray | null; queryData: Trigger extends CallbackData ? ReturnType : never; } & EventContextOf) => unknown, macroOptions?: Record): TThis; inlineQuery>(this: TThis, triggerOrHandler: RegExp | string | ((context: Ctx<"inline_query">) => boolean) | ((context: Ctx<"inline_query"> & { args: RegExpMatchArray | null; } & EventContextOf) => unknown), maybeHandler?: (context: Ctx<"inline_query"> & { args: RegExpMatchArray | null; } & EventContextOf) => unknown, options?: { onResult?: (context: Ctx<"chosen_inline_result"> & { args: RegExpMatchArray | null; } & EventContextOf) => unknown; } & Record): TThis; guestQuery>(this: TThis, triggerOrHandler: RegExp | string | ((context: Ctx<"guest_message">) => boolean) | ((context: Ctx<"guest_message"> & { args: RegExpMatchArray | null; } & EventContextOf) => unknown), maybeHandler?: (context: Ctx<"guest_message"> & { args: RegExpMatchArray | null; } & EventContextOf) => unknown, macroOptions?: Record): TThis; hears, Trigger extends CallbackData | RegExp | MaybeArray | ((context: Ctx<"message">) => boolean)>(this: TThis, trigger: Trigger, handler: (context: Ctx<"message"> & { args: RegExpMatchArray | null; /** * Payload decoded from a reply-keyboard button's hidden suffix when * `trigger` is a {@link CallbackData} (otherwise `undefined`). A reply * tap arrives as a text message; the matching label hides the packed * payload in invisible characters, recovered here type-safely. */ replyData: Trigger extends CallbackData ? ReturnType : undefined; } & EventContextOf) => unknown, macroOptions?: Record): TThis; command>(this: TThis, command: MaybeArray, handlerOrMeta: ((context: Ctx<"message"> & { args: string | null; } & EventContextOf) => unknown) | CommandMeta, handlerOrOptions?: ((context: Ctx<"message"> & { args: string | null; } & EventContextOf) => unknown) | Record, macroOptions?: Record): TThis; startParameter>(this: TThis, parameter: RegExp | MaybeArray, handler: Handler & { rawStartPayload: string; } & EventContextOf>, macroOptions?: Record): TThis; }>; /** * Yields the subset of UpdateName whose context type contains all keys from Narrowing. */ type CompatibleUpdates$1 = { [K in UpdateName]: keyof Narrowing & string extends keyof ContextType ? K : never; }[UpdateName]; /** * `Plugin` is an object from which you can extends in Bot instance and adopt types * * @example * ```ts * import { Plugin, Bot } from "gramio"; * * export class PluginError extends Error { * wow: "type" | "safe" = "type"; * } * * const plugin = new Plugin("gramio-example") * .error("PLUGIN", PluginError) * .derive(() => { * return { * some: ["derived", "props"] as const, * }; * }); * * const bot = new Bot(process.env.TOKEN!) * .extend(plugin) * .onError(({ context, kind, error }) => { * if (context.is("message") && kind === "PLUGIN") { * console.log(error.wow); * } * }) * .use((context) => { * console.log(context.some); * }); * ``` */ declare class Plugin { /** * @internal * Set of Plugin data * * */ _: { /** Name of plugin */ name: string; /** List of plugin dependencies. If user does't extend from listed there dependencies it throw a error */ dependencies: string[]; /** remap generic type. {} in runtime */ Errors: Errors; /** remap generic type. {} in runtime */ Derives: Derives; /** remap generic type. {} in runtime */ Macros: Macros; /** Composer */ composer: EventComposer, { callback_query: _gramio_contexts.CallbackQueryContext; chat_join_request: _gramio_contexts.ChatJoinRequestContext; chat_member: _gramio_contexts.ChatMemberContext; my_chat_member: _gramio_contexts.ChatMemberContext; chosen_inline_result: _gramio_contexts.ChosenInlineResultContext; delete_chat_photo: _gramio_contexts.DeleteChatPhotoContext; group_chat_created: _gramio_contexts.GroupChatCreatedContext; inline_query: _gramio_contexts.InlineQueryContext; invoice: _gramio_contexts.InvoiceContext; left_chat_member: _gramio_contexts.LeftChatMemberContext; location: _gramio_contexts.LocationContext; managed_bot: _gramio_contexts.ManagedBotContext; managed_bot_created: _gramio_contexts.ManagedBotCreatedContext; community_chat_added: _gramio_contexts.CommunityChatAddedContext; community_chat_joined: _gramio_contexts.CommunityChatJoinedContext; community_chat_removed: _gramio_contexts.CommunityChatRemovedContext; stopped_message_generation: _gramio_contexts.MessageGenerationStoppedContext; message_auto_delete_timer_changed: _gramio_contexts.MessageAutoDeleteTimerChangedContext; message: _gramio_contexts.MessageContext & _gramio_contexts.Require<_gramio_contexts.MessageContext, "from">; channel_post: _gramio_contexts.MessageContext; edited_message: _gramio_contexts.MessageContext & _gramio_contexts.Require<_gramio_contexts.MessageContext, "from">; edited_channel_post: _gramio_contexts.MessageContext & _gramio_contexts.Require<_gramio_contexts.MessageContext, "from">; business_message: _gramio_contexts.MessageContext & _gramio_contexts.Require<_gramio_contexts.MessageContext, "from">; edited_business_message: _gramio_contexts.MessageContext & _gramio_contexts.Require<_gramio_contexts.MessageContext, "from">; guest_message: _gramio_contexts.MessageContext & _gramio_contexts.Require<_gramio_contexts.MessageContext, "from">; deleted_business_messages: _gramio_contexts.BusinessMessagesDeletedContext; business_connection: _gramio_contexts.BusinessConnectionContext; migrate_from_chat_id: _gramio_contexts.MigrateFromChatIdContext; migrate_to_chat_id: _gramio_contexts.MigrateToChatIdContext; new_chat_members: _gramio_contexts.NewChatMembersContext; new_chat_photo: _gramio_contexts.NewChatPhotoContext; new_chat_title: _gramio_contexts.NewChatTitleContext; passport_data: _gramio_contexts.PassportDataContext; pinned_message: _gramio_contexts.PinnedMessageContext; poll_answer: _gramio_contexts.PollAnswerContext; poll_option_added: _gramio_contexts.PollOptionAddedContext; poll_option_deleted: _gramio_contexts.PollOptionDeletedContext; poll: _gramio_contexts.PollContext; pre_checkout_query: _gramio_contexts.PreCheckoutQueryContext; proximity_alert_triggered: _gramio_contexts.ProximityAlertTriggeredContext; write_access_allowed: _gramio_contexts.WriteAccessAllowedContext; boost_added: _gramio_contexts.BoostAddedContext; chat_background_set: _gramio_contexts.ChatBackgroundSetContext; checklist_tasks_done: _gramio_contexts.ChecklistTasksDoneContext; checklist_tasks_added: _gramio_contexts.ChecklistTasksAddedContext; direct_message_price_changed: _gramio_contexts.DirectMessagePriceChangedContext; suggested_post_approved: _gramio_contexts.SuggestedPostApprovedContext; suggested_post_approval_failed: _gramio_contexts.SuggestedPostApprovalFailedContext; suggested_post_declined: _gramio_contexts.SuggestedPostDeclinedContext; suggested_post_paid: _gramio_contexts.SuggestedPostPaidContext; suggested_post_refunded: _gramio_contexts.SuggestedPostRefundedContext; forum_topic_created: _gramio_contexts.ForumTopicCreatedContext; forum_topic_edited: _gramio_contexts.ForumTopicEditedContext; forum_topic_closed: _gramio_contexts.ForumTopicClosedContext; forum_topic_reopened: _gramio_contexts.ForumTopicReopenedContext; general_forum_topic_hidden: _gramio_contexts.GeneralForumTopicHiddenContext; general_forum_topic_unhidden: _gramio_contexts.GeneralForumTopicUnhiddenContext; shipping_query: _gramio_contexts.ShippingQueryContext; subscription: _gramio_contexts.SubscriptionContext; successful_payment: _gramio_contexts.SuccessfulPaymentContext; refunded_payment: _gramio_contexts.RefundedPaymentContext; users_shared: _gramio_contexts.UsersSharedContext; chat_shared: _gramio_contexts.ChatSharedContext; gift: _gramio_contexts.GiftContext; gift_upgrade_sent: _gramio_contexts.GiftUpgradeSentContext; unique_gift: _gramio_contexts.UniqueGiftContext; chat_owner_left: _gramio_contexts.ChatOwnerLeftContext; chat_owner_changed: _gramio_contexts.ChatOwnerChangedContext; paid_message_price_changed: _gramio_contexts.PaidMessagePriceChangedContext; video_chat_ended: _gramio_contexts.VideoChatEndedContext; video_chat_participants_invited: _gramio_contexts.VideoChatParticipantsInvitedContext; video_chat_scheduled: _gramio_contexts.VideoChatScheduledContext; video_chat_started: _gramio_contexts.VideoChatStartedContext; web_app_data: _gramio_contexts.WebAppDataContext; service_message: _gramio_contexts.MessageContext; message_reaction: _gramio_contexts.MessageReactionContext; message_reaction_count: _gramio_contexts.MessageReactionCountContext; chat_boost: _gramio_contexts.ChatBoostContext; removed_chat_boost: _gramio_contexts.RemovedChatBoostContext; giveaway_created: _gramio_contexts.GiveawayCreatedContext; giveaway_completed: _gramio_contexts.GiveawayCompletedContext; giveaway_winners: _gramio_contexts.GiveawayWinnersContext; purchased_paid_media: _gramio_contexts.PaidMediaPurchasedContext; }, Context, Context, {}, {}, { reaction & { "~": { macros: MacroDefinitions; commandsMeta?: Map; Derives?: Record; }; chosenInlineResult(trigger: any, handler: any, macroOptions?: any): TThis; }>(this: TThis, trigger: MaybeArray<_gramio_types.TelegramReactionTypeEmojiEmoji>, handler: (context: _gramio_contexts.MessageReactionContext & _gramio_composer.EventContextOf) => unknown, macroOptions?: Record): TThis; callbackQuery & { "~": { macros: MacroDefinitions; commandsMeta?: Map; Derives?: Record; }; chosenInlineResult(trigger: any, handler: any, macroOptions?: any): TThis; }, Trigger extends _gramio_callback_data.CallbackData | string | RegExp>(this: TThis, trigger: Trigger, handler: (context: _gramio_contexts.CallbackQueryContext & { queryData: Trigger extends _gramio_callback_data.CallbackData ? ReturnType : Trigger extends RegExp ? RegExpMatchArray : never; } & _gramio_composer.EventContextOf) => unknown, macroOptions?: Record): TThis; chosenInlineResult & { "~": { macros: MacroDefinitions; commandsMeta?: Map; Derives?: Record; }; chosenInlineResult(trigger: any, handler: any, macroOptions?: any): TThis; }, Trigger extends _gramio_callback_data.CallbackData | RegExp | string | ((context: _gramio_contexts.ChosenInlineResultContext) => boolean)>(this: TThis, trigger: Trigger, handler: (context: _gramio_contexts.ChosenInlineResultContext & { args: RegExpMatchArray | null; queryData: Trigger extends _gramio_callback_data.CallbackData ? ReturnType : never; } & _gramio_composer.EventContextOf) => unknown, macroOptions?: Record): TThis; inlineQuery & { "~": { macros: MacroDefinitions; commandsMeta?: Map; Derives?: Record; }; chosenInlineResult(trigger: any, handler: any, macroOptions?: any): TThis; }>(this: TThis, triggerOrHandler: RegExp | string | ((context: _gramio_contexts.InlineQueryContext) => boolean) | ((context: _gramio_contexts.InlineQueryContext & { args: RegExpMatchArray | null; } & _gramio_composer.EventContextOf) => unknown), maybeHandler?: (context: _gramio_contexts.InlineQueryContext & { args: RegExpMatchArray | null; } & _gramio_composer.EventContextOf) => unknown, options?: { onResult?: (context: _gramio_contexts.ChosenInlineResultContext & { args: RegExpMatchArray | null; } & _gramio_composer.EventContextOf) => unknown; } & Record): TThis; guestQuery & { "~": { macros: MacroDefinitions; commandsMeta?: Map; Derives?: Record; }; chosenInlineResult(trigger: any, handler: any, macroOptions?: any): TThis; }>(this: TThis, triggerOrHandler: RegExp | string | ((context: _gramio_contexts.MessageContext & _gramio_contexts.Require<_gramio_contexts.MessageContext, "from">) => boolean) | ((context: (_gramio_contexts.MessageContext & _gramio_contexts.Require<_gramio_contexts.MessageContext, "from">) & { args: RegExpMatchArray | null; } & _gramio_composer.EventContextOf) => unknown), maybeHandler?: (context: (_gramio_contexts.MessageContext & _gramio_contexts.Require<_gramio_contexts.MessageContext, "from">) & { args: RegExpMatchArray | null; } & _gramio_composer.EventContextOf) => unknown, macroOptions?: Record): TThis; hears & { "~": { macros: MacroDefinitions; commandsMeta?: Map; Derives?: Record; }; chosenInlineResult(trigger: any, handler: any, macroOptions?: any): TThis; }, Trigger extends _gramio_callback_data.CallbackData | RegExp | MaybeArray | ((context: _gramio_contexts.MessageContext & _gramio_contexts.Require<_gramio_contexts.MessageContext, "from">) => boolean)>(this: TThis, trigger: Trigger, handler: (context: (_gramio_contexts.MessageContext & _gramio_contexts.Require<_gramio_contexts.MessageContext, "from">) & { args: RegExpMatchArray | null; replyData: Trigger extends _gramio_callback_data.CallbackData ? ReturnType : undefined; } & _gramio_composer.EventContextOf) => unknown, macroOptions?: Record): TThis; command & { "~": { macros: MacroDefinitions; commandsMeta?: Map; Derives?: Record; }; chosenInlineResult(trigger: any, handler: any, macroOptions?: any): TThis; }>(this: TThis, command: MaybeArray, handlerOrMeta: ((context: (_gramio_contexts.MessageContext & _gramio_contexts.Require<_gramio_contexts.MessageContext, "from">) & { args: string | null; } & _gramio_composer.EventContextOf) => unknown) | CommandMeta, handlerOrOptions?: ((context: (_gramio_contexts.MessageContext & _gramio_contexts.Require<_gramio_contexts.MessageContext, "from">) & { args: string | null; } & _gramio_composer.EventContextOf) => unknown) | Record, macroOptions?: Record): TThis; startParameter & { "~": { macros: MacroDefinitions; commandsMeta?: Map; Derives?: Record; }; chosenInlineResult(trigger: any, handler: any, macroOptions?: any): TThis; }>(this: TThis, parameter: RegExp | MaybeArray, handler: Handler<(_gramio_contexts.MessageContext & _gramio_contexts.Require<_gramio_contexts.MessageContext, "from">) & { rawStartPayload: string; } & _gramio_composer.EventContextOf>, macroOptions?: Record): TThis; }, {}> & { reaction & { "~": { macros: MacroDefinitions; commandsMeta?: Map; Derives?: Record; }; chosenInlineResult(trigger: any, handler: any, macroOptions?: any): TThis; }>(this: TThis, trigger: MaybeArray<_gramio_types.TelegramReactionTypeEmojiEmoji>, handler: (context: _gramio_contexts.MessageReactionContext & _gramio_composer.EventContextOf) => unknown, macroOptions?: Record): TThis; callbackQuery & { "~": { macros: MacroDefinitions; commandsMeta?: Map; Derives?: Record; }; chosenInlineResult(trigger: any, handler: any, macroOptions?: any): TThis; }, Trigger extends _gramio_callback_data.CallbackData | string | RegExp>(this: TThis, trigger: Trigger, handler: (context: _gramio_contexts.CallbackQueryContext & { queryData: Trigger extends _gramio_callback_data.CallbackData ? ReturnType : Trigger extends RegExp ? RegExpMatchArray : never; } & _gramio_composer.EventContextOf) => unknown, macroOptions?: Record): TThis; chosenInlineResult & { "~": { macros: MacroDefinitions; commandsMeta?: Map; Derives?: Record; }; chosenInlineResult(trigger: any, handler: any, macroOptions?: any): TThis; }, Trigger extends _gramio_callback_data.CallbackData | RegExp | string | ((context: _gramio_contexts.ChosenInlineResultContext) => boolean)>(this: TThis, trigger: Trigger, handler: (context: _gramio_contexts.ChosenInlineResultContext & { args: RegExpMatchArray | null; queryData: Trigger extends _gramio_callback_data.CallbackData ? ReturnType : never; } & _gramio_composer.EventContextOf) => unknown, macroOptions?: Record): TThis; inlineQuery & { "~": { macros: MacroDefinitions; commandsMeta?: Map; Derives?: Record; }; chosenInlineResult(trigger: any, handler: any, macroOptions?: any): TThis; }>(this: TThis, triggerOrHandler: RegExp | string | ((context: _gramio_contexts.InlineQueryContext) => boolean) | ((context: _gramio_contexts.InlineQueryContext & { args: RegExpMatchArray | null; } & _gramio_composer.EventContextOf) => unknown), maybeHandler?: (context: _gramio_contexts.InlineQueryContext & { args: RegExpMatchArray | null; } & _gramio_composer.EventContextOf) => unknown, options?: { onResult?: (context: _gramio_contexts.ChosenInlineResultContext & { args: RegExpMatchArray | null; } & _gramio_composer.EventContextOf) => unknown; } & Record): TThis; guestQuery & { "~": { macros: MacroDefinitions; commandsMeta?: Map; Derives?: Record; }; chosenInlineResult(trigger: any, handler: any, macroOptions?: any): TThis; }>(this: TThis, triggerOrHandler: RegExp | string | ((context: _gramio_contexts.MessageContext & _gramio_contexts.Require<_gramio_contexts.MessageContext, "from">) => boolean) | ((context: (_gramio_contexts.MessageContext & _gramio_contexts.Require<_gramio_contexts.MessageContext, "from">) & { args: RegExpMatchArray | null; } & _gramio_composer.EventContextOf) => unknown), maybeHandler?: (context: (_gramio_contexts.MessageContext & _gramio_contexts.Require<_gramio_contexts.MessageContext, "from">) & { args: RegExpMatchArray | null; } & _gramio_composer.EventContextOf) => unknown, macroOptions?: Record): TThis; hears & { "~": { macros: MacroDefinitions; commandsMeta?: Map; Derives?: Record; }; chosenInlineResult(trigger: any, handler: any, macroOptions?: any): TThis; }, Trigger extends _gramio_callback_data.CallbackData | RegExp | MaybeArray | ((context: _gramio_contexts.MessageContext & _gramio_contexts.Require<_gramio_contexts.MessageContext, "from">) => boolean)>(this: TThis, trigger: Trigger, handler: (context: (_gramio_contexts.MessageContext & _gramio_contexts.Require<_gramio_contexts.MessageContext, "from">) & { args: RegExpMatchArray | null; replyData: Trigger extends _gramio_callback_data.CallbackData ? ReturnType : undefined; } & _gramio_composer.EventContextOf) => unknown, macroOptions?: Record): TThis; command & { "~": { macros: MacroDefinitions; commandsMeta?: Map; Derives?: Record; }; chosenInlineResult(trigger: any, handler: any, macroOptions?: any): TThis; }>(this: TThis, command: MaybeArray, handlerOrMeta: ((context: (_gramio_contexts.MessageContext & _gramio_contexts.Require<_gramio_contexts.MessageContext, "from">) & { args: string | null; } & _gramio_composer.EventContextOf) => unknown) | CommandMeta, handlerOrOptions?: ((context: (_gramio_contexts.MessageContext & _gramio_contexts.Require<_gramio_contexts.MessageContext, "from">) & { args: string | null; } & _gramio_composer.EventContextOf) => unknown) | Record, macroOptions?: Record): TThis; startParameter & { "~": { macros: MacroDefinitions; commandsMeta?: Map; Derives?: Record; }; chosenInlineResult(trigger: any, handler: any, macroOptions?: any): TThis; }>(this: TThis, parameter: RegExp | MaybeArray, handler: Handler<(_gramio_contexts.MessageContext & _gramio_contexts.Require<_gramio_contexts.MessageContext, "from">) & { rawStartPayload: string; } & _gramio_composer.EventContextOf>, macroOptions?: Record): TThis; }; /** Store plugin preRequests hooks */ preRequests: [Hooks.PreRequest, MaybeArray | undefined][]; /** Store plugin onResponses hooks */ onResponses: [Hooks.OnResponse, MaybeArray | undefined][]; /** Store plugin onResponseErrors hooks */ onResponseErrors: [Hooks.OnResponseError, MaybeArray | undefined][]; /** Store plugin onApiCalls hooks */ onApiCalls: [Hooks.OnApiCall, MaybeArray | undefined][]; /** * Store plugin groups * * If you use `on` or `use` in group and on plugin-level groups handlers are registered after plugin-level handlers * */ groups: ((bot: AnyBot) => AnyBot)[]; /** Store plugin onStarts hooks */ onStarts: Hooks.OnStart[]; /** Store plugin onStops hooks */ onStops: Hooks.OnStop[]; /** Store plugin onErrors hooks */ onErrors: Hooks.OnError[]; /** Map of plugin errors */ errorsDefinitions: Record; decorators: Record; }; /** Expose composer internals so `composer.extend(plugin)` works via duck-typing */ get "~"(): Omit["~"], "Out" | "Derives"> & { Out: Derives["global"]; Derives: Omit; }; /** Create new Plugin. Please provide `name` */ constructor(name: string, { dependencies }?: { dependencies?: string[]; }); /** Currently not isolated!!! * * > [!WARNING] * > If you use `on` or `use` in a `group` and at the plugin level, the group handlers are registered **after** the handlers at the plugin level */ group(grouped: (bot: Bot) => AnyBot): this; /** * Register custom class-error in plugin **/ error(kind: Name, error: NewError): Plugin; }, Derives, Macros>; /** * Derive some data to handlers * * @example * ```ts * new Bot("token").derive((context) => { * return { * superSend: () => context.send("Derived method") * } * }) * ``` */ derive & Derives["global"]>>(handler: Handler): Plugin>; }, Macros>; derive & Derives["global"] & Derives[Update]>>(updateName: MaybeArray, handler: Handler): Plugin>; }, Macros>; decorate>(value: Value): Plugin; decorate(name: Name, value: Value): Plugin; /** * Register a single named macro definition on this plugin */ macro>(name: Name, definition: TDef): Plugin>; /** Register multiple macro definitions at once */ macro>>(definitions: TDefs): Plugin; /** Register handler with a type-narrowing filter (auto-discovers matching events) */ on(filter: (ctx: any) => ctx is Narrowing, handler: Handler> & Derives["global"] & Narrowing>): this; /** Register handler with a boolean filter (all updates) */ on(filter: (ctx: Context & Derives["global"]) => boolean, handler: Handler & Derives["global"]>): this; /** Register handler to one or many Updates with a type-narrowing filter */ on(updateName: MaybeArray, filter: (ctx: any) => ctx is Narrowing, handler: Handler & Derives["global"] & Derives[T] & Narrowing>): this; /** Register handler to one or many Updates with a boolean filter (no type narrowing) */ on(updateName: MaybeArray, filter: (ctx: ContextType & Derives["global"] & Derives[T]) => boolean, handler: Handler & Derives["global"] & Derives[T]>): this; /** Register handler to one or many Updates */ on(updateName: MaybeArray, handler: Handler & Derives["global"] & Derives[T]>): this; /** Register handler to any Updates */ use(handler: Handler & Derives["global"]>): this; /** * This hook called before sending a request to Telegram Bot API (allows us to impact the sent parameters). * * @example * ```typescript * import { Bot } from "gramio"; * * const bot = new Bot(process.env.TOKEN!).preRequest((context) => { * if (context.method === "sendMessage") { * context.params.text = "mutate params"; * } * * return context; * }); * * bot.start(); * ``` * * [Documentation](https://gramio.dev/hooks/pre-request.html) * */ preRequest>(methods: MaybeArray, handler: Handler): this; preRequest(handler: Hooks.PreRequest): this; /** * This hook called when API return successful response * * [Documentation](https://gramio.dev/hooks/on-response.html) * */ onResponse>(methods: MaybeArray, handler: Handler): this; onResponse(handler: Hooks.OnResponse): this; /** * This hook called when API return an error * * [Documentation](https://gramio.dev/hooks/on-response-error.html) * */ onResponseError>(methods: MaybeArray, handler: Handler): this; onResponseError(handler: Hooks.OnResponseError): this; /** * This hook wraps the entire API call, enabling tracing/instrumentation. * * @example * ```typescript * const plugin = new Plugin("example").onApiCall(async (context, next) => { * console.log(`Calling ${context.method}`); * const result = await next(); * console.log(`${context.method} completed`); * return result; * }); * ``` * */ onApiCall>(methods: MaybeArray, handler: Handler): this; onApiCall(handler: Hooks.OnApiCall): this; /** * This hook called when the bot is `started`. * * @example * ```typescript * import { Bot } from "gramio"; * * const bot = new Bot(process.env.TOKEN!).onStart( * ({ plugins, info, updatesFrom, bot }) => { * console.log(`plugin list - ${plugins.join(", ")}`); * console.log(`bot username is @${info.username}`); * console.log(`updates from ${updatesFrom}`); * } * ); * * bot.start(); * ``` * * [Documentation](https://gramio.dev/hooks/on-start.html) * */ onStart(handler: Hooks.OnStart): this; /** * This hook called when the bot stops. * * @example * ```typescript * import { Bot } from "gramio"; * * const bot = new Bot(process.env.TOKEN!).onStop( * ({ plugins, info, bot }) => { * console.log(`plugin list - ${plugins.join(", ")}`); * console.log(`bot username is @${info.username}`); * } * ); * * bot.start(); * bot.stop(); * ``` * * [Documentation](https://gramio.dev/hooks/on-stop.html) * */ onStop(handler: Hooks.OnStop): this; /** * Set error handler. * @example * ```ts * bot.onError("message", ({ context, kind, error }) => { * return context.send(`${kind}: ${error.message}`); * }) * ``` */ onError(updateName: MaybeArray, handler: Hooks.OnError & Derives["global"] & Derives[T]>): this; onError(handler: Hooks.OnError & Derives["global"]>): this; /** Extend plugin with a Composer instance (merges middleware with deduplication) */ extend>(composer: EventComposer): Plugin; /** Extend plugin with another Plugin (merges middleware, hooks, decorators, error definitions, groups, and dependencies) */ extend(plugin: MaybePromise): Plugin; } interface Plugin { /** Register callback query handler */ callbackQuery: (typeof methods)["callbackQuery"]; /** Register command handler */ command: (typeof methods)["command"]; /** Register text/caption pattern handler */ hears: (typeof methods)["hears"]; /** Register reaction handler */ reaction: (typeof methods)["reaction"]; /** Register inline query handler */ inlineQuery: (typeof methods)["inlineQuery"]; /** Register guest query (`guest_message`) handler */ guestQuery: (typeof methods)["guestQuery"]; /** Register chosen inline result handler */ chosenInlineResult: (typeof methods)["chosenInlineResult"]; /** Register deep-link parameter handler */ startParameter: (typeof methods)["startParameter"]; } /** Bot options that you can provide to {@link Bot} constructor */ interface BotOptions { /** Bot token */ token: string; /** When the bot begins to listen for updates, `GramIO` retrieves information about the bot to verify if the **bot token is valid** * and to utilize some bot metadata. For example, this metadata will be used to strip bot mentions in commands. * * If you set it up, `GramIO` will not send a `getMe` request on startup. * * @important * **You should set this up when horizontally scaling your bot or working in serverless environments.** * */ info?: TelegramUser; /** List of plugins enabled by default */ plugins?: { /** Pass `false` to disable plugin. @default true */ format?: boolean; }; /** Options to configure how to send requests to the Telegram Bot API */ api: { /** Configure {@link fetch} parameters */ fetchOptions?: Parameters[1]; /** URL which will be used to send requests to. @default "https://api.telegram.org/bot" */ baseURL: string; /** * Should we send requests to `test` data center? * The test environment is completely separate from the main environment, so you will need to create a new user account and a new bot with `@BotFather`. * * [Documentation](https://core.telegram.org/bots/webapps#using-bots-in-the-test-environment) * @default false * */ useTest?: boolean; /** * Time in milliseconds before calling {@link APIMethods.getUpdates | getUpdates} again * @default 1000 */ retryGetUpdatesWait?: number; }; /** * File download/serving options — mainly for a **local Bot API server**. * * @example * ```ts * const bot = new Bot(token, { * api: { baseURL: "http://telegram-bot-api:8081/bot" }, * files: { * // bot.getFileLink() and ctx.download() resolve to this (token-less) URL * baseURL: "http://telegram-bot-api:8080", * }, * }); * ``` */ files?: { /** How to fetch file bytes. @default "auto" */ source?: FileSource; /** Working directory of the local Bot API server — the prefix of the absolute `file_path` it returns. @default "/var/lib/telegram-bot-api" */ localDir?: string; /** Where that working dir is mounted on the bot's side (for `source: "disk"` when bot & server share a volume at a different path). Defaults to `localDir`. */ mountDir?: string; /** Public base URL where the working dir is served (e.g. the bundled file server / nginx). Enables token-less {@link Bot.getFileLink} and `source: "rewrite"`. */ baseURL?: string; }; } /** * Handler is a function with context and next function arguments * * @example * ```ts * const handler: Handler> = (context, _next) => context.send("HI!"); * * bot.on("message", handler) * ``` */ type Handler = (context: T, next: Next) => unknown; interface ErrorHandlerParams, Kind extends string, Err> { context: Ctx; kind: Kind; error: Err; } type AnyTelegramError = { [APIMethod in Methods]: TelegramError; }[Methods]; type AnyTelegramMethod = { [APIMethod in Methods]: { method: APIMethod; params: MaybeSuppressedParams; }; }[Methods]; /** * Interface for add `suppress` param to params */ interface Suppress { /** * Pass `true` if you want to suppress throwing errors of this method. * * **But this does not undo getting into the `onResponseError` hook**. * * @example * ```ts * const response = await bot.api.sendMessage({ * suppress: true, * chat_id: "@not_found", * text: "Suppressed method" * }); * * if(response instanceof TelegramError) console.error("sendMessage returns an error...") * else console.log("Message has been sent successfully"); * ``` * * */ suppress?: IsSuppressed; } /** Type that assign API params with {@link Suppress} */ type MaybeSuppressedParams = APIMethodParams & Suppress; /** Return method params but with {@link Suppress} */ type SuppressedAPIMethodParams = undefined extends APIMethodParams ? Suppress : MaybeSuppressedParams; /** Type that return MaybeSuppressed API method ReturnType */ type MaybeSuppressedReturn = true extends IsSuppressed ? TelegramError | APIMethodReturn : APIMethodReturn; /** Type that return {@link Suppress | Suppressed} API method ReturnType */ type SuppressedAPIMethodReturn = MaybeSuppressedReturn; /** Map of APIMethods but with {@link Suppress} */ type SuppressedAPIMethods = { [APIMethod in Methods]: APIMethodParams extends undefined ? (params?: Suppress) => Promise> : undefined extends APIMethodParams ? (params?: MaybeSuppressedParams) => Promise> : (params: MaybeSuppressedParams) => Promise>; }; type AnyTelegramMethodWithReturn = { [APIMethod in Methods]: { method: APIMethod; params: APIMethodParams; response: APIMethodReturn; }; }[Methods]; /** Type for maybe {@link Promise} or may not */ type MaybePromise = Promise | T; /** * Namespace with GramIO hooks types * * [Documentation](https://gramio.dev/hooks/overview.html) * */ declare namespace Hooks { /** Derive */ type Derive = (context: Ctx) => MaybePromise>; /** Argument type for {@link PreRequest} */ type PreRequestContext = AnyTelegramMethod; /** * Type for `preRequest` hook * * @example * ```typescript * import { Bot } from "gramio"; * * const bot = new Bot(process.env.TOKEN!).preRequest((context) => { * if (context.method === "sendMessage") { * context.params.text = "mutate params"; * } * * return context; * }); * * bot.start(); * ``` * * [Documentation](https://gramio.dev/hooks/pre-request.html) * */ type PreRequest = (ctx: PreRequestContext) => MaybePromise>; /** Argument type for {@link OnError} */ type OnErrorContext, T extends ErrorDefinitions> = ErrorHandlerParams | ErrorHandlerParams | { [K in keyof T]: ErrorHandlerParams; }[keyof T]; /** * Type for `onError` hook * * @example * ```typescript * bot.on("message", () => { * bot.api.sendMessage({ * chat_id: "@not_found", * text: "Chat not exists....", * }); * }); * * bot.onError(({ context, kind, error }) => { * if (context.is("message")) return context.send(`${kind}: ${error.message}`); * }); * ``` * * [Documentation](https://gramio.dev/hooks/on-error.html) * */ type OnError = Context> = (options: OnErrorContext) => unknown; /** * Type for `onStart` hook * * @example * ```typescript * import { Bot } from "gramio"; * * const bot = new Bot(process.env.TOKEN!).onStart( * ({ plugins, info, updatesFrom, bot }) => { * console.log(`plugin list - ${plugins.join(", ")}`); * console.log(`bot username is @${info.username}`); * console.log(`updates from ${updatesFrom}`); * } * ); * * bot.start(); * ``` * * [Documentation](https://gramio.dev/hooks/on-start.html) * */ type OnStart = (context: { plugins: string[]; info: TelegramUser; updatesFrom: "webhook" | "long-polling"; bot: BotLike; }) => unknown; /** * Type for `onStop` hook * * @example * ```typescript * import { Bot } from "gramio"; * * const bot = new Bot(process.env.TOKEN!).onStop( * ({ plugins, info, bot }) => { * console.log(`plugin list - ${plugins.join(", ")}`); * console.log(`bot username is @${info.username}`); * } * ); * * bot.start(); * bot.stop(); * ``` * * [Documentation](https://gramio.dev/hooks/on-stop.html) * */ type OnStop = (context: { plugins: string[]; info: TelegramUser; bot: BotLike; }) => unknown; /** * Type for `onResponseError` hook * * [Documentation](https://gramio.dev/hooks/on-response-error.html) * */ type OnResponseError = (context: AnyTelegramError, api: Bot["api"]) => unknown; /** * Type for `onResponse` hook * * [Documentation](https://gramio.dev/hooks/on-response.html) * */ type OnResponse = (context: AnyTelegramMethodWithReturn) => unknown; /** Argument type for {@link OnApiCall} */ type OnApiCallContext = AnyTelegramMethod; /** * Type for `onApiCall` hook (wrap-style) * * This hook wraps the entire API call execution, enabling span creation * around API calls for tracing/instrumentation. * * @example * ```typescript * import { Bot } from "gramio"; * * const bot = new Bot(process.env.TOKEN!).onApiCall(async (context, next) => { * console.log(`Calling ${context.method}`); * const result = await next(); * console.log(`${context.method} completed`); * return result; * }); * ``` * */ type OnApiCall = (context: OnApiCallContext, next: () => Promise) => Promise; /** Store hooks */ interface Store { preRequest: PreRequest[]; onResponse: OnResponse[]; onResponseError: OnResponseError[]; onError: OnError[]; onStart: OnStart[]; onStop: OnStop[]; onApiCall: OnApiCall[]; } } /** Error map should be map of string: error */ type ErrorDefinitions = Record; /** Map of derives */ type DeriveDefinitions = Record; /** Type of Bot that accepts any generics */ type AnyBot = Bot; /** Type of Bot that accepts any generics */ type AnyPlugin = Plugin; type CallbackQueryShorthandContext = Omit, "data"> & BotType["__Derives"]["global"] & BotType["__Derives"]["callback_query"] & { queryData: Trigger extends CallbackData ? ReturnType : Trigger extends RegExp ? RegExpMatchArray : never; }; type BotStartOptionsLongPolling = Omit>, "allowed_updates" | "offset">; type BotStartOptionsWebhook = true | string | Omit; type AllowedUpdates = Exclude>["allowed_updates"], "update_id">; interface BotStartOptions { webhook?: BotStartOptionsWebhook; longPolling?: BotStartOptionsLongPolling; dropPendingUpdates?: boolean; /** * Which update types to receive from Telegram. * * - **`undefined`** (default) — Telegram's default set, plus automatic opt-in * for `chat_member`, `message_reaction`, and `message_reaction_count` if * the bot has handlers registered for them. * - **`"strict"`** — only receive update types that handlers explicitly * register for via `.on()`. Equivalent to `AllowedUpdatesFilter.from(bot)`. * Filter-only `.on()` and `.use()` are not included. * - **`AllowedUpdatesFilter` / array** — explicit list of update types. * * @example * ```typescript * // Auto opt-in (default): Telegram default + auto chat_member/reaction if needed * bot.start(); * * // Strict: only registered events * bot.start({ allowedUpdates: "strict" }); * * // Manual * bot.start({ allowedUpdates: AllowedUpdatesFilter.all }); * * // Strict + customize * bot.start({ allowedUpdates: AllowedUpdatesFilter.from(bot).add("poll") }); * ``` */ allowedUpdates?: AllowedUpdates | "strict"; deleteWebhook?: boolean | "on-conflict-with-polling"; } interface PollingStartOptions { dropPendingUpdates?: boolean; deleteWebhookOnConflict?: boolean; } /** Shorthand strings for common BotCommandScope types */ type ScopeShorthand = "default" | "all_private_chats" | "all_group_chats" | "all_chat_administrators"; /** * Metadata for a bot command, used by `syncCommands()` to push * descriptions, localized names, and visibility scopes to the Telegram API. */ interface CommandMeta { /** Command description shown in the Telegram menu (1-256 chars) */ description: string; /** Localized descriptions keyed by IETF language tag */ locales?: Record; /** Where this command is visible. Default: `["default"]` */ scopes?: (TelegramBotCommandScope | ScopeShorthand)[]; /** Exclude this command from `syncCommands()`. The handler still works. @default false */ hide?: boolean; } /** Minimal key-value storage interface compatible with `@gramio/storage` */ interface SyncStorage { get(key: string): string | undefined | Promise; set(key: string, value: string): void | Promise; } /** Options for {@link Bot.syncCommands} */ interface SyncCommandsOptions { /** Storage for caching sync hashes. When provided, only changed groups trigger API calls. */ storage?: SyncStorage; /** Delete commands for scopes not declared by any command. @default false */ cleanUnusedScopes?: boolean; /** Command names to exclude from syncing (in addition to commands with `hide: true`) */ exclude?: string[]; } declare class Updates { private readonly bot; isStarted: boolean; isRequestActive: boolean; private offset; composer: InstanceType; queue: EventQueue; stopPollingPromiseResolve: ((value?: undefined) => void) | undefined; constructor(bot: AnyBot, onError: (context: Context, error: Error) => unknown); handleUpdate(data: TelegramUpdate): Promise; /** @deprecated use bot.start instead @internal */ startPolling(params?: APIMethodParams<"getUpdates">, options?: PollingStartOptions): void; startFetchLoop(params?: APIMethodParams<"getUpdates">, options?: PollingStartOptions): Promise; dropPendingUpdates(deleteWebhookOnConflict?: boolean): Promise; /** * ! Soon waitPendingRequests param default will changed to true */ stopPolling(waitPendingRequests?: boolean): Promise; } /** * Yields the subset of UpdateName whose context type contains all keys from Narrowing. * Used to give filter-only .on() handlers a rich union type instead of the bare Context base class. */ type CompatibleUpdates = { [K in UpdateName]: keyof Narrowing & string extends keyof ContextType ? K : never; }[UpdateName]; /** Bot instance * * @example * ```ts * import { Bot } from "gramio"; * * const bot = new Bot("") // put you token here * .command("start", (context) => context.send("Hi!")) * .onStart(console.log); * * bot.start(); * ``` */ declare class Bot { /** @deprecated use `~` instead*/ _: { /** @deprecated @internal. Remap generic */ derives: Derives; }; /** @deprecated use `~.derives` instead @internal. Remap generic */ __Derives: Derives; "~": { /** @deprecated @internal. Remap generic */ derives: Derives; }; /** Options provided to instance */ readonly options: BotOptions; /** Bot data (filled in when calling bot.init/bot.start) */ info: TelegramUser | undefined; /** * Send API Request to Telegram Bot API * * @example * ```ts * const response = await bot.api.sendMessage({ * chat_id: "@gramio_forum", * text: "some text", * }); * ``` * * [Documentation](https://gramio.dev/bot-api.html) */ readonly api: SuppressedAPIMethods; private lazyloadPlugins; private dependencies; private errorsDefinitions; private errorHandler; /** This instance handle updates */ updates: Updates; private hooks; constructor(token: string, options?: Omit & { api?: Partial; }); constructor(options: Omit & { api?: Partial; }); private runHooks; private runImmutableHooks; private _callApi; /** * Download file * * @example * ```ts * bot.on("message", async (context) => { * if (!context.document) return; * // download to ./file-name * await context.download(context.document.fileName || "file-name"); * // get ArrayBuffer * const buffer = await context.download(); * * return context.send("Thank you!"); * }); * ``` * [Documentation](https://gramio.dev/files/download.html) */ downloadFile(attachment: Attachment | { file_id: string; } | string): TelegramFileDownload; downloadFile(attachment: Attachment | { file_id: string; } | string, path: string): Promise; /** * Get a shareable download link for a file. * * When {@link BotOptions.files | `files.baseURL`} is set (e.g. a local Bot API * server with the bundled file server), the link is **token-less and path-based** * — safe to hand to users. Otherwise it falls back to the classic * `…/file/bot/` URL (which contains the bot token). * * @example * ```ts * const link = await bot.getFileLink(ctx.document.fileId); * await ctx.reply(`Download: ${link}`); * ``` */ getFileLink(attachment: Attachment | { file_id: string; } | string): Promise; /** * Register custom class-error for type-safe catch in `onError` hook * * @example * ```ts * export class NoRights extends Error { * needRole: "admin" | "moderator"; * * constructor(role: "admin" | "moderator") { * super(); * this.needRole = role; * } * } * * const bot = new Bot(process.env.TOKEN!) * .error("NO_RIGHTS", NoRights) * .onError(({ context, kind, error }) => { * if (context.is("message") && kind === "NO_RIGHTS") * return context.send( * format`You don't have enough rights! You need to have an «${bold( * error.needRole * )}» role.` * ); * }); * * bot.updates.on("message", (context) => { * if (context.text === "bun") throw new NoRights("admin"); * }); * ``` */ error(kind: Name, error: NewError): Bot; }, Derives, Macros>; /** * Set error handler. * @example * ```ts * bot.onError("message", ({ context, kind, error }) => { * return context.send(`${kind}: ${error.message}`); * }) * ``` */ onError(updateName: MaybeArray, handler: Hooks.OnError>): this; onError(handler: Hooks.OnError & Derives["global"]>): this; /** * Derive some data to handlers * * @example * ```ts * new Bot("token").derive((context) => { * return { * superSend: () => context.send("Derived method") * } * }) * ``` */ derive & Derives["global"]>>(handler: Handler): Bot>; }, Macros>; derive & Derives["global"] & Derives[Update]>>(updateName: MaybeArray, handler: Handler): Bot>; }, Macros>; decorate>(value: Value): Bot; decorate(name: Name, value: Value): Bot; /** * Register a single named macro definition * * @example * ```ts * import { Bot, type MacroDef } from "gramio"; * * const onlyAdmin: MacroDef = { * preHandler: (ctx, next) => { * if (ctx.from?.id !== ADMIN_ID) return; * return next(); * }, * }; * * const bot = new Bot(process.env.TOKEN!) * .macro("onlyAdmin", onlyAdmin) * .command("ban", handler, { onlyAdmin: true }); * ``` */ macro>(name: Name, definition: TDef): Bot>; /** Register multiple macro definitions at once */ macro>>(definitions: TDefs): Bot; /** * This hook called when the bot is `started`. * * @example * ```typescript * import { Bot } from "gramio"; * * const bot = new Bot(process.env.TOKEN!).onStart( * ({ plugins, info, updatesFrom, bot }) => { * console.log(`plugin list - ${plugins.join(", ")}`); * console.log(`bot username is @${info.username}`); * console.log(`updates from ${updatesFrom}`); * } * ); * * bot.start(); * ``` * * [Documentation](https://gramio.dev/hooks/on-start.html) * */ onStart(handler: Hooks.OnStart): this; /** * This hook called when the bot stops. * * @example * ```typescript * import { Bot } from "gramio"; * * const bot = new Bot(process.env.TOKEN!).onStop( * ({ plugins, info, bot }) => { * console.log(`plugin list - ${plugins.join(", ")}`); * console.log(`bot username is @${info.username}`); * } * ); * * bot.start(); * bot.stop(); * ``` * * [Documentation](https://gramio.dev/hooks/on-stop.html) * */ onStop(handler: Hooks.OnStop): this; /** * This hook called before sending a request to Telegram Bot API (allows us to impact the sent parameters). * * @example * ```typescript * import { Bot } from "gramio"; * * const bot = new Bot(process.env.TOKEN!).preRequest((context) => { * if (context.method === "sendMessage") { * context.params.text = "mutate params"; * } * * return context; * }); * * bot.start(); * ``` * * [Documentation](https://gramio.dev/hooks/pre-request.html) * */ preRequest>(methods: MaybeArray, handler: Handler): this; preRequest(handler: Hooks.PreRequest): this; /** * This hook called when API return successful response * * [Documentation](https://gramio.dev/hooks/on-response.html) * */ onResponse>(methods: MaybeArray, handler: Handler): this; onResponse(handler: Hooks.OnResponse): this; /** * This hook called when API return an error * * [Documentation](https://gramio.dev/hooks/on-response-error.html) * */ onResponseError>(methods: MaybeArray, handler: Handler): this; onResponseError(handler: Hooks.OnResponseError): this; /** * This hook wraps the entire API call, enabling tracing/instrumentation. * * @example * ```typescript * import { Bot } from "gramio"; * * const bot = new Bot(process.env.TOKEN!).onApiCall(async (context, next) => { * console.log(`Calling ${context.method}`); * const result = await next(); * console.log(`${context.method} completed`); * return result; * }); * ``` * */ onApiCall>(methods: MaybeArray, handler: Handler): this; onApiCall(handler: Hooks.OnApiCall): this; /** Register handler with a type-narrowing filter (auto-discovers matching events) */ on(filter: (ctx: any) => ctx is Narrowing, handler: Handler> & Derives["global"] & Narrowing>): this; /** Register handler with a boolean filter (all updates) */ on(filter: (ctx: Context & Derives["global"]) => boolean, handler: Handler & Derives["global"]>): this; /** Register handler to one or many Updates with a type-narrowing filter */ on(updateName: MaybeArray, filter: (ctx: any) => ctx is Narrowing, handler: Handler & Narrowing>): this; /** Register handler to one or many Updates with a boolean filter (no type narrowing) */ on(updateName: MaybeArray, filter: (ctx: ContextType) => boolean, handler: Handler>): this; /** Register handler to one or many Updates */ on(updateName: MaybeArray, handler: Handler>): this; /** Register handler to any Updates */ use(handler: Handler & Derives["global"]>): this; /** * Extend {@link Plugin} logic and types * * @example * ```ts * import { Plugin, Bot } from "gramio"; * * export class PluginError extends Error { * wow: "type" | "safe" = "type"; * } * * const plugin = new Plugin("gramio-example") * .error("PLUGIN", PluginError) * .derive(() => { * return { * some: ["derived", "props"] as const, * }; * }); * * const bot = new Bot(process.env.TOKEN!) * .extend(plugin) * .onError(({ context, kind, error }) => { * if (context.is("message") && kind === "PLUGIN") { * console.log(error.wow); * } * }) * .use((context) => { * console.log(context.some); * }); * ``` */ extend>(composer: EventComposer): Bot; extend(plugin: MaybePromise): Bot; /** * Register handler to reaction (`message_reaction` update) * * @example * ```ts * new Bot().reaction("👍", async (context) => { * await context.reply(`Thank you!`); * }); * ``` * */ reaction, Macros> = {}>(trigger: MaybeArray, handler: (context: ContextType & DeriveFromOptions) => unknown, options?: TOptions): this; /** * Register handler to `callback_query` event * * @example * ```ts * const someData = new CallbackData("example").number("id"); * * new Bot() * .command("start", (context) => * context.send("some", { * reply_markup: new InlineKeyboard().text( * "example", * someData.pack({ * id: 1, * }) * ), * }) * ) * .callbackQuery(someData, (context) => { * context.queryData; // is type-safe * }); * ``` */ callbackQuery, Macros> = {}>(trigger: Trigger, handler: (context: CallbackQueryShorthandContext & DeriveFromOptions) => unknown, options?: TOptions): this; /** * Register handler to `chosen_inline_result` update * * Accepts a `CallbackData` schema for type-safe filtering on `result_id`: * * @example * ```ts * const trackRef = new CallbackData("track").string("src").string("id"); * * new Bot() * .on("inline_query", async (ctx) => { * await ctx.answer(tracks.map((t) => ({ * type: "audio", * id: trackRef.pack({ src: t.source, id: t.id }), * audio_url: t.url, * title: t.title, * }))); * }) * .chosenInlineResult(trackRef, (ctx) => { * ctx.queryData; // { src: string; id: string } * }); * ``` * * String/RegExp/predicate triggers filter on `context.query` (the user's * typed text); the `CallbackData` schema filters on `context.resultId`. */ chosenInlineResult) => boolean), Ctx = ContextType, TOptions extends HandlerOptions = {}>(trigger: Trigger, handler: (context: Ctx & { args: RegExpMatchArray | null; queryData: Trigger extends CallbackData ? ReturnType : never; } & DeriveFromOptions) => unknown, options?: TOptions): this; /** * Register handler to `inline_query` update * * @example * ```ts * new Bot().inlineQuery( * /regular expression with (.*)/i, * async (context) => { * if (context.args) { * await context.answer( * [ * InlineQueryResult.article( * "id-1", * context.args[1], * InputMessageContent.text("some"), * { * reply_markup: new InlineKeyboard().text( * "some", * "callback-data" * ), * } * ), * ], * { * cache_time: 0, * } * ); * } * }, * { * onResult: (context) => context.editText("Message edited!"), * } * ); * ``` * */ inlineQuery>(handler: (context: Ctx & { args: RegExpMatchArray | null; }) => unknown): this; inlineQuery>(trigger: RegExp | string | ((context: Ctx) => boolean), handler: (context: Ctx & { args: RegExpMatchArray | null; }) => unknown, options?: HandlerOptions & { onResult?: (context: ContextType & { args: RegExpMatchArray | null; }) => unknown; }): this; /** * Register handler to `guest_message` update — a message sent to the bot * from a chat where the bot is not a member, via a guest query. * * Reply with {@link MessageContext.answerGuestQuery `context.answerGuestQuery()`} * (NOT `context.send`/`context.reply`, which target a chat the bot can't post to). * * @example * ```ts * new Bot().guestQuery(/^find (.*)/i, async (context) => { * await context.answerGuestQuery({ * type: "text", * text: `Looking up ${context.args?.[1]}…`, * }); * }); * * // No-trigger form — match any guest message: * new Bot().guestQuery(async (context) => { * await context.answerGuestQuery({ type: "text", text: "Hi!" }); * }); * ``` * */ guestQuery>(handler: (context: Ctx & { args: RegExpMatchArray | null; }) => unknown): this; guestQuery>(trigger: RegExp | string | ((context: Ctx) => boolean), handler: (context: Ctx & { args: RegExpMatchArray | null; }) => unknown, options?: HandlerOptions): this; /** * Register handler to `message` and `business_message` event * * @example * ```ts * new Bot().hears(/regular expression with (.*)/i, async (context) => { * if (context.args) await context.send(`Params ${context.args[1]}`); * }); * ``` */ hears, Trigger extends CallbackData | RegExp | MaybeArray | ((context: Ctx) => boolean) = CallbackData | RegExp | MaybeArray | ((context: Ctx) => boolean), TOptions extends HandlerOptions = {}>(trigger: Trigger, handler: (context: Ctx & { args: RegExpMatchArray | null; /** * Payload decoded from a reply-keyboard button's hidden suffix when * `trigger` is a {@link CallbackData} (otherwise `undefined`). */ replyData: Trigger extends CallbackData ? ReturnType : undefined; } & DeriveFromOptions) => unknown, options?: TOptions): this; /** * Register handler to `message` and `business_message` event when entities contains a command * * @example * ```ts * new Bot().command("start", async (context) => { * return context.send(`You message is /start ${context.args}`); * }); * ``` * * @example * ```ts * // With metadata — description will be synced via syncCommands() * new Bot().command("start", { * description: "Start the bot", * locales: { ru: "Запустить бота" }, * }, (context) => context.send("Hello!")); * ``` */ command, Macros> = {}>(command: MaybeArray, handler: (context: ContextType & { args: string | null; } & DeriveFromOptions) => unknown, options?: TOptions): typeof this; command, Macros> = {}>(command: MaybeArray, meta: CommandMeta, handler: (context: ContextType & { args: string | null; } & DeriveFromOptions) => unknown, options?: TOptions): typeof this; /** * Register handler to `start` command when start parameter is matched * * @example * ```ts * new Bot().startParameter(/^ref_(.+)$/, (context) => { * return context.send(`Reference: ${context.rawStartPayload}`); * }); * ``` */ startParameter & { rawStartPayload: string; }, Macros> = {}>(parameter: RegExp | MaybeArray, handler: Handler & { rawStartPayload: string; } & DeriveFromOptions>, options?: TOptions): this; /** Currently not isolated!!! */ group(grouped: (bot: typeof this) => AnyBot): typeof this; /** * Sync registered command metadata with the Telegram API. * * Groups commands by `{scope, language_code}` and calls `setMyCommands` for each group. * When a `storage` is provided, hashes each payload and skips unchanged groups. * * @example * ```ts * bot.onStart(() => bot.syncCommands()); * ``` */ syncCommands(options?: SyncCommandsOptions): Promise; /** * Init bot. Call it manually only if you doesn't use {@link Bot.start} */ init(): Promise; /** * Start receive updates via long-polling or webhook * * @example * ```ts * import { Bot } from "gramio"; * * const bot = new Bot("") // put you token here * .command("start", (context) => context.send("Hi!")) * .onStart(console.log); * * bot.start(); * ``` */ start({ webhook, longPolling, dropPendingUpdates, allowedUpdates: allowedUpdatesRaw, deleteWebhook: deleteWebhookRaw, }?: BotStartOptions): Promise; /** * Stops receiving events via long-polling or webhook * */ stop(timeout?: number): Promise; } /** * A type guard predicate that narrows `In` to `Out`. * Built-in filters use `any` as `In` so they work with any bot's context type. * The actual narrowing happens via intersection in the `.on()` handler type. */ type Filter = (context: In) => context is Out; type ExtractNarrow = F extends Filter ? N : never; /** Maps forward origin type strings to their concrete classes */ type ForwardOriginMapping = { user: MessageOriginUser; chat: MessageOriginChat; channel: MessageOriginChannel; hidden_user: MessageOriginHiddenUser; }; type AnyForwardOrigin = ForwardOriginMapping[keyof ForwardOriginMapping]; interface ForwardOriginFilter { /** Matches any forwarded message, narrowing `forwardOrigin` to the full origin union */ (): Filter; /** * Matches forwarded messages of a specific origin type. * * @example * filters.forwardOrigin("user") // forwarded from a real user * filters.forwardOrigin("channel") // forwarded from a channel */ (type: T): Filter; } type ChatTypeUnion = "private" | "group" | "supergroup" | "channel"; interface SenderChatFilter { /** Matches messages sent on behalf of a chat, narrowing `senderChat` to `Chat` */ (): Filter; /** * Matches messages sent on behalf of a chat of a specific type. * * @example * filters.senderChat("channel") // anonymous channel post * filters.senderChat("supergroup") // anonymous supergroup admin */ (type: T): Filter; } type UnionToIntersection = (U extends any ? (x: U) => void : never) extends (x: infer I) => void ? I : never; /** Union of all attachment types (shorthand for `AttachmentsMapping[keyof AttachmentsMapping]`) */ type AnyAttachment = AttachmentsMapping[keyof AttachmentsMapping]; declare const filters: { photo: Filter; video: Filter; document: Filter; audio: Filter; sticker: Filter; voice: Filter; videoNote: Filter; animation: Filter; contact: Filter; location: Filter; poll: Filter; /** Matches any message that has an attachment */ media: Filter; /** Matches messages that have text */ text: Filter; /** Matches messages that have a caption */ caption: Filter; /** Matches messages that contain a dice */ dice: Filter; /** Matches forwarded messages. Call without args for any origin, or pass a type to narrow precisely. */ forwardOrigin: ForwardOriginFilter; /** Matches messages that are replies */ reply: Filter; /** Matches messages that have text entities */ entities: Filter; /** Matches messages that have caption entities */ captionEntities: Filter; /** Matches messages that have a quote */ quote: Filter; /** Matches messages sent via a bot */ viaBot: Filter; /** Matches messages that have link preview options */ linkPreview: Filter; /** Matches messages with a /start payload */ startPayload: Filter; /** Matches messages with a raw /start payload string */ rawStartPayload: Filter; /** Matches messages with an author signature */ authorSignature: Filter; /** Matches messages with external reply info */ replyInfo: Filter; /** Matches contexts that have a sender (from user) */ hasFrom: Filter; /** Matches messages sent on behalf of a chat. Pass a type to also narrow `senderChat.type`. */ senderChat: SenderChatFilter; /** Matches giveaway messages */ giveaway: Filter; /** Matches messages with paid media */ paidMedia: Filter; /** Matches messages with a game */ game: Filter; /** Matches messages with a story */ story: Filter; /** Matches messages with an effect ID */ effectId: Filter; /** Matches messages that belong to a media group */ mediaGroup: Filter; /** Matches messages with a venue */ venue: Filter; /** Matches messages from bot accounts */ isBot: (ctx: any) => boolean; /** Matches messages from premium users */ isPremium: (ctx: any) => boolean; /** Matches messages in forum (topic) chats */ isForum: (ctx: any) => boolean; /** Matches service messages */ service: (ctx: any) => any; /** Matches messages in topics */ topicMessage: (ctx: any) => any; /** Matches media with spoiler. Narrows `attachment` to confirm media is present. */ mediaSpoiler: Filter; /** Matches messages with protected content. No type narrowing. */ protectedContent: (ctx: any) => boolean; /** Matches messages sent while user was offline. No type narrowing. */ fromOffline: (ctx: any) => boolean; /** Matches callback queries that have an associated message */ hasMessage: Filter; }>; /** Matches callback queries that have data */ hasData: Filter; /** Matches callback queries with an inline message ID */ hasInlineMessageId: Filter; /** Matches callback queries with a game short name */ hasGameShortName: Filter; /** Matches messages with a specific text entity type */ entity(type: TelegramMessageEntity["type"]): Filter; /** Matches messages with a specific caption entity type */ captionEntity(type: TelegramMessageEntity["type"]): Filter; /** Matches messages from a specific chat type. Narrows both `chatType` and `chat.type`. */ chat(type: T): Filter; /** Matches private (DM) chats. Narrows both `chatType` and `chat.type`. */ pm: Filter; /** Matches group chats. Narrows both `chatType` and `chat.type`. */ group: Filter; /** Matches supergroup chats. Narrows both `chatType` and `chat.type`. */ supergroup: Filter; /** Matches channel chats. Narrows both `chatType` and `chat.type`. */ channel: Filter; /** Matches messages from specific user(s). No type narrowing. */ from(userId: number | number[]): (ctx: any) => boolean; /** Matches messages in specific chat(s). No type narrowing. */ chatId(chatId: number | number[]): (ctx: any) => boolean; /** Matches messages whose text/caption matches the regex, sets `ctx.match` */ regex(pattern: RegExp): Filter; /** Intersection: both filters must match */ and(f1: Filter, f2: Filter): Filter; /** Union: either filter must match */ or(f1: Filter, f2: Filter): Filter; /** Negation: inverts the filter (no type narrowing) */ not(f: (ctx: any) => boolean): (ctx: any) => boolean; /** Variadic intersection: all filters must match */ every[]>(...filters: Filters): Filter>>; /** Variadic union: any filter must match */ some[]>(...filters: Filters): Filter>; }; declare const frameworks: { elysia: ({ body, headers }: any) => { update: any; header: any; unauthorized: () => Response; response: () => Response; }; fastify: (request: any, reply: any) => { update: any; header: any; unauthorized: () => any; response: () => any; }; hono: (c: any) => { update: any; header: any; unauthorized: () => any; response: () => Response; }; express: (req: any, res: any) => { update: any; header: any; unauthorized: () => any; response: () => any; }; koa: (ctx: any) => { update: any; header: any; unauthorized: () => void; response: () => void; }; http: (req: any, res: any) => { update: Promise; header: any; unauthorized: () => any; response: () => any; }; "std/http": (req: any) => { update: any; header: any; response: () => Response; unauthorized: () => Response; }; "Bun.serve": (req: any) => { update: any; header: any; response: () => Response; unauthorized: () => Response; }; cloudflare: (req: any) => { update: any; header: any; response: () => Response; unauthorized: () => Response; }; Request: (req: any) => { update: any; header: any; response: () => Response; unauthorized: () => Response; }; }; /** Union type of webhook handlers name */ type WebhookHandlers = keyof typeof frameworks; interface WebhookHandlerOptionsShouldWait { /** Action to take when timeout occurs. @default "throw" */ onTimeout?: "throw" | "return"; /** Timeout in milliseconds. @default 10_000 */ timeout?: number; } interface WebhookHandlerOptions { secretToken?: string; shouldWait?: boolean | WebhookHandlerOptionsShouldWait; } /** * Setup handler with yours web-framework to receive updates via webhook * * @example * ```ts * import { Bot } from "gramio"; * import Fastify from "fastify"; * * const bot = new Bot(process.env.TOKEN as string).on( * "message", * (context) => { * return context.send("Fastify!"); * }, * ); * * const fastify = Fastify(); * * fastify.post("/telegram-webhook", webhookHandler(bot, "fastify")); * * fastify.listen({ port: 3445, host: "::" }); * * bot.start({ * webhook: { * url: "https://example.com:3445/telegram-webhook", * }, * }); * ``` */ declare function webhookHandler(bot: AnyBot, framework: Framework, secretTokenOrOptions?: string | WebhookHandlerOptions): ReturnType<(typeof frameworks)[Framework]> extends { response: () => any; } ? (...args: Parameters<(typeof frameworks)[Framework]>) => ReturnType["response"]> : (...args: Parameters<(typeof frameworks)[Framework]>) => void; export { AllowedUpdatesFilter, Bot, Composer, ErrorKind, Hooks, OPT_IN_TYPES, Plugin, TelegramError, Updates, methods as _composerMethods, buildAllowedUpdates, detectOptInUpdates, filters, mapEventToAllowedUpdates, webhookHandler }; export type { AllowedUpdateName, AllowedUpdates, AnyBot, AnyPlugin, BotOptions, BotStartOptions, BotStartOptionsLongPolling, BotStartOptionsWebhook, CallbackQueryShorthandContext, CommandMeta, DeriveDefinitions, ErrorDefinitions, Filter, Handler, MaybePromise, MaybeSuppressedParams, MaybeSuppressedReturn, PollingStartOptions, ScopeShorthand, Suppress, SuppressedAPIMethodParams, SuppressedAPIMethodReturn, SuppressedAPIMethods, SyncCommandsOptions, SyncStorage, WebhookHandlerOptions, WebhookHandlerOptionsShouldWait, WebhookHandlers };