Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Telegraf<C>

Type parameters

Hierarchy

Index

Constructors

constructor

  • new Telegraf<C>(token: string, options?: Partial<Options<C>>): Telegraf<C>

Properties

Optional botInfo

botInfo: undefined | UserFromGetMe

Set manually to avoid implicit getMe call in launch or webhookCallback

Private Optional botInfoCall

botInfoCall: undefined | Promise<UserFromGetMe>

Readonly context

context: Partial<C> = ...

Private Readonly options

options: Options<C>

Private Optional polling

polling: undefined | Polling

telegram

telegram: Telegram

Private Optional webhookServer

webhookServer: undefined | Server | Server

Accessors

token

  • get token(): string

webhookReply

  • get webhookReply(): boolean
  • set webhookReply(webhookReply: boolean): void
  • Returns boolean

  • deprecated

    use ctx.telegram.webhookReply

    Parameters

    • webhookReply: boolean

    Returns void

Methods

action

  • action(triggers: MaybeArray<string | RegExp | ((value: string, ctx: C) => null | RegExpExecArray)>, ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"callback_query", object>>>>): Telegraf<C>
  • Registers middleware for handling matching callback queries.

    Parameters

    • triggers: MaybeArray<string | RegExp | ((value: string, ctx: C) => null | RegExpExecArray)>
    • Rest ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"callback_query", object>>>>

    Returns Telegraf<C>

cashtag

  • cashtag(cashtag: MaybeArray<string>, ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"channel_post", object> | Record<"message", object>>>>): Telegraf<C>
  • Parameters

    • cashtag: MaybeArray<string>
    • Rest ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"channel_post", object> | Record<"message", object>>>>

    Returns Telegraf<C>

catch

  • 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(command: MaybeArray<string>, ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, { message: Pick<TextMessage & AnimationMessage & DocumentMessage & AudioMessage & ChannelChatCreatedMessage & ConnectedWebsiteMessage & ContactMessage & DeleteChatPhotoMessage & DiceMessage & GameMessage & GroupChatCreatedMessage & InvoiceMessage & LeftChatMemberMessage & LocationMessage & MigrateFromChatIdMessage & MigrateToChatIdMessage & NewChatMembersMessage & NewChatPhotoMessage & NewChatTitleMessage & PassportDataMessage & ProximityAlertTriggeredMessage & PhotoMessage & PinnedMessageMessage & PollMessage & StickerMessage & SuccessfulPaymentMessage & SupergroupChatCreated & VenueMessage & VideoMessage & VideoNoteMessage & VoiceMessage, "text"> }>>>): Telegraf<C>
  • Registers middleware for handling specified commands.

    Parameters

    • command: MaybeArray<string>
    • Rest ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, { message: Pick<TextMessage & AnimationMessage & DocumentMessage & AudioMessage & ChannelChatCreatedMessage & ConnectedWebsiteMessage & ContactMessage & DeleteChatPhotoMessage & DiceMessage & GameMessage & GroupChatCreatedMessage & InvoiceMessage & LeftChatMemberMessage & LocationMessage & MigrateFromChatIdMessage & MigrateToChatIdMessage & NewChatMembersMessage & NewChatPhotoMessage & NewChatTitleMessage & PassportDataMessage & ProximityAlertTriggeredMessage & PhotoMessage & PinnedMessageMessage & PollMessage & StickerMessage & SuccessfulPaymentMessage & SupergroupChatCreated & VenueMessage & VideoMessage & VideoNoteMessage & VoiceMessage, "text"> }>>>

    Returns Telegraf<C>

drop

  • drop(predicate: Predicate<C>): Telegraf<C>

email

  • email(email: MaybeArray<string>, ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"channel_post", object> | Record<"message", object>>>>): Telegraf<C>
  • Parameters

    • email: MaybeArray<string>
    • Rest ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"channel_post", object> | Record<"message", object>>>>

    Returns Telegraf<C>

filter

  • filter(predicate: Predicate<C>): Telegraf<C>

gameQuery

  • gameQuery(...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C, GameQueryUpdate>>>): Telegraf<C>

