Class Stage<C, D>

Type Parameters

Hierarchy

Constructors

Properties

options: Partial<SceneContextSceneOptions<D>>
scenes: Map<string, BaseScene<C>>
mount: {
    <Ctx, Filter>(filters, ...fns): MiddlewareFn<Ctx>;
    <Ctx, Filter>(filters, ...fns): MiddlewareFn<Ctx>;
} = Composer.on

Type declaration

    • <Ctx, Filter>(filters, ...fns): MiddlewareFn<Ctx>
    • Generates middleware for handling provided update types.

      Type Parameters

      Parameters

      • filters: MaybeArray<Filter>
      • Rest ...fns: NonemptyReadonlyArray<Middleware<FilteredContext<Ctx, Filter>>>
        Rest

      Returns MiddlewareFn<Ctx>

      Deprecated

      use Composer.on instead

    • <Ctx, Filter>(filters, ...fns): MiddlewareFn<Ctx>
    • Generates middleware for handling provided update types.

      Type Parameters

      • Ctx extends Context<Update>

      • Filter extends "text" | "sticker" | "animation" | "audio" | "document" | "photo" | "video" | "video_note" | "voice" | "callback_query" | "channel_post" | "chat_member" | "chosen_inline_result" | "edited_channel_post" | "message_reaction" | "message_reaction_count" | "edited_message" | "inline_query" | "message" | "my_chat_member" | "pre_checkout_query" | "poll_answer" | "poll" | "shipping_query" | "chat_join_request" | "chat_boost" | "removed_chat_boost" | "has_media_spoiler" | "contact" | "dice" | "location" | "new_chat_members" | "left_chat_member" | "new_chat_title" | "new_chat_photo" | "delete_chat_photo" | "group_chat_created" | "supergroup_chat_created" | "channel_chat_created" | "message_auto_delete_timer_changed" | "migrate_to_chat_id" | "migrate_from_chat_id" | "pinned_message" | "invoice" | "successful_payment" | "users_shared" | "chat_shared" | "connected_website" | "write_access_allowed" | "passport_data" | "proximity_alert_triggered" | "boost_added" | "forum_topic_created" | "forum_topic_edited" | "forum_topic_closed" | "forum_topic_reopened" | "general_forum_topic_hidden" | "general_forum_topic_unhidden" | "giveaway_created" | "giveaway" | "giveaway_winners" | "giveaway_completed" | "video_chat_scheduled" | "video_chat_started" | "video_chat_ended" | "video_chat_participants_invited" | "web_app_data" | "game" | "story" | "venue" | "forward_date"

      Parameters

      Returns MiddlewareFn<Ctx>

      Deprecated

      use Composer.on instead

