Options
All
  • Public
  • Public/Protected
  • All
Menu

Class WizardScene<C>

Type parameters

Hierarchy

Implements

  • MiddlewareObj<C>

Index

Constructors

constructor

Properties

enterHandler

enterHandler: MiddlewareFn<C>

id

id: string

leaveHandler

leaveHandler: MiddlewareFn<C>

steps

steps: Middleware<C>[]

Optional ttl

ttl: undefined | number

Methods

action

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

    Parameters

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

    Returns WizardScene<C>

cashtag

  • cashtag(cashtag: MaybeArray<string>, ...fns: MatchedMiddleware<C, "message" | "channel_post">): WizardScene<C>

command

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

drop

email

  • email(email: Triggers<C>, ...fns: MatchedMiddleware<C, "message" | "channel_post">): WizardScene<C>

enter

enterMiddleware

filter

gameQuery

guard

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

hashtag

  • hashtag(hashtag: MaybeArray<string>, ...fns: MatchedMiddleware<C, "message" | "channel_post">): WizardScene<C>

hears

  • hears(triggers: Triggers<C>, ...fns: MatchedMiddleware<C, "text">): WizardScene<C>
  • Registers middleware for handling matching text messages.

    Parameters

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

    Returns WizardScene<C>

help

inlineQuery

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

    Parameters

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

    Returns WizardScene<C>

leave

leaveMiddleware

mention

  • mention(mention: MaybeArray<string>, ...fns: MatchedMiddleware<C, "message" | "channel_post">): WizardScene<C>

middleware

on

  • on<T>(updateType: MaybeArray<T>, ...fns: NonemptyReadonlyArray<Middleware<MatchedContext<C, T>>>): WizardScene<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" | "forward_date" | "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" | "voice_chat_scheduled" | "voice_chat_started" | "voice_chat_ended" | "voice_chat_participants_invited" | "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 WizardScene<C>

phone

  • phone(number: Triggers<C>, ...fns: MatchedMiddleware<C, "message" | "channel_post">): WizardScene<C>

settings

start

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

textLink

  • textLink(link: Triggers<C>, ...fns: MatchedMiddleware<C, "message" | "channel_post">): WizardScene<C>

textMention

  • textMention(mention: Triggers<C>, ...fns: MatchedMiddleware<C, "message" | "channel_post">): WizardScene<C>

url

  • url(url: Triggers<C>, ...fns: MatchedMiddleware<C, "message" | "channel_post">): WizardScene<C>

use

Static acl

Static action

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

Static admin

Static branch

Static cashtag

  • cashtag<C>(cashtag: MaybeArray<string>, ...fns: MatchedMiddleware<C, "message" | "channel_post">): MiddlewareFn<C>

Static catch

Static chatType

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

Static command

  • command<C>(command: MaybeArray<string>, ...fns: NonemptyReadonlyArray<Middleware<MatchedContext<C, "text">>>): 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: Triggers<C>, ...fns: MatchedMiddleware<C, "message" | "channel_post">): MiddlewareFn<C>

Static entityText

  • entityText<C>(entityType: MaybeArray<string>, predicate: Triggers<C>, ...fns: MatchedMiddleware<C, "message" | "channel_post">): MiddlewareFn<C>

Static filter

Static fork

Static gameQuery

Static groupChat

Static guard

  • 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<NarrowedContext<C, U>>>

      middleware to run if the predicate returns true

    Returns MiddlewareFn<C>

Static hashtag

  • hashtag<C>(hashtag: MaybeArray<string>, ...fns: MatchedMiddleware<C, "message" | "channel_post">): MiddlewareFn<C>

Static hears

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

Static inlineQuery

  • inlineQuery<C>(triggers: Triggers<C>, ...fns: MatchedMiddleware<C, "inline_query">): MiddlewareFn<C>

Static lazy

Static log

Static mention

  • mention<C>(mention: MaybeArray<string>, ...fns: MatchedMiddleware<C, "message" | "channel_post">): MiddlewareFn<C>

Static mount

  • 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" | "forward_date" | "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" | "voice_chat_scheduled" | "voice_chat_started" | "voice_chat_ended" | "voice_chat_participants_invited" | "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>

Static on

  • 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" | "forward_date" | "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" | "voice_chat_scheduled" | "voice_chat_started" | "voice_chat_ended" | "voice_chat_participants_invited" | "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>

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: Triggers<C>, ...fns: MatchedMiddleware<C, "message" | "channel_post">): MiddlewareFn<C>

Static privateChat

Static reply

Static tap

Static textLink

  • textLink<C>(link: Triggers<C>, ...fns: MatchedMiddleware<C, "message" | "channel_post">): MiddlewareFn<C>

Static textMention

  • textMention<C>(mention: Triggers<C>, ...fns: MatchedMiddleware<C, "message" | "channel_post">): MiddlewareFn<C>

Static unwrap

Static url

  • url<C>(url: Triggers<C>, ...fns: MatchedMiddleware<C, "message" | "channel_post">): MiddlewareFn<C>

Generated using TypeDoc