guard

  • guard<U>(guardFn: (update: Update) => update is U, ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C, U>>>): 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<GuardedContext<C, U>>>

    Returns Telegraf<C>

handleError

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

    • err: unknown
    • ctx: C

    Returns MaybePromise<void>

handleUpdate

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

    • update: Update
    • Optional webhookResponse: ServerResponse

    Returns Promise<void>

Private handleUpdates

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

    • updates: readonly Update[]

    Returns Promise<void[]>

hashtag

  • hashtag(hashtag: MaybeArray<string>, ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"channel_post", object> | Record<"message", object>>>>): Telegraf<C>
  • Parameters

    • hashtag: MaybeArray<string>
    • Rest ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"channel_post", object> | Record<"message", object>>>>

    Returns Telegraf<C>

hears

  • hears(triggers: MaybeArray<string | RegExp | ((value: string, ctx: C) => null | RegExpExecArray)>, ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, { message: Pick<TextMessage & AnimationMessage & DocumentMessage & AudioMessage & ChannelChatCreatedMessage & ConnectedWebsiteMessage & ContactMessage & DeleteChatPhotoMessage & DiceMessage & GameMessage & GroupChatCreatedMessage & InvoiceMessage & LeftChatMemberMessage & LocationMessage & MigrateFromChatIdMessage & MigrateToChatIdMessage & NewChatMembersMessage & NewChatPhotoMessage & NewChatTitleMessage & PassportDataMessage & ProximityAlertTriggeredMessage & PhotoMessage & PinnedMessageMessage & PollMessage & StickerMessage & SuccessfulPaymentMessage & SupergroupChatCreated & VenueMessage & VideoMessage & VideoNoteMessage & VoiceMessage, "text"> }>>>): Telegraf<C>
  • Registers middleware for handling matching text messages.

    Parameters

    • triggers: MaybeArray<string | RegExp | ((value: string, ctx: C) => null | RegExpExecArray)>
    • Rest ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, { message: Pick<TextMessage & AnimationMessage & DocumentMessage & AudioMessage & ChannelChatCreatedMessage & ConnectedWebsiteMessage & ContactMessage & DeleteChatPhotoMessage & DiceMessage & GameMessage & GroupChatCreatedMessage & InvoiceMessage & LeftChatMemberMessage & LocationMessage & MigrateFromChatIdMessage & MigrateToChatIdMessage & NewChatMembersMessage & NewChatPhotoMessage & NewChatTitleMessage & PassportDataMessage & ProximityAlertTriggeredMessage & PhotoMessage & PinnedMessageMessage & PollMessage & StickerMessage & SuccessfulPaymentMessage & SupergroupChatCreated & VenueMessage & VideoMessage & VideoNoteMessage & VoiceMessage, "text"> }>>>

    Returns Telegraf<C>

help

inlineQuery

  • inlineQuery(triggers: MaybeArray<string | RegExp | ((value: string, ctx: C) => null | RegExpExecArray)>, ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"inline_query", object>>>>): Telegraf<C>
  • Registers middleware for handling matching inline queries.

    Parameters

    • triggers: MaybeArray<string | RegExp | ((value: string, ctx: C) => null | RegExpExecArray)>
    • Rest ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"inline_query", object>>>>

    Returns Telegraf<C>

launch

  • launch(config?: LaunchOptions): Promise<void>
  • Parameters

    • config: LaunchOptions = ...

    Returns Promise<void>

mention

  • mention(mention: MaybeArray<string>, ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"channel_post", object> | Record<"message", object>>>>): Telegraf<C>
  • Parameters

    • mention: MaybeArray<string>
    • Rest ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"channel_post", object> | Record<"message", object>>>>

    Returns Telegraf<C>

middleware

on

  • on<T>(updateType: MaybeArray<T>, ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C, MountMap[T]>>>): Telegraf<C>
  • Registers middleware for handling provided update types.

    Type parameters

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

    Parameters

    • updateType: MaybeArray<T>
    • Rest ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C, MountMap[T]>>>

    Returns Telegraf<C>

