balebaazoo 1.2.3 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -212,9 +212,12 @@ interface Transaction {
212
212
  id: string;
213
213
  status: string;
214
214
  amount: number;
215
- currency: string;
216
- created_at: number;
217
- updated_at: number;
215
+ userID?: number;
216
+ createdAt?: number;
217
+ /** @deprecated Bale API uses createdAt */
218
+ created_at?: number;
219
+ currency?: string;
220
+ updated_at?: number;
218
221
  }
219
222
  interface InlineKeyboardButton {
220
223
  text: string;
@@ -525,7 +528,9 @@ interface AnswerPreCheckoutQueryParams {
525
528
  error_message?: string;
526
529
  }
527
530
  interface InquireTransactionParams {
528
- provider_payment_charge_id: string;
531
+ transaction_id?: string;
532
+ /** @deprecated Use transaction_id */
533
+ provider_payment_charge_id?: string;
529
534
  }
530
535
  type ApiMethodResultMap = {
531
536
  getMe: User;
@@ -678,6 +683,8 @@ declare class Context {
678
683
  readonly botInfo?: User;
679
684
  callbackQueryAnswered: boolean;
680
685
  private _updateTypes?;
686
+ session: Record<string, unknown>;
687
+ state: Record<string, unknown>;
681
688
  constructor(options: ContextOptions);
682
689
  get updateId(): number;
683
690
  get updateTypes(): string[];
@@ -701,6 +708,11 @@ declare class Context {
701
708
  replyWithLocation(latitude: number, longitude: number, extra?: Omit<SendLocationParams, "chat_id" | "latitude" | "longitude">): Promise<Message>;
702
709
  replyWithContact(phoneNumber: string, firstName: string, extra?: Omit<SendContactParams, "chat_id" | "phone_number" | "first_name">): Promise<Message>;
703
710
  replyWithInvoice(params: Omit<SendInvoiceParams, "chat_id">): Promise<Message>;
711
+ targetMessage(): Message | undefined;
712
+ editMessageText(text: string, extra?: Omit<EditMessageTextParams, "chat_id" | "message_id" | "text">): Promise<Message>;
713
+ deleteMessage(params?: Partial<Pick<DeleteMessageParams, "chat_id" | "message_id">>): Promise<boolean>;
714
+ forwardMessage(toChatId: CopyMessageParams["chat_id"], params?: Omit<ForwardMessageParams, "chat_id">): Promise<Message>;
715
+ copyMessage(toChatId: CopyMessageParams["chat_id"], params?: Omit<CopyMessageParams, "chat_id">): Promise<MessageId>;
704
716
  sendChatAction(action: ChatAction): Promise<boolean>;
705
717
  answerCallbackQuery(params?: Omit<AnswerCallbackQueryParams, "callback_query_id">): Promise<boolean>;
706
718
  answerPreCheckoutQuery(params: Omit<AnswerPreCheckoutQueryParams, "pre_checkout_query_id">): Promise<boolean>;
@@ -731,7 +743,7 @@ declare function extractCommand(text: string): {
731
743
  args: string;
732
744
  } | null;
733
745
 
734
- type FilterQuery = "message" | "message:text" | "message:photo" | "message:document" | "message:voice" | "message:audio" | "message:video" | "message:location" | "message:contact" | "message:sticker" | "message:command" | "message:successful_payment" | "message:web_app_data" | "edited_message" | "edited_message:text" | "callback_query" | "callback_query:data" | "pre_checkout_query";
746
+ type FilterQuery = "message" | "message:text" | "message:photo" | "message:document" | "message:voice" | "message:audio" | "message:video" | "message:animation" | "message:new_chat_members" | "message:left_chat_member" | "message:location" | "message:contact" | "message:sticker" | "message:command" | "message:successful_payment" | "message:web_app_data" | "edited_message" | "edited_message:text" | "callback_query" | "callback_query:data" | "pre_checkout_query";
735
747
  type FilterContext<Q extends FilterQuery> = Q extends "message" ? Context & {
736
748
  message: NonNullable<Context["message"]>;
737
749
  } : Q extends "message:text" ? Context & {
@@ -752,9 +764,12 @@ declare function matchesAnyFilter(ctx: Context, filters: FilterQuery[]): boolean
752
764
  declare function matchesChatType(ctx: Context, chatType: Chat["type"] | Chat["type"][]): boolean;
753
765
 
754
766
  declare class Composer<C extends Context = Context> {
755
- private readonly handler;
756
767
  private readonly registered;
768
+ private dirty;
769
+ private snapshot;
770
+ private cachedHandler?;
757
771
  constructor(...middleware: MiddlewareLike<C>[]);
772
+ private markDirty;
758
773
  middleware(): Middleware<C>;
759
774
  use(...middleware: MiddlewareLike<C>[]): this;
760
775
  on(filter: FilterQuery | FilterQuery[], ...middleware: Middleware<C>[]): this;
@@ -762,6 +777,7 @@ declare class Composer<C extends Context = Context> {
762
777
  command(command: string | string[], ...middleware: Middleware<C>[]): this;
763
778
  hears(pattern: string | RegExp, ...middleware: Middleware<C>[]): this;
764
779
  chatType(chatType: Chat["type"] | Chat["type"][], ...middleware: Middleware<C>[]): this;
780
+ static compose<C extends Context>(...composers: Array<Composer<C> | MiddlewareLike<C>>): Composer<C>;
765
781
  }
766
782
 
767
783
  interface PollingBot {
@@ -773,6 +789,7 @@ interface PollingOptions {
773
789
  limit?: number;
774
790
  timeout?: number;
775
791
  allowedUpdates?: string[];
792
+ concurrency?: number;
776
793
  dropPendingUpdates?: boolean;
777
794
  onStart?: (botInfo: User) => void | Promise<void>;
778
795
  onError?: (error: unknown) => void;
@@ -791,6 +808,7 @@ declare class PollingRunner {
791
808
  private backoffAttempt;
792
809
  start(bot: PollingBot, options?: PollingOptions): Promise<void>;
793
810
  private runLoop;
811
+ private processUpdates;
794
812
  setOffset(offset: number): void;
795
813
  stop(): Promise<void>;
796
814
  }
@@ -804,17 +822,20 @@ interface BotOptions extends ApiClientOptions {
804
822
 
805
823
  declare class Bot<C extends Context = Context> extends Composer<C> {
806
824
  readonly api: Api;
807
- private botInfo?;
825
+ private _botInfo?;
808
826
  private readonly polling;
809
827
  private readonly autoAnswer;
810
828
  private catchHandler?;
811
829
  constructor(token: string, options?: Omit<BotOptions, "token">);
830
+ get telegram(): Api;
831
+ get botInfo(): User | undefined;
812
832
  init(): Promise<User>;
813
833
  catch(handler: (error: unknown, ctx: C) => void | Promise<void>): this;
814
834
  handleUpdate(update: Update): Promise<void>;
815
835
  createContext(update: Update): Context;
816
836
  start(options?: PollingOptions): Promise<void>;
817
837
  launch(options?: PollingOptions): Promise<void>;
838
+ switchToPolling(options?: PollingOptions): Promise<void>;
818
839
  stop(): Promise<void>;
819
840
  webhookCallback(): (update: Update) => Promise<void>;
820
841
  use(...middleware: MiddlewareLike<C>[]): this;
@@ -881,4 +902,43 @@ interface GracefulShutdownOptions {
881
902
  }
882
903
  declare function setupGracefulShutdown(bot: Bot, options?: GracefulShutdownOptions): void;
883
904
 
884
- export { type AddStickerToSetParams, type Animation, type AnswerCallbackQueryParams, type AnswerPreCheckoutQueryParams, Api, type ApiClientOptions, type ApiMethod, type ApiMethodResultMap, type AskReviewParams, type Audio, BaleAPIError, type BaleApiResponse, BaleError, BaleNetworkError, type BanChatMemberParams, Bot, type BotOptions, type CallOptions, type CallbackQuery, type Chat, type ChatAction, type ChatFullInfo, type ChatId, type ChatMember, type ChatMemberAdministrator, type ChatMemberMember, type ChatMemberOwner, type ChatMemberRestricted, type ChatPhoto, Composer, type Contact, Context, type ContextOptions, type CopyMessageParams, type CopyTextButton, type CreateChatInviteLinkParams, type CreateInvoiceLinkParams, type CreateNewStickerSetParams, DEFAULT_API_BASE, type DeleteMessageParams, type Document, type EditMessageCaptionParams, type EditMessageReplyMarkupParams, type EditMessageTextParams, type File, type FilterContext, type FilterQuery, type ForwardMessageParams, type GetChatMemberParams, type GetChatParams, type GetFileParams, type GetUpdatesParams, type GracefulShutdownOptions, InlineKeyboard, type InlineKeyboardButton, type InlineKeyboardMarkup, InputFile, type InputMedia, type InputMediaAnimation, type InputMediaAudio, type InputMediaDocument, type InputMediaPhoto, type InputMediaVideo, type InputSticker, type InquireTransactionParams, type Invoice, type KeyboardButton, type LabeledPrice, type LeaveChatParams, type Location, type Message, type MessageEntity, type MessageId, type Middleware, type MiddlewareLike, type MiddlewareObject, type NextFunction, type PhotoSize, type PinChatMessageParams, type PollingBot, type PollingOptions, PollingRunner, type PreCheckoutQuery, type PromoteChatMemberParams, ReplyKeyboard, type ReplyKeyboardMarkup, type ReplyKeyboardRemove, type ReplyMarkup, type ReplyOptions, type ResponseParameters, type RevokeChatInviteLinkParams, type SendAnimationParams, type SendAudioParams, type SendChatActionParams, type SendContactParams, type SendDocumentParams, type SendInvoiceParams, type SendLocationParams, type SendMediaGroupParams, type SendMediaParams, type SendMessageParams, type SendPhotoParams, type SendVideoParams, type SendVoiceParams, type SetChatDescriptionParams, type SetChatPhotoParams, type SetChatTitleParams, type SetWebhookParams, type Sticker, type StickerSet, type SuccessfulPayment, type Transaction, type UnbanChatMemberParams, type Update, type UploadStickerFileParams, type User, type UserId, type Video, type Voice, type WebAppData, type WebAppInfo, type WebhookHandlerOptions, type WebhookInfo, autoAnswerCallback, bold, createWebhookHandler, errorHandler, extractCommand, isFilePath, isMiddlewareObject, italic, link, matchUpdate, matchesAnyFilter, matchesChatType, matchesFilter, md, normalizeMiddleware, removeKeyboard, runMiddleware, setupGracefulShutdown, spoiler, webhookFromJson };
905
+ interface SceneSessionState {
906
+ id?: string;
907
+ step?: number;
908
+ }
909
+ declare class Scene<C extends Context = Context> extends Composer<C> {
910
+ readonly id: string;
911
+ private readonly enterMiddleware;
912
+ private readonly leaveMiddleware;
913
+ constructor(id: string, ...middleware: Middleware<C>[]);
914
+ enter(...middleware: Middleware<C>[]): this;
915
+ leave(...middleware: Middleware<C>[]): this;
916
+ runEnter(ctx: C): Promise<void>;
917
+ runLeave(ctx: C): Promise<void>;
918
+ }
919
+ declare class Stage<C extends Context = Context> extends Composer<C> {
920
+ private readonly scenes;
921
+ register(...scenes: Scene<C>[]): this;
922
+ getScene(id: string): Scene<C> | undefined;
923
+ enter(ctx: C, sceneId: string, state?: SceneSessionState): Promise<void>;
924
+ leave(ctx: C): Promise<void>;
925
+ middleware(): Middleware<C>;
926
+ }
927
+ declare function enterScene<C extends Context>(ctx: C, sceneId: string, scene: Scene<C>, initialState?: SceneSessionState): Promise<void>;
928
+ declare function leaveScene<C extends Context>(ctx: C, scene: Scene<C>): Promise<void>;
929
+
930
+ interface SessionStore<T> {
931
+ get(key: string): T | undefined;
932
+ set(key: string, value: T): void;
933
+ delete(key: string): void;
934
+ }
935
+ declare function memorySessionStore<T>(): SessionStore<T>;
936
+
937
+ interface SessionOptions<T extends object, C extends Context = Context> {
938
+ getSessionKey: (ctx: C) => string | undefined;
939
+ store?: SessionStore<T>;
940
+ defaultSession: (ctx: C) => T;
941
+ }
942
+ declare function session<T extends object, C extends Context = Context>(options: SessionOptions<T, C>): Middleware<C>;
943
+
944
+ export { type AddStickerToSetParams, type Animation, type AnswerCallbackQueryParams, type AnswerPreCheckoutQueryParams, Api, type ApiClientOptions, type ApiMethod, type ApiMethodResultMap, type AskReviewParams, type Audio, BaleAPIError, type BaleApiResponse, BaleError, BaleNetworkError, type BanChatMemberParams, Bot, type BotOptions, type CallOptions, type CallbackQuery, type Chat, type ChatAction, type ChatFullInfo, type ChatId, type ChatMember, type ChatMemberAdministrator, type ChatMemberMember, type ChatMemberOwner, type ChatMemberRestricted, type ChatPhoto, Composer, type Contact, Context, type ContextOptions, type CopyMessageParams, type CopyTextButton, type CreateChatInviteLinkParams, type CreateInvoiceLinkParams, type CreateNewStickerSetParams, DEFAULT_API_BASE, type DeleteMessageParams, type Document, type EditMessageCaptionParams, type EditMessageReplyMarkupParams, type EditMessageTextParams, type File, type FilterContext, type FilterQuery, type ForwardMessageParams, type GetChatMemberParams, type GetChatParams, type GetFileParams, type GetUpdatesParams, type GracefulShutdownOptions, InlineKeyboard, type InlineKeyboardButton, type InlineKeyboardMarkup, InputFile, type InputMedia, type InputMediaAnimation, type InputMediaAudio, type InputMediaDocument, type InputMediaPhoto, type InputMediaVideo, type InputSticker, type InquireTransactionParams, type Invoice, type KeyboardButton, type LabeledPrice, type LeaveChatParams, type Location, type Message, type MessageEntity, type MessageId, type Middleware, type MiddlewareLike, type MiddlewareObject, type NextFunction, type PhotoSize, type PinChatMessageParams, type PollingBot, type PollingOptions, PollingRunner, type PreCheckoutQuery, type PromoteChatMemberParams, ReplyKeyboard, type ReplyKeyboardMarkup, type ReplyKeyboardRemove, type ReplyMarkup, type ReplyOptions, type ResponseParameters, type RevokeChatInviteLinkParams, Scene, type SceneSessionState, type SendAnimationParams, type SendAudioParams, type SendChatActionParams, type SendContactParams, type SendDocumentParams, type SendInvoiceParams, type SendLocationParams, type SendMediaGroupParams, type SendMediaParams, type SendMessageParams, type SendPhotoParams, type SendVideoParams, type SendVoiceParams, type SessionOptions, type SessionStore, type SetChatDescriptionParams, type SetChatPhotoParams, type SetChatTitleParams, type SetWebhookParams, Stage, type Sticker, type StickerSet, type SuccessfulPayment, type Transaction, type UnbanChatMemberParams, type Update, type UploadStickerFileParams, type User, type UserId, type Video, type Voice, type WebAppData, type WebAppInfo, type WebhookHandlerOptions, type WebhookInfo, autoAnswerCallback, bold, createWebhookHandler, enterScene, errorHandler, extractCommand, isFilePath, isMiddlewareObject, italic, leaveScene, link, matchUpdate, matchesAnyFilter, matchesChatType, matchesFilter, md, memorySessionStore, normalizeMiddleware, removeKeyboard, runMiddleware, session, setupGracefulShutdown, spoiler, webhookFromJson };
package/dist/index.d.ts CHANGED
@@ -212,9 +212,12 @@ interface Transaction {
212
212
  id: string;
213
213
  status: string;
214
214
  amount: number;
215
- currency: string;
216
- created_at: number;
217
- updated_at: number;
215
+ userID?: number;
216
+ createdAt?: number;
217
+ /** @deprecated Bale API uses createdAt */
218
+ created_at?: number;
219
+ currency?: string;
220
+ updated_at?: number;
218
221
  }
219
222
  interface InlineKeyboardButton {
220
223
  text: string;
@@ -525,7 +528,9 @@ interface AnswerPreCheckoutQueryParams {
525
528
  error_message?: string;
526
529
  }
527
530
  interface InquireTransactionParams {
528
- provider_payment_charge_id: string;
531
+ transaction_id?: string;
532
+ /** @deprecated Use transaction_id */
533
+ provider_payment_charge_id?: string;
529
534
  }
530
535
  type ApiMethodResultMap = {
531
536
  getMe: User;
@@ -678,6 +683,8 @@ declare class Context {
678
683
  readonly botInfo?: User;
679
684
  callbackQueryAnswered: boolean;
680
685
  private _updateTypes?;
686
+ session: Record<string, unknown>;
687
+ state: Record<string, unknown>;
681
688
  constructor(options: ContextOptions);
682
689
  get updateId(): number;
683
690
  get updateTypes(): string[];
@@ -701,6 +708,11 @@ declare class Context {
701
708
  replyWithLocation(latitude: number, longitude: number, extra?: Omit<SendLocationParams, "chat_id" | "latitude" | "longitude">): Promise<Message>;
702
709
  replyWithContact(phoneNumber: string, firstName: string, extra?: Omit<SendContactParams, "chat_id" | "phone_number" | "first_name">): Promise<Message>;
703
710
  replyWithInvoice(params: Omit<SendInvoiceParams, "chat_id">): Promise<Message>;
711
+ targetMessage(): Message | undefined;
712
+ editMessageText(text: string, extra?: Omit<EditMessageTextParams, "chat_id" | "message_id" | "text">): Promise<Message>;
713
+ deleteMessage(params?: Partial<Pick<DeleteMessageParams, "chat_id" | "message_id">>): Promise<boolean>;
714
+ forwardMessage(toChatId: CopyMessageParams["chat_id"], params?: Omit<ForwardMessageParams, "chat_id">): Promise<Message>;
715
+ copyMessage(toChatId: CopyMessageParams["chat_id"], params?: Omit<CopyMessageParams, "chat_id">): Promise<MessageId>;
704
716
  sendChatAction(action: ChatAction): Promise<boolean>;
705
717
  answerCallbackQuery(params?: Omit<AnswerCallbackQueryParams, "callback_query_id">): Promise<boolean>;
706
718
  answerPreCheckoutQuery(params: Omit<AnswerPreCheckoutQueryParams, "pre_checkout_query_id">): Promise<boolean>;
@@ -731,7 +743,7 @@ declare function extractCommand(text: string): {
731
743
  args: string;
732
744
  } | null;
733
745
 
734
- type FilterQuery = "message" | "message:text" | "message:photo" | "message:document" | "message:voice" | "message:audio" | "message:video" | "message:location" | "message:contact" | "message:sticker" | "message:command" | "message:successful_payment" | "message:web_app_data" | "edited_message" | "edited_message:text" | "callback_query" | "callback_query:data" | "pre_checkout_query";
746
+ type FilterQuery = "message" | "message:text" | "message:photo" | "message:document" | "message:voice" | "message:audio" | "message:video" | "message:animation" | "message:new_chat_members" | "message:left_chat_member" | "message:location" | "message:contact" | "message:sticker" | "message:command" | "message:successful_payment" | "message:web_app_data" | "edited_message" | "edited_message:text" | "callback_query" | "callback_query:data" | "pre_checkout_query";
735
747
  type FilterContext<Q extends FilterQuery> = Q extends "message" ? Context & {
736
748
  message: NonNullable<Context["message"]>;
737
749
  } : Q extends "message:text" ? Context & {
@@ -752,9 +764,12 @@ declare function matchesAnyFilter(ctx: Context, filters: FilterQuery[]): boolean
752
764
  declare function matchesChatType(ctx: Context, chatType: Chat["type"] | Chat["type"][]): boolean;
753
765
 
754
766
  declare class Composer<C extends Context = Context> {
755
- private readonly handler;
756
767
  private readonly registered;
768
+ private dirty;
769
+ private snapshot;
770
+ private cachedHandler?;
757
771
  constructor(...middleware: MiddlewareLike<C>[]);
772
+ private markDirty;
758
773
  middleware(): Middleware<C>;
759
774
  use(...middleware: MiddlewareLike<C>[]): this;
760
775
  on(filter: FilterQuery | FilterQuery[], ...middleware: Middleware<C>[]): this;
@@ -762,6 +777,7 @@ declare class Composer<C extends Context = Context> {
762
777
  command(command: string | string[], ...middleware: Middleware<C>[]): this;
763
778
  hears(pattern: string | RegExp, ...middleware: Middleware<C>[]): this;
764
779
  chatType(chatType: Chat["type"] | Chat["type"][], ...middleware: Middleware<C>[]): this;
780
+ static compose<C extends Context>(...composers: Array<Composer<C> | MiddlewareLike<C>>): Composer<C>;
765
781
  }
766
782
 
767
783
  interface PollingBot {
@@ -773,6 +789,7 @@ interface PollingOptions {
773
789
  limit?: number;
774
790
  timeout?: number;
775
791
  allowedUpdates?: string[];
792
+ concurrency?: number;
776
793
  dropPendingUpdates?: boolean;
777
794
  onStart?: (botInfo: User) => void | Promise<void>;
778
795
  onError?: (error: unknown) => void;
@@ -791,6 +808,7 @@ declare class PollingRunner {
791
808
  private backoffAttempt;
792
809
  start(bot: PollingBot, options?: PollingOptions): Promise<void>;
793
810
  private runLoop;
811
+ private processUpdates;
794
812
  setOffset(offset: number): void;
795
813
  stop(): Promise<void>;
796
814
  }
@@ -804,17 +822,20 @@ interface BotOptions extends ApiClientOptions {
804
822
 
805
823
  declare class Bot<C extends Context = Context> extends Composer<C> {
806
824
  readonly api: Api;
807
- private botInfo?;
825
+ private _botInfo?;
808
826
  private readonly polling;
809
827
  private readonly autoAnswer;
810
828
  private catchHandler?;
811
829
  constructor(token: string, options?: Omit<BotOptions, "token">);
830
+ get telegram(): Api;
831
+ get botInfo(): User | undefined;
812
832
  init(): Promise<User>;
813
833
  catch(handler: (error: unknown, ctx: C) => void | Promise<void>): this;
814
834
  handleUpdate(update: Update): Promise<void>;
815
835
  createContext(update: Update): Context;
816
836
  start(options?: PollingOptions): Promise<void>;
817
837
  launch(options?: PollingOptions): Promise<void>;
838
+ switchToPolling(options?: PollingOptions): Promise<void>;
818
839
  stop(): Promise<void>;
819
840
  webhookCallback(): (update: Update) => Promise<void>;
820
841
  use(...middleware: MiddlewareLike<C>[]): this;
@@ -881,4 +902,43 @@ interface GracefulShutdownOptions {
881
902
  }
882
903
  declare function setupGracefulShutdown(bot: Bot, options?: GracefulShutdownOptions): void;
883
904
 
884
- export { type AddStickerToSetParams, type Animation, type AnswerCallbackQueryParams, type AnswerPreCheckoutQueryParams, Api, type ApiClientOptions, type ApiMethod, type ApiMethodResultMap, type AskReviewParams, type Audio, BaleAPIError, type BaleApiResponse, BaleError, BaleNetworkError, type BanChatMemberParams, Bot, type BotOptions, type CallOptions, type CallbackQuery, type Chat, type ChatAction, type ChatFullInfo, type ChatId, type ChatMember, type ChatMemberAdministrator, type ChatMemberMember, type ChatMemberOwner, type ChatMemberRestricted, type ChatPhoto, Composer, type Contact, Context, type ContextOptions, type CopyMessageParams, type CopyTextButton, type CreateChatInviteLinkParams, type CreateInvoiceLinkParams, type CreateNewStickerSetParams, DEFAULT_API_BASE, type DeleteMessageParams, type Document, type EditMessageCaptionParams, type EditMessageReplyMarkupParams, type EditMessageTextParams, type File, type FilterContext, type FilterQuery, type ForwardMessageParams, type GetChatMemberParams, type GetChatParams, type GetFileParams, type GetUpdatesParams, type GracefulShutdownOptions, InlineKeyboard, type InlineKeyboardButton, type InlineKeyboardMarkup, InputFile, type InputMedia, type InputMediaAnimation, type InputMediaAudio, type InputMediaDocument, type InputMediaPhoto, type InputMediaVideo, type InputSticker, type InquireTransactionParams, type Invoice, type KeyboardButton, type LabeledPrice, type LeaveChatParams, type Location, type Message, type MessageEntity, type MessageId, type Middleware, type MiddlewareLike, type MiddlewareObject, type NextFunction, type PhotoSize, type PinChatMessageParams, type PollingBot, type PollingOptions, PollingRunner, type PreCheckoutQuery, type PromoteChatMemberParams, ReplyKeyboard, type ReplyKeyboardMarkup, type ReplyKeyboardRemove, type ReplyMarkup, type ReplyOptions, type ResponseParameters, type RevokeChatInviteLinkParams, type SendAnimationParams, type SendAudioParams, type SendChatActionParams, type SendContactParams, type SendDocumentParams, type SendInvoiceParams, type SendLocationParams, type SendMediaGroupParams, type SendMediaParams, type SendMessageParams, type SendPhotoParams, type SendVideoParams, type SendVoiceParams, type SetChatDescriptionParams, type SetChatPhotoParams, type SetChatTitleParams, type SetWebhookParams, type Sticker, type StickerSet, type SuccessfulPayment, type Transaction, type UnbanChatMemberParams, type Update, type UploadStickerFileParams, type User, type UserId, type Video, type Voice, type WebAppData, type WebAppInfo, type WebhookHandlerOptions, type WebhookInfo, autoAnswerCallback, bold, createWebhookHandler, errorHandler, extractCommand, isFilePath, isMiddlewareObject, italic, link, matchUpdate, matchesAnyFilter, matchesChatType, matchesFilter, md, normalizeMiddleware, removeKeyboard, runMiddleware, setupGracefulShutdown, spoiler, webhookFromJson };
905
+ interface SceneSessionState {
906
+ id?: string;
907
+ step?: number;
908
+ }
909
+ declare class Scene<C extends Context = Context> extends Composer<C> {
910
+ readonly id: string;
911
+ private readonly enterMiddleware;
912
+ private readonly leaveMiddleware;
913
+ constructor(id: string, ...middleware: Middleware<C>[]);
914
+ enter(...middleware: Middleware<C>[]): this;
915
+ leave(...middleware: Middleware<C>[]): this;
916
+ runEnter(ctx: C): Promise<void>;
917
+ runLeave(ctx: C): Promise<void>;
918
+ }
919
+ declare class Stage<C extends Context = Context> extends Composer<C> {
920
+ private readonly scenes;
921
+ register(...scenes: Scene<C>[]): this;
922
+ getScene(id: string): Scene<C> | undefined;
923
+ enter(ctx: C, sceneId: string, state?: SceneSessionState): Promise<void>;
924
+ leave(ctx: C): Promise<void>;
925
+ middleware(): Middleware<C>;
926
+ }
927
+ declare function enterScene<C extends Context>(ctx: C, sceneId: string, scene: Scene<C>, initialState?: SceneSessionState): Promise<void>;
928
+ declare function leaveScene<C extends Context>(ctx: C, scene: Scene<C>): Promise<void>;
929
+
930
+ interface SessionStore<T> {
931
+ get(key: string): T | undefined;
932
+ set(key: string, value: T): void;
933
+ delete(key: string): void;
934
+ }
935
+ declare function memorySessionStore<T>(): SessionStore<T>;
936
+
937
+ interface SessionOptions<T extends object, C extends Context = Context> {
938
+ getSessionKey: (ctx: C) => string | undefined;
939
+ store?: SessionStore<T>;
940
+ defaultSession: (ctx: C) => T;
941
+ }
942
+ declare function session<T extends object, C extends Context = Context>(options: SessionOptions<T, C>): Middleware<C>;
943
+
944
+ export { type AddStickerToSetParams, type Animation, type AnswerCallbackQueryParams, type AnswerPreCheckoutQueryParams, Api, type ApiClientOptions, type ApiMethod, type ApiMethodResultMap, type AskReviewParams, type Audio, BaleAPIError, type BaleApiResponse, BaleError, BaleNetworkError, type BanChatMemberParams, Bot, type BotOptions, type CallOptions, type CallbackQuery, type Chat, type ChatAction, type ChatFullInfo, type ChatId, type ChatMember, type ChatMemberAdministrator, type ChatMemberMember, type ChatMemberOwner, type ChatMemberRestricted, type ChatPhoto, Composer, type Contact, Context, type ContextOptions, type CopyMessageParams, type CopyTextButton, type CreateChatInviteLinkParams, type CreateInvoiceLinkParams, type CreateNewStickerSetParams, DEFAULT_API_BASE, type DeleteMessageParams, type Document, type EditMessageCaptionParams, type EditMessageReplyMarkupParams, type EditMessageTextParams, type File, type FilterContext, type FilterQuery, type ForwardMessageParams, type GetChatMemberParams, type GetChatParams, type GetFileParams, type GetUpdatesParams, type GracefulShutdownOptions, InlineKeyboard, type InlineKeyboardButton, type InlineKeyboardMarkup, InputFile, type InputMedia, type InputMediaAnimation, type InputMediaAudio, type InputMediaDocument, type InputMediaPhoto, type InputMediaVideo, type InputSticker, type InquireTransactionParams, type Invoice, type KeyboardButton, type LabeledPrice, type LeaveChatParams, type Location, type Message, type MessageEntity, type MessageId, type Middleware, type MiddlewareLike, type MiddlewareObject, type NextFunction, type PhotoSize, type PinChatMessageParams, type PollingBot, type PollingOptions, PollingRunner, type PreCheckoutQuery, type PromoteChatMemberParams, ReplyKeyboard, type ReplyKeyboardMarkup, type ReplyKeyboardRemove, type ReplyMarkup, type ReplyOptions, type ResponseParameters, type RevokeChatInviteLinkParams, Scene, type SceneSessionState, type SendAnimationParams, type SendAudioParams, type SendChatActionParams, type SendContactParams, type SendDocumentParams, type SendInvoiceParams, type SendLocationParams, type SendMediaGroupParams, type SendMediaParams, type SendMessageParams, type SendPhotoParams, type SendVideoParams, type SendVoiceParams, type SessionOptions, type SessionStore, type SetChatDescriptionParams, type SetChatPhotoParams, type SetChatTitleParams, type SetWebhookParams, Stage, type Sticker, type StickerSet, type SuccessfulPayment, type Transaction, type UnbanChatMemberParams, type Update, type UploadStickerFileParams, type User, type UserId, type Video, type Voice, type WebAppData, type WebAppInfo, type WebhookHandlerOptions, type WebhookInfo, autoAnswerCallback, bold, createWebhookHandler, enterScene, errorHandler, extractCommand, isFilePath, isMiddlewareObject, italic, leaveScene, link, matchUpdate, matchesAnyFilter, matchesChatType, matchesFilter, md, memorySessionStore, normalizeMiddleware, removeKeyboard, runMiddleware, session, setupGracefulShutdown, spoiler, webhookFromJson };