Options
All
  • Public
  • Public/Protected
  • All
Menu

Type parameters

Hierarchy

Index

Constructors

Properties

botInfo?: UserFromGetMe

Set manually to avoid implicit getMe call in launch or webhookCallback

botInfoCall?: Promise<UserFromGetMe>
context: Partial<C> = {}
options: Options<C>
polling?: Polling
telegram: Telegram
webhookServer?: Server | Server

Accessors

  • get token(): string
  • get webhookReply(): boolean
  • set webhookReply(webhookReply: boolean): void
  • deprecated

    use ctx.telegram.webhookReply

    Returns boolean

  • deprecated

    use ctx.telegram.webhookReply

    Parameters

    • webhookReply: boolean

    Returns void

Methods

  • action(triggers: Triggers<C>, ...fns: MatchedMiddleware<C, "callback_query">): Telegraf<C>
  • Registers middleware for handling matching callback queries.

    Parameters

    • triggers: Triggers<C>
    • Rest ...fns: MatchedMiddleware<C, "callback_query">

    Returns Telegraf<C>

  • cashtag(cashtag: MaybeArray<string>, ...fns: MatchedMiddleware<C, "message" | "channel_post">): Telegraf<C>
  • catch(handler: (err: unknown, ctx: C) => MaybePromise<void>): Telegraf<C>
  • Override error handling

    Parameters

    • handler: (err: unknown, ctx: C) => MaybePromise<void>
        • (err: unknown, ctx: C): MaybePromise<void>
        • Parameters

          • err: unknown
          • ctx: C

          Returns MaybePromise<void>

    Returns Telegraf<C>

  • command(command: MaybeArray<string>, ...fns: NonemptyReadonlyArray<Middleware<MatchedContext<C, "text">>>): Telegraf<C>
  • Registers middleware for handling specified commands.

    Parameters

    • command: MaybeArray<string>
    • Rest ...fns: NonemptyReadonlyArray<Middleware<MatchedContext<C, "text">>>

    Returns Telegraf<C>

  • drop(predicate: Predicate<C>): Telegraf<C>
  • email(email: Triggers<C>, ...fns: MatchedMiddleware<C, "message" | "channel_post">): Telegraf<C>
  • filter(predicate: Predicate<C>): Telegraf<C>
  • Registers middleware for handling updates matching given type guard function.

    Type parameters

    • U: Update

    Parameters

    • guardFn: (update: Update) => update is U
        • (update: Update): update is U
        • Parameters

          • update: Update

          Returns update is U

    • Rest ...fns: NonemptyReadonlyArray<Middleware<NarrowedContext<C, U>>>

    Returns Telegraf<C>

  • handleError(err: unknown, ctx: C): MaybePromise<void>
  • Parameters

    • err: unknown
    • ctx: C

    Returns MaybePromise<void>

  • handleUpdate(update: Update, webhookResponse?: ServerResponse): Promise<void>
  • Parameters

    • update: Update
    • Optional webhookResponse: ServerResponse

    Returns Promise<void>

  • handleUpdates(updates: readonly Update[]): Promise<void[]>
  • Parameters

    • updates: readonly Update[]

    Returns Promise<void[]>

  • hashtag(hashtag: MaybeArray<string>, ...fns: MatchedMiddleware<C, "message" | "channel_post">): Telegraf<C>
  • hears(triggers: Triggers<C>, ...fns: MatchedMiddleware<C, "text">): Telegraf<C>
  • Registers middleware for handling matching text messages.

    Parameters

    • triggers: Triggers<C>
    • Rest ...fns: MatchedMiddleware<C, "text">

    Returns Telegraf<C>

  • inlineQuery(triggers: Triggers<C>, ...fns: MatchedMiddleware<C, "inline_query">): Telegraf<C>
  • Registers middleware for handling matching inline queries.

    Parameters

    • triggers: Triggers<C>
    • Rest ...fns: MatchedMiddleware<C, "inline_query">

    Returns Telegraf<C>

  • mention(mention: MaybeArray<string>, ...fns: MatchedMiddleware<C, "message" | "channel_post">): Telegraf<C>
  • on<T>(updateType: MaybeArray<T>, ...fns: NonemptyReadonlyArray<Middleware<MatchedContext<C, T>>>): Telegraf<C>
  • Registers middleware for handling provided update types.

    Type parameters

    • T: "text" | "callback_query" | "message" | "channel_post" | "chat_member" | "chosen_inline_result" | "edited_channel_post" | "edited_message" | "inline_query" | "my_chat_member" | "pre_checkout_query" | "poll_answer" | "poll" | "shipping_query" | "chat_join_request" | "channel_chat_created" | "connected_website" | "delete_chat_photo" | "group_chat_created" | "invoice" | "left_chat_member" | "message_auto_delete_timer_changed" | "migrate_from_chat_id" | "migrate_to_chat_id" | "new_chat_members" | "new_chat_photo" | "new_chat_title" | "passport_data" | "proximity_alert_triggered" | "pinned_message" | "successful_payment" | "supergroup_chat_created" | "video_chat_scheduled" | "video_chat_started" | "video_chat_ended" | "video_chat_participants_invited" | "web_app_data" | "forward_date" | "animation" | "document" | "audio" | "contact" | "dice" | "game" | "location" | "photo" | "sticker" | "venue" | "video" | "video_note" | "voice"

    Parameters

    • updateType: MaybeArray<T>
    • Rest ...fns: NonemptyReadonlyArray<Middleware<MatchedContext<C, T>>>

    Returns Telegraf<C>

  • phone(number: Triggers<C>, ...fns: MatchedMiddleware<C, "message" | "channel_post">): Telegraf<C>
  • secretPathComponent(): string
  • settings(...fns: NonemptyReadonlyArray<Middleware<MatchedContext<C, "text">>>): Telegraf<C>
  • spoiler(text: Triggers<C>, ...fns: MatchedMiddleware<C, "message" | "channel_post">): Telegraf<C>
  • start(...fns: NonemptyReadonlyArray<Middleware<Context<{ message: New & NonChannel & TextMessage; update_id: number }> & Omit<C, keyof Context<Update>> & { startPayload: string }>>): Telegraf<C>
  • Registers a middleware for handling /start

    Parameters

    • Rest ...fns: NonemptyReadonlyArray<Middleware<Context<{ message: New & NonChannel & TextMessage; update_id: number }> & Omit<C, keyof Context<Update>> & { startPayload: string }>>

    Returns Telegraf<C>

  • startWebhook(hookPath: string, tlsOptions?: TlsOptions, port?: number, host?: string, cb?: RequestListener): Telegraf<C>
  • Parameters

    • hookPath: string
    • Optional tlsOptions: TlsOptions
    • Optional port: number
    • Optional host: string
    • Optional cb: RequestListener

    Returns Telegraf<C>

  • stop(reason?: string): void
  • Parameters

    • reason: string = 'unspecified'

    Returns void

  • textLink(link: Triggers<C>, ...fns: MatchedMiddleware<C, "message" | "channel_post">): Telegraf<C>
  • textMention(mention: Triggers<C>, ...fns: MatchedMiddleware<C, "message" | "channel_post">): Telegraf<C>
  • url(url: Triggers<C>, ...fns: MatchedMiddleware<C, "message" | "channel_post">): Telegraf<C>
  • webhookCallback(path?: string): (req: IncomingMessage & { body?: Update }, res: ServerResponse, next?: () => void) => Promise<void>
  • Parameters

    • path: string = '/'

    Returns (req: IncomingMessage & { body?: Update }, res: ServerResponse, next?: () => void) => Promise<void>

      • (req: IncomingMessage & { body?: Update }, res: ServerResponse, next?: () => void): Promise<void>
      • Parameters

        • req: IncomingMessage & { body?: Update }
        • res: ServerResponse
        • next: () => void = ...
            • (): void
            • Returns void

        Returns Promise<void>

  • action<C>(triggers: Triggers<C>, ...fns: MatchedMiddleware<C, "callback_query">): MiddlewareFn<C>
  • Generates middleware for handling matching callback queries.

    Type parameters

    Parameters

    • triggers: Triggers<C>
    • Rest ...fns: MatchedMiddleware<C, "callback_query">

    Returns MiddlewareFn<C>

  • cashtag<C>(cashtag: MaybeArray<string>, ...fns: MatchedMiddleware<C, "message" | "channel_post">): MiddlewareFn<C>
  • chatType<C>(type: MaybeArray<"channel" | "private" | "group" | "supergroup">, ...fns: NonemptyReadonlyArray<Middleware<C>>): MiddlewareFn<C>
  • Generates middleware running only in specified chat types.

    Type parameters

    Parameters

    • type: MaybeArray<"channel" | "private" | "group" | "supergroup">
    • Rest ...fns: NonemptyReadonlyArray<Middleware<C>>

    Returns MiddlewareFn<C>

  • command<C>(command: MaybeArray<string>, ...fns: NonemptyReadonlyArray<Middleware<MatchedContext<C, "text">>>): MiddlewareFn<C>
  • dispatch<C, Handlers>(routeFn: (ctx: C) => MaybePromise<keyof Handlers>, handlers: Handlers): Middleware<C>
  • Type parameters

    Parameters

    • routeFn: (ctx: C) => MaybePromise<keyof Handlers>
        • (ctx: C): MaybePromise<keyof Handlers>
        • Parameters

          • ctx: C

          Returns MaybePromise<keyof Handlers>

    • handlers: Handlers

    Returns Middleware<C>

  • email<C>(email: Triggers<C>, ...fns: MatchedMiddleware<C, "message" | "channel_post">): MiddlewareFn<C>
  • entityText<C>(entityType: MaybeArray<string>, predicate: Triggers<C>, ...fns: MatchedMiddleware<C, "message" | "channel_post">): MiddlewareFn<C>
  • Generates optional middleware based on a predicate that only operates on ctx.update.

    Example:

    import { Composer, Update } from 'telegraf'

    const predicate = (u): u is Update.MessageUpdate => 'message' in u
    const middleware = Composer.guard(predicate, (ctx) => {
    const message = ctx.update.message
    })

    Note that Composer.on('message') is preferred over this.

    see

    Composer.optional for a more generic version of this method that allows the predicate to operate on ctx itself

    Type parameters

    Parameters

    • guardFn: (u: Update) => u is U

      predicate to decide whether to run the middleware based on the ctx.update object

        • (u: Update): u is U
        • Parameters

          • u: Update

          Returns u is U

    • Rest ...fns: NonemptyReadonlyArray<Middleware<NarrowedContext<C, U>>>

      middleware to run if the predicate returns true

    Returns MiddlewareFn<C>

  • hashtag<C>(hashtag: MaybeArray<string>, ...fns: MatchedMiddleware<C, "message" | "channel_post">): MiddlewareFn<C>
  • hears<C>(triggers: Triggers<C>, ...fns: MatchedMiddleware<C, "text">): MiddlewareFn<C>
  • Generates middleware for handling matching text messages.

    Type parameters

    Parameters

    • triggers: Triggers<C>
    • Rest ...fns: MatchedMiddleware<C, "text">

    Returns MiddlewareFn<C>

  • inlineQuery<C>(triggers: Triggers<C>, ...fns: MatchedMiddleware<C, "inline_query">): MiddlewareFn<C>
  • mention<C>(mention: MaybeArray<string>, ...fns: MatchedMiddleware<C, "message" | "channel_post">): MiddlewareFn<C>
  • mount<C, T>(updateType: MaybeArray<T>, ...fns: NonemptyReadonlyArray<Middleware<MatchedContext<C, T>>>): MiddlewareFn<C>
  • Generates middleware for handling provided update types.

    deprecated

    use Composer.on

    Type parameters

    • C: Context<Update, C>

    • T: "text" | "callback_query" | "message" | "channel_post" | "chat_member" | "chosen_inline_result" | "edited_channel_post" | "edited_message" | "inline_query" | "my_chat_member" | "pre_checkout_query" | "poll_answer" | "poll" | "shipping_query" | "chat_join_request" | "channel_chat_created" | "connected_website" | "delete_chat_photo" | "group_chat_created" | "invoice" | "left_chat_member" | "message_auto_delete_timer_changed" | "migrate_from_chat_id" | "migrate_to_chat_id" | "new_chat_members" | "new_chat_photo" | "new_chat_title" | "passport_data" | "proximity_alert_triggered" | "pinned_message" | "successful_payment" | "supergroup_chat_created" | "video_chat_scheduled" | "video_chat_started" | "video_chat_ended" | "video_chat_participants_invited" | "web_app_data" | "forward_date" | "animation" | "document" | "audio" | "contact" | "dice" | "game" | "location" | "photo" | "sticker" | "venue" | "video" | "video_note" | "voice"

    Parameters

    • updateType: MaybeArray<T>
    • Rest ...fns: NonemptyReadonlyArray<Middleware<MatchedContext<C, T>>>

    Returns MiddlewareFn<C>

  • on<C, T>(updateType: MaybeArray<T>, ...fns: NonemptyReadonlyArray<Middleware<MatchedContext<C, T>>>): MiddlewareFn<C>
  • Generates middleware for handling provided update types.

    Type parameters

    • C: Context<Update, C>

    • T: "text" | "callback_query" | "message" | "channel_post" | "chat_member" | "chosen_inline_result" | "edited_channel_post" | "edited_message" | "inline_query" | "my_chat_member" | "pre_checkout_query" | "poll_answer" | "poll" | "shipping_query" | "chat_join_request" | "channel_chat_created" | "connected_website" | "delete_chat_photo" | "group_chat_created" | "invoice" | "left_chat_member" | "message_auto_delete_timer_changed" | "migrate_from_chat_id" | "migrate_to_chat_id" | "new_chat_members" | "new_chat_photo" | "new_chat_title" | "passport_data" | "proximity_alert_triggered" | "pinned_message" | "successful_payment" | "supergroup_chat_created" | "video_chat_scheduled" | "video_chat_started" | "video_chat_ended" | "video_chat_participants_invited" | "web_app_data" | "forward_date" | "animation" | "document" | "audio" | "contact" | "dice" | "game" | "location" | "photo" | "sticker" | "venue" | "video" | "video_note" | "voice"

    Parameters

    • updateType: MaybeArray<T>
    • Rest ...fns: NonemptyReadonlyArray<Middleware<MatchedContext<C, T>>>

    Returns MiddlewareFn<C>

  • optional<C>(predicate: Predicate<C> | AsyncPredicate<C>, ...fns: NonemptyReadonlyArray<Middleware<C>>): MiddlewareFn<C>
  • Generates optional middleware.

    Type parameters

    Parameters

    • predicate: Predicate<C> | AsyncPredicate<C>

      predicate to decide on a context object whether to run the middleware

    • Rest ...fns: NonemptyReadonlyArray<Middleware<C>>

    Returns MiddlewareFn<C>

  • phone<C>(number: Triggers<C>, ...fns: MatchedMiddleware<C, "message" | "channel_post">): MiddlewareFn<C>
  • spoiler<C>(text: Triggers<C>, ...fns: MatchedMiddleware<C, "message" | "channel_post">): MiddlewareFn<C>
  • textLink<C>(link: Triggers<C>, ...fns: MatchedMiddleware<C, "message" | "channel_post">): MiddlewareFn<C>
  • textMention<C>(mention: Triggers<C>, ...fns: MatchedMiddleware<C, "message" | "channel_post">): MiddlewareFn<C>
  • url<C>(url: Triggers<C>, ...fns: MatchedMiddleware<C, "message" | "channel_post">): MiddlewareFn<C>

Generated using TypeDoc