phone

  • phone(number: MaybeArray<string>, ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"channel_post", object> | Record<"message", object>>>>): Telegraf<C>
  • Parameters

    • number: MaybeArray<string>
    • Rest ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"channel_post", object> | Record<"message", object>>>>

    Returns Telegraf<C>

settings

start

Private startPolling

  • startPolling(allowedUpdates?: ("callback_query" | "channel_post" | "chosen_inline_result" | "edited_channel_post" | "edited_message" | "inline_query" | "message" | "pre_checkout_query" | "shipping_query" | "poll" | "poll_answer")[]): void
  • Parameters

    • allowedUpdates: ("callback_query" | "channel_post" | "chosen_inline_result" | "edited_channel_post" | "edited_message" | "inline_query" | "message" | "pre_checkout_query" | "shipping_query" | "poll" | "poll_answer")[] = ...

    Returns void

Private startWebhook

  • 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

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

    • reason: string = 'unspecified'

    Returns void

textLink

  • textLink(link: MaybeArray<string>, ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"channel_post", object> | Record<"message", object>>>>): Telegraf<C>
  • Parameters

    • link: MaybeArray<string>
    • Rest ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"channel_post", object> | Record<"message", object>>>>

    Returns Telegraf<C>

textMention

  • textMention(mention: MaybeArray<string>, ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"channel_post", object> | Record<"message", object>>>>): Telegraf<C>
  • Parameters

    • mention: MaybeArray<string>
    • Rest ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"channel_post", object> | Record<"message", object>>>>

    Returns Telegraf<C>

url

  • url(url: MaybeArray<string>, ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"channel_post", object> | Record<"message", object>>>>): Telegraf<C>
  • Parameters

    • url: MaybeArray<string>
    • Rest ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"channel_post", object> | Record<"message", object>>>>

    Returns Telegraf<C>

use

webhookCallback

  • webhookCallback(path?: string): (req: IncomingMessage, res: ServerResponse, next?: () => void) => Promise<void>
  • Parameters

    • path: string = '/'

    Returns (req: IncomingMessage, res: ServerResponse, next?: () => void) => Promise<void>

      • (req: IncomingMessage, res: ServerResponse, next?: () => void): Promise<void>
      • Parameters

        • req: IncomingMessage
        • res: ServerResponse
        • next: () => void = ...
            • (): void
            • Returns void

        Returns Promise<void>

Static acl

Static action

  • action<C>(triggers: MaybeArray<string | RegExp | ((value: string, ctx: C) => null | RegExpExecArray)>, ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"callback_query", object>>>>): MiddlewareFn<C>
  • Generates middleware for handling matching callback queries.

    Type parameters

    Parameters

    • triggers: MaybeArray<string | RegExp | ((value: string, ctx: C) => null | RegExpExecArray)>
    • Rest ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"callback_query", object>>>>

    Returns MiddlewareFn<C>

Static admin

Static branch

Static cashtag

  • cashtag<C>(cashtag: MaybeArray<string>, ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"channel_post", object> | Record<"message", object>>>>): MiddlewareFn<C>
  • Type parameters

    Parameters

    • cashtag: MaybeArray<string>
    • Rest ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"channel_post", object> | Record<"message", object>>>>

    Returns MiddlewareFn<C>

Static catch

Static chatType

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

    Type parameters

    Parameters

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

    Returns MiddlewareFn<C>