Methods

  • Registers middleware for handling matching callback queries.

    Parameters

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

    Returns Stage<C, D>

  • Parameters

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

    Returns Stage<C, D>

  • Parameters

    • email: Triggers<C>
    • Rest ...fns: MatchedMiddleware<C, "channel_post" | "message">
      Rest

    Returns Stage<C, D>

  • Registers middleware for handling updates matching given type guard function.

    Type Parameters

    • U extends Update

    Parameters

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

          • update: Update

          Returns update is U

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

    Returns Stage<C, D>

    Deprecated

    use Composer::on

  • Parameters

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

    Returns Stage<C, D>

  • Registers middleware for handling matching text messages.

    Parameters

    • triggers: Triggers<NarrowedContext<C, {
          message: New & NonChannel & TextMessage;
          update_id: number;
      }>>
    • Rest ...fns: MatchedMiddleware<C, "text">
      Rest

    Returns Stage<C, D>

  • Parameters

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

    Returns Stage<C, D>

  • Registers middleware for handling updates narrowed by update types or filter queries.

    Type Parameters

    Parameters

    • filters: MaybeArray<Filter>
    • Rest ...fns: NonemptyReadonlyArray<Middleware<FilteredContext<C, Filter>>>
      Rest

    Returns Stage<C, D>

  • Registers middleware for handling updates narrowed by update types or message subtypes.

    Type Parameters

    • Filter extends "text" | "sticker" | "animation" | "audio" | "document" | "photo" | "video" | "video_note" | "voice" | "callback_query" | "channel_post" | "chat_member" | "chosen_inline_result" | "edited_channel_post" | "message_reaction" | "message_reaction_count" | "edited_message" | "inline_query" | "message" | "my_chat_member" | "pre_checkout_query" | "poll_answer" | "poll" | "shipping_query" | "chat_join_request" | "chat_boost" | "removed_chat_boost" | "has_media_spoiler" | "contact" | "dice" | "location" | "new_chat_members" | "left_chat_member" | "new_chat_title" | "new_chat_photo" | "delete_chat_photo" | "group_chat_created" | "supergroup_chat_created" | "channel_chat_created" | "message_auto_delete_timer_changed" | "migrate_to_chat_id" | "migrate_from_chat_id" | "pinned_message" | "invoice" | "successful_payment" | "users_shared" | "chat_shared" | "connected_website" | "write_access_allowed" | "passport_data" | "proximity_alert_triggered" | "boost_added" | "forum_topic_created" | "forum_topic_edited" | "forum_topic_closed" | "forum_topic_reopened" | "general_forum_topic_hidden" | "general_forum_topic_unhidden" | "giveaway_created" | "giveaway" | "giveaway_winners" | "giveaway_completed" | "video_chat_scheduled" | "video_chat_started" | "video_chat_ended" | "video_chat_participants_invited" | "web_app_data" | "game" | "story" | "venue" | "forward_date"

    Parameters

    Returns Stage<C, D>

    Deprecated

    Use filter utils instead. Support for Message subtype in Composer::on will be removed in Telegraf v5.

  • Parameters

    • number: Triggers<C>
    • Rest ...fns: MatchedMiddleware<C, "channel_post" | "message">
      Rest

    Returns Stage<C, D>

  • Parameters

    • reaction: MaybeArray<ReactionAddedOrRemoved>
    • Rest ...fns: NonemptyReadonlyArray<Middleware<Context<MessageReactionUpdate> & Omit<C, keyof Context<Update>> & {
          match: ReactionAddedOrRemoved;
      }, MessageReactionUpdate>>
      Rest

    Returns Stage<C, D>

  • Registers a middleware for handling /start

    Parameters

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

    Returns Stage<C, D>

  • Parameters

    • url: Triggers<C>
    • Rest ...fns: MatchedMiddleware<C, "channel_post" | "message">
      Rest

    Returns Stage<C, D>

  • Type Parameters

    Parameters

    • predicate: boolean | Predicate<C> | AsyncPredicate<C>
    • trueMiddleware: Middleware<C>

      middleware to run if the predicate returns true

    • falseMiddleware: Middleware<C>

      middleware to run if the predicate returns false

    Returns MiddlewareFn<C>

  • Type Parameters

    • C extends Context<Update>

    • Handlers extends Record<string | number | symbol, Middleware<C>>

    Parameters

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

          • ctx: C

          Returns MaybePromise<keyof Handlers>

    • handlers: Handlers

    Returns Middleware<C>

  • Type Parameters

    Parameters

    • Rest ...args: [sceneId: string, initialState: object, silent: boolean]
      Rest

    Returns ((ctx) => Promise<unknown>)

      • (ctx): Promise<unknown>
      • Parameters

        • ctx: C

        Returns Promise<unknown>

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

    Type Parameters

    • C extends Context<Update>

    • U extends Update

    Parameters

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

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

        • (u): u is U
        • Parameters

          • u: Update

          Returns u is U

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

      middleware to run if the predicate returns true

      Rest

    Returns MiddlewareFn<C>

    See

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

    Deprecated

    use Composer.on

  • Generates middleware for handling matching text messages.

    Type Parameters

    Parameters

    • triggers: Triggers<NarrowedContext<C, {
          message: New & NonChannel & TextMessage;
          update_id: number;
      }>>
    • Rest ...fns: MatchedMiddleware<C, "text">
      Rest

    Returns MiddlewareFn<C>

  • Generates middleware for handling updates narrowed by update types or filter queries.

    Type Parameters

    Parameters

    • filters: MaybeArray<Filter>
    • Rest ...fns: NonemptyReadonlyArray<Middleware<FilteredContext<Ctx, Filter>>>
      Rest

    Returns MiddlewareFn<Ctx>

  • Generates middleware for handling updates narrowed by update types or message subtype.

    Type Parameters

    • Ctx extends Context<Update>

    • Filter extends "text" | "sticker" | "animation" | "audio" | "document" | "photo" | "video" | "video_note" | "voice" | "callback_query" | "channel_post" | "chat_member" | "chosen_inline_result" | "edited_channel_post" | "message_reaction" | "message_reaction_count" | "edited_message" | "inline_query" | "message" | "my_chat_member" | "pre_checkout_query" | "poll_answer" | "poll" | "shipping_query" | "chat_join_request" | "chat_boost" | "removed_chat_boost" | "has_media_spoiler" | "contact" | "dice" | "location" | "new_chat_members" | "left_chat_member" | "new_chat_title" | "new_chat_photo" | "delete_chat_photo" | "group_chat_created" | "supergroup_chat_created" | "channel_chat_created" | "message_auto_delete_timer_changed" | "migrate_to_chat_id" | "migrate_from_chat_id" | "pinned_message" | "invoice" | "successful_payment" | "users_shared" | "chat_shared" | "connected_website" | "write_access_allowed" | "passport_data" | "proximity_alert_triggered" | "boost_added" | "forum_topic_created" | "forum_topic_edited" | "forum_topic_closed" | "forum_topic_reopened" | "general_forum_topic_hidden" | "general_forum_topic_unhidden" | "giveaway_created" | "giveaway" | "giveaway_winners" | "giveaway_completed" | "video_chat_scheduled" | "video_chat_started" | "video_chat_ended" | "video_chat_participants_invited" | "web_app_data" | "game" | "story" | "venue" | "forward_date"

    Parameters

    Returns MiddlewareFn<Ctx>

    Deprecated

    Use filter utils instead. Support for Message subtype in Composer.on will be removed in Telegraf v5.

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

      middleware to run if the predicate returns true

      Rest

    Returns MiddlewareFn<C>

  • Type Parameters

    Parameters

    • Rest ...args: []
      Rest

    Returns ((ctx) => undefined | Promise<unknown>)

      • (ctx): undefined | Promise<unknown>
      • Parameters

        • ctx: C

        Returns undefined | Promise<unknown>

Generated using TypeDoc