Static command

  • command<C>(command: MaybeArray<string>, ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, { message: Pick<TextMessage & AnimationMessage & DocumentMessage & AudioMessage & ChannelChatCreatedMessage & ConnectedWebsiteMessage & ContactMessage & DeleteChatPhotoMessage & DiceMessage & GameMessage & GroupChatCreatedMessage & InvoiceMessage & LeftChatMemberMessage & LocationMessage & MigrateFromChatIdMessage & MigrateToChatIdMessage & NewChatMembersMessage & NewChatPhotoMessage & NewChatTitleMessage & PassportDataMessage & ProximityAlertTriggeredMessage & PhotoMessage & PinnedMessageMessage & PollMessage & StickerMessage & SuccessfulPaymentMessage & SupergroupChatCreated & VenueMessage & VideoMessage & VideoNoteMessage & VoiceMessage, "text"> }>>>): MiddlewareFn<C>
  • Generates middleware for handling specified commands.

    Type parameters

    Parameters

    • command: MaybeArray<string>
    • Rest ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, { message: Pick<TextMessage & AnimationMessage & DocumentMessage & AudioMessage & ChannelChatCreatedMessage & ConnectedWebsiteMessage & ContactMessage & DeleteChatPhotoMessage & DiceMessage & GameMessage & GroupChatCreatedMessage & InvoiceMessage & LeftChatMemberMessage & LocationMessage & MigrateFromChatIdMessage & MigrateToChatIdMessage & NewChatMembersMessage & NewChatPhotoMessage & NewChatTitleMessage & PassportDataMessage & ProximityAlertTriggeredMessage & PhotoMessage & PinnedMessageMessage & PollMessage & StickerMessage & SuccessfulPaymentMessage & SupergroupChatCreated & VenueMessage & VideoMessage & VideoNoteMessage & VoiceMessage, "text"> }>>>

    Returns MiddlewareFn<C>

Static compose

Static creator

Static dispatch

  • 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>

Static drop

Static email

  • email<C>(email: MaybeArray<string>, ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"channel_post", object> | Record<"message", object>>>>): MiddlewareFn<C>
  • Type parameters

    Parameters

    • email: MaybeArray<string>
    • Rest ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"channel_post", object> | Record<"message", object>>>>

    Returns MiddlewareFn<C>

Static entityText

  • entityText<C>(entityType: MaybeArray<string>, predicate: MaybeArray<string | RegExp | ((value: string, ctx: C) => null | RegExpExecArray)>, ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"channel_post", object> | Record<"message", object>>>>): MiddlewareFn<C>
  • Type parameters

    Parameters

    • entityType: MaybeArray<string>
    • predicate: MaybeArray<string | RegExp | ((value: string, ctx: C) => null | RegExpExecArray)>
    • Rest ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"channel_post", object> | Record<"message", object>>>>

    Returns MiddlewareFn<C>

Static filter

Static fork

Static gameQuery

  • gameQuery<C>(...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C, GameQueryUpdate>>>): MiddlewareFn<C>

Static groupChat

Static guard

  • guard<C, U>(guardFn: (u: Update) => u is U, ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C, U>>>): 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.mount('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<GuardedContext<C, U>>>

      middleware to run if the predicate returns true

    Returns MiddlewareFn<C>

Static hashtag

  • hashtag<C>(hashtag: MaybeArray<string>, ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"channel_post", object> | Record<"message", object>>>>): MiddlewareFn<C>
  • Type parameters

    Parameters

    • hashtag: MaybeArray<string>
    • Rest ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"channel_post", object> | Record<"message", object>>>>

    Returns MiddlewareFn<C>

Static hears

  • hears<C>(triggers: MaybeArray<string | RegExp | ((value: string, ctx: C) => null | RegExpExecArray)>, ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, { message: Pick<TextMessage & AnimationMessage & DocumentMessage & AudioMessage & ChannelChatCreatedMessage & ConnectedWebsiteMessage & ContactMessage & DeleteChatPhotoMessage & DiceMessage & GameMessage & GroupChatCreatedMessage & InvoiceMessage & LeftChatMemberMessage & LocationMessage & MigrateFromChatIdMessage & MigrateToChatIdMessage & NewChatMembersMessage & NewChatPhotoMessage & NewChatTitleMessage & PassportDataMessage & ProximityAlertTriggeredMessage & PhotoMessage & PinnedMessageMessage & PollMessage & StickerMessage & SuccessfulPaymentMessage & SupergroupChatCreated & VenueMessage & VideoMessage & VideoNoteMessage & VoiceMessage, "text"> }>>>): MiddlewareFn<C>
  • Generates middleware for handling matching text messages.

    Type parameters

    Parameters

    • triggers: MaybeArray<string | RegExp | ((value: string, ctx: C) => null | RegExpExecArray)>
    • Rest ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, { message: Pick<TextMessage & AnimationMessage & DocumentMessage & AudioMessage & ChannelChatCreatedMessage & ConnectedWebsiteMessage & ContactMessage & DeleteChatPhotoMessage & DiceMessage & GameMessage & GroupChatCreatedMessage & InvoiceMessage & LeftChatMemberMessage & LocationMessage & MigrateFromChatIdMessage & MigrateToChatIdMessage & NewChatMembersMessage & NewChatPhotoMessage & NewChatTitleMessage & PassportDataMessage & ProximityAlertTriggeredMessage & PhotoMessage & PinnedMessageMessage & PollMessage & StickerMessage & SuccessfulPaymentMessage & SupergroupChatCreated & VenueMessage & VideoMessage & VideoNoteMessage & VoiceMessage, "text"> }>>>

    Returns MiddlewareFn<C>

Static inlineQuery

  • inlineQuery<C>(triggers: MaybeArray<string | RegExp | ((value: string, ctx: C) => null | RegExpExecArray)>, ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"inline_query", object>>>>): MiddlewareFn<C>
  • Generates middleware for handling matching inline queries.

    Type parameters

    Parameters

    • triggers: MaybeArray<string | RegExp | ((value: string, ctx: C) => null | RegExpExecArray)>
    • Rest ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"inline_query", object>>>>

    Returns MiddlewareFn<C>

Static lazy

Static log

Static mention

  • mention<C>(mention: MaybeArray<string>, ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"channel_post", object> | Record<"message", object>>>>): MiddlewareFn<C>
  • Type parameters

    Parameters

    • mention: MaybeArray<string>
    • Rest ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"channel_post", object> | Record<"message", object>>>>

    Returns MiddlewareFn<C>

Static mount

  • mount<C, T>(updateType: MaybeArray<T>, ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C, MountMap[T]>>>): MiddlewareFn<C>
  • Generates middleware for handling provided update types.

    deprecated

    use Composer.on

    Type parameters

    • C: Context<C>

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

    Parameters

    • updateType: MaybeArray<T>
    • Rest ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C, MountMap[T]>>>

    Returns MiddlewareFn<C>

Static on

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

    Type parameters

    • C: Context<C>

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

    Parameters

    • updateType: MaybeArray<T>
    • Rest ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C, MountMap[T]>>>

    Returns MiddlewareFn<C>

Static optional

  • 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>

Static passThru

Static phone

  • phone<C>(number: MaybeArray<string>, ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"channel_post", object> | Record<"message", object>>>>): MiddlewareFn<C>
  • Type parameters

    Parameters

    • number: MaybeArray<string>
    • Rest ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"channel_post", object> | Record<"message", object>>>>

    Returns MiddlewareFn<C>

Static privateChat

Static reply

  • reply(...args: [text: string, extra?: Pick<{}, "parse_mode" | "entities" | "disable_web_page_preview" | "disable_notification" | "reply_to_message_id" | "allow_sending_without_reply" | "reply_markup">]): MiddlewareFn<Context>
  • Parameters

    • Rest ...args: [text: string, extra?: Pick<{}, "parse_mode" | "entities" | "disable_web_page_preview" | "disable_notification" | "reply_to_message_id" | "allow_sending_without_reply" | "reply_markup">]

    Returns MiddlewareFn<Context>

Static tap

Static textLink

  • textLink<C>(link: MaybeArray<string>, ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"channel_post", object> | Record<"message", object>>>>): MiddlewareFn<C>
  • Type parameters

    Parameters

    • link: MaybeArray<string>
    • Rest ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"channel_post", object> | Record<"message", object>>>>

    Returns MiddlewareFn<C>

Static textMention

  • textMention<C>(mention: MaybeArray<string>, ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"channel_post", object> | Record<"message", object>>>>): MiddlewareFn<C>

Static unwrap

Static url

  • url<C>(url: MaybeArray<string>, ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"channel_post", object> | Record<"message", object>>>>): MiddlewareFn<C>
  • Type parameters

    Parameters

    • url: MaybeArray<string>
    • Rest ...fns: NonemptyReadonlyArray<Middleware<GuardedContext<C & { match: RegExpExecArray }, Record<"channel_post", object> | Record<"message", object>>>>

    Returns MiddlewareFn<C>

Generated using TypeDoc