Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Context<U>

Type parameters

  • U: Deunionize<tg.Update> = tg.Update

Hierarchy

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

  • new Context<U>(update: U, tg: Telegram, botInfo: UserFromGetMe): Context<U>
  • Type parameters

    • U: (CallbackQueryUpdate & AddOptionalKeys<"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">) | (ChannelPostUpdate & AddOptionalKeys<"callback_query" | "message" | "chat_member" | "chosen_inline_result" | "edited_channel_post" | "edited_message" | "inline_query" | "my_chat_member" | "pre_checkout_query" | "poll_answer" | "poll" | "shipping_query">) | (ChatMemberUpdate & AddOptionalKeys<"callback_query" | "message" | "channel_post" | "chosen_inline_result" | "edited_channel_post" | "edited_message" | "inline_query" | "my_chat_member" | "pre_checkout_query" | "poll_answer" | "poll" | "shipping_query">) | (ChosenInlineResultUpdate & AddOptionalKeys<"callback_query" | "message" | "channel_post" | "chat_member" | "edited_channel_post" | "edited_message" | "inline_query" | "my_chat_member" | "pre_checkout_query" | "poll_answer" | "poll" | "shipping_query">) | (EditedChannelPostUpdate & AddOptionalKeys<"callback_query" | "message" | "channel_post" | "chat_member" | "chosen_inline_result" | "edited_message" | "inline_query" | "my_chat_member" | "pre_checkout_query" | "poll_answer" | "poll" | "shipping_query">) | (EditedMessageUpdate & AddOptionalKeys<"callback_query" | "message" | "channel_post" | "chat_member" | "chosen_inline_result" | "edited_channel_post" | "inline_query" | "my_chat_member" | "pre_checkout_query" | "poll_answer" | "poll" | "shipping_query">) | (InlineQueryUpdate & AddOptionalKeys<"callback_query" | "message" | "channel_post" | "chat_member" | "chosen_inline_result" | "edited_channel_post" | "edited_message" | "my_chat_member" | "pre_checkout_query" | "poll_answer" | "poll" | "shipping_query">) | (MessageUpdate & AddOptionalKeys<"callback_query" | "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">) | (MyChatMemberUpdate & AddOptionalKeys<"callback_query" | "message" | "channel_post" | "chat_member" | "chosen_inline_result" | "edited_channel_post" | "edited_message" | "inline_query" | "pre_checkout_query" | "poll_answer" | "poll" | "shipping_query">) | (PreCheckoutQueryUpdate & AddOptionalKeys<"callback_query" | "message" | "channel_post" | "chat_member" | "chosen_inline_result" | "edited_channel_post" | "edited_message" | "inline_query" | "my_chat_member" | "poll_answer" | "poll" | "shipping_query">) | (PollAnswerUpdate & AddOptionalKeys<"callback_query" | "message" | "channel_post" | "chat_member" | "chosen_inline_result" | "edited_channel_post" | "edited_message" | "inline_query" | "my_chat_member" | "pre_checkout_query" | "poll" | "shipping_query">) | (PollUpdate & AddOptionalKeys<"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" | "shipping_query">) | (ShippingQueryUpdate & AddOptionalKeys<"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">) = Update

    Parameters

    • update: U
    • tg: Telegram
    • botInfo: UserFromGetMe

    Returns Context<U>

Properties

Readonly botInfo

botInfo: UserFromGetMe

Readonly state

state: Record<string | symbol, any> = ...

Readonly tg

Readonly update

update: U

Accessors

callbackQuery

  • get callbackQuery(): PropOr<U, "callback_query", undefined>
  • Returns PropOr<U, "callback_query", undefined>

channelPost

  • get channelPost(): PropOr<U, "channel_post", undefined>
  • Returns PropOr<U, "channel_post", undefined>

chat

  • get chat(): PropOr<GetUpdateContent<U>, "chat", undefined>
  • Returns PropOr<GetUpdateContent<U>, "chat", undefined>

chatMember

  • get chatMember(): PropOr<U, "chat_member", undefined>
  • Returns PropOr<U, "chat_member", undefined>

chosenInlineResult

  • get chosenInlineResult(): PropOr<U, "chosen_inline_result", undefined>
  • Returns PropOr<U, "chosen_inline_result", undefined>

editedChannelPost

  • get editedChannelPost(): PropOr<U, "edited_channel_post", undefined>
  • Returns PropOr<U, "edited_channel_post", undefined>

editedMessage

  • get editedMessage(): PropOr<U, "edited_message", undefined>
  • Returns PropOr<U, "edited_message", undefined>

from

  • get from(): PropOr<GetUpdateContent<U>, "from", undefined>
  • Returns PropOr<GetUpdateContent<U>, "from", undefined>

inlineMessageId

  • get inlineMessageId(): undefined | string

inlineQuery

  • get inlineQuery(): PropOr<U, "inline_query", undefined>
  • Returns PropOr<U, "inline_query", undefined>

me

  • get me(): string

message

  • get message(): PropOr<U, "message", undefined>
  • Returns PropOr<U, "message", undefined>

myChatMember

  • get myChatMember(): PropOr<U, "my_chat_member", undefined>
  • Returns PropOr<U, "my_chat_member", undefined>

passportData

  • get passportData(): undefined | PassportData

poll

  • get poll(): PropOr<U, "poll", undefined>

pollAnswer

  • get pollAnswer(): PropOr<U, "poll_answer", undefined>
  • Returns PropOr<U, "poll_answer", undefined>

preCheckoutQuery

  • get preCheckoutQuery(): PropOr<U, "pre_checkout_query", undefined>
  • Returns PropOr<U, "pre_checkout_query", undefined>

senderChat

  • get senderChat(): PropOr<GetUpdateContent<U>, "sender_chat", undefined>
  • Returns PropOr<GetUpdateContent<U>, "sender_chat", undefined>

shippingQuery

  • get shippingQuery(): PropOr<U, "shipping_query", undefined>
  • Returns PropOr<U, "shipping_query", undefined>

telegram

updateType

  • get updateType(): Extract<UnionKeys<U>, UpdateType>

webhookReply

  • get webhookReply(): boolean
  • set webhookReply(enable: boolean): void
  • deprecated

    use ctx.telegram.webhookReply

    Returns boolean

  • Parameters

    • enable: boolean

    Returns void

Methods

addStickerToSet

answerCbQuery

answerGameQuery

  • answerGameQuery(...args: [url: string]): Promise<true>
  • Parameters

    • Rest ...args: [url: string]

    Returns Promise<true>

answerInlineQuery

  • answerInlineQuery(...args: [results: readonly InlineQueryResult[], extra?: ExtraAnswerInlineQuery]): Promise<true>

answerPreCheckoutQuery

  • answerPreCheckoutQuery(...args: [ok: boolean, errorMessage?: string]): Promise<true>
  • Parameters

    • Rest ...args: [ok: boolean, errorMessage?: string]

    Returns Promise<true>

answerShippingQuery

  • answerShippingQuery(...args: [ok: boolean, shippingOptions: readonly ShippingOption[], errorMessage: string]): Promise<true>
  • Parameters

    • Rest ...args: [ok: boolean, shippingOptions: readonly ShippingOption[], errorMessage: string]

    Returns Promise<true>

Private assert

  • assert<T>(value: undefined | T, method: string): asserts value is T
  • Type parameters

    • T: string | object

    Parameters

    • value: undefined | T
    • method: string

    Returns asserts value is T

copyMessage

  • copyMessage(chatId: string | number, extra?: ExtraCopyMessage): Promise<MessageId>

createChatInviteLink

createNewStickerSet

deleteChatPhoto

  • deleteChatPhoto(...args: []): Promise<true>
  • Parameters

    • Rest ...args: []

    Returns Promise<true>

deleteChatStickerSet

  • deleteChatStickerSet(): Promise<true>

deleteMessage

  • deleteMessage(messageId?: number): Promise<true>
  • Parameters

    • Optional messageId: number

    Returns Promise<true>

deleteStickerFromSet

  • deleteStickerFromSet(sticker: string): Promise<true>
  • Parameters

    • sticker: string

    Returns Promise<true>

editChatInviteLink

editMessageCaption

  • editMessageCaption(caption: undefined | string, extra?: ExtraEditMessageCaption): Promise<true | (Edited & CaptionableMessage)>

editMessageLiveLocation

  • editMessageLiveLocation(latitude: number, longitude: number, extra?: ExtraEditMessageLiveLocation): Promise<true | (Edited & LocationMessage)>

editMessageMedia

  • editMessageMedia(media: {} | {} | {} | {} | {}, extra?: ExtraEditMessageMedia): Promise<true | (Edited & AnimationMessage) | (Edited & AudioMessage) | (Edited & DocumentMessage) | (Edited & PhotoMessage) | (Edited & VideoMessage)>
  • Parameters

    Returns Promise<true | (Edited & AnimationMessage) | (Edited & AudioMessage) | (Edited & DocumentMessage) | (Edited & PhotoMessage) | (Edited & VideoMessage)>

editMessageReplyMarkup

  • editMessageReplyMarkup(markup: undefined | InlineKeyboardMarkup): Promise<true | (Edited & ServiceMessageBundle | CommonMessageBundle)>
  • Parameters

    • markup: undefined | InlineKeyboardMarkup

    Returns Promise<true | (Edited & ServiceMessageBundle | CommonMessageBundle)>

editMessageText

  • editMessageText(text: string, extra?: ExtraEditMessageText): Promise<true | (Edited & TextMessage)>

exportChatInviteLink

  • exportChatInviteLink(...args: []): Promise<string>
  • Parameters

    • Rest ...args: []

    Returns Promise<string>

forwardMessage

  • forwardMessage(chatId: string | number, extra?: { disable_notification?: undefined | boolean }): Promise<ServiceMessageBundle | CommonMessageBundle>
  • Parameters

    • chatId: string | number
    • Optional extra: { disable_notification?: undefined | boolean }
      • Optional disable_notification?: undefined | boolean

    Returns Promise<ServiceMessageBundle | CommonMessageBundle>

getChat

  • getChat(...args: []): Promise<ChatFromGetChat>
  • Parameters

    • Rest ...args: []

    Returns Promise<ChatFromGetChat>

getChatAdministrators

  • getChatAdministrators(...args: []): Promise<ChatMember[]>
  • Parameters

    • Rest ...args: []

    Returns Promise<ChatMember[]>

getChatMember

  • getChatMember(...args: [userId: number]): Promise<ChatMember>
  • Parameters

    • Rest ...args: [userId: number]

    Returns Promise<ChatMember>

getChatMembersCount

  • getChatMembersCount(...args: []): Promise<number>
  • Parameters

    • Rest ...args: []

    Returns Promise<number>

getMyCommands

  • getMyCommands(): Promise<BotCommand[]>

getStickerSet

  • getStickerSet(setName: string): Promise<StickerSet>
  • Parameters

    • setName: string

    Returns Promise<StickerSet>

kickChatMember

  • kickChatMember(...args: [userId: number, untilDate?: number, extra?: ExtraKickChatMember]): Promise<true>

leaveChat

  • leaveChat(...args: []): Promise<true>
  • Parameters

    • Rest ...args: []

    Returns Promise<true>

pinChatMessage

  • pinChatMessage(...args: [messageId: number, extra?: { disable_notification?: undefined | boolean }]): Promise<true>
  • Parameters

    • Rest ...args: [messageId: number, extra?: { disable_notification?: undefined | boolean }]

    Returns Promise<true>

promoteChatMember

reply

replyWithAnimation

  • replyWithAnimation(...args: [animation: string | InputFile, extra?: ExtraAnimation]): Promise<AnimationMessage>
  • Parameters

    • Rest ...args: [animation: string | InputFile, extra?: ExtraAnimation]

    Returns Promise<AnimationMessage>

replyWithAudio

  • replyWithAudio(...args: [audio: string | InputFile, extra?: ExtraAudio]): Promise<AudioMessage>
  • Parameters

    • Rest ...args: [audio: string | InputFile, extra?: ExtraAudio]

    Returns Promise<AudioMessage>

replyWithChatAction

  • replyWithChatAction(...args: [action: "typing" | "upload_photo" | "record_video" | "upload_video" | "record_voice" | "upload_voice" | "upload_document" | "find_location" | "record_video_note" | "upload_video_note"]): Promise<true>
  • Parameters

    • Rest ...args: [action: "typing" | "upload_photo" | "record_video" | "upload_video" | "record_voice" | "upload_voice" | "upload_document" | "find_location" | "record_video_note" | "upload_video_note"]

    Returns Promise<true>

replyWithContact

  • replyWithContact(...args: [phoneNumber: string, firstName: string, extra?: ExtraContact]): Promise<ContactMessage>
  • Parameters

    • Rest ...args: [phoneNumber: string, firstName: string, extra?: ExtraContact]

    Returns Promise<ContactMessage>

replyWithDice

  • replyWithDice(...args: [extra?: ExtraDice]): Promise<DiceMessage>

replyWithDocument

  • replyWithDocument(...args: [document: string | InputFile, extra?: ExtraDocument]): Promise<DocumentMessage>
  • Parameters

    • Rest ...args: [document: string | InputFile, extra?: ExtraDocument]

    Returns Promise<DocumentMessage>

replyWithGame

  • replyWithGame(...args: [gameName: string, extra?: ExtraGame]): Promise<GameMessage>
  • Parameters

    • Rest ...args: [gameName: string, extra?: ExtraGame]

    Returns Promise<GameMessage>

replyWithHTML

replyWithInvoice

replyWithLocation

  • replyWithLocation(...args: [latitude: number, longitude: number, extra?: ExtraLocation]): Promise<LocationMessage>
  • Parameters

    • Rest ...args: [latitude: number, longitude: number, extra?: ExtraLocation]

    Returns Promise<LocationMessage>

replyWithMarkdown

  • replyWithMarkdown(markdown: string, extra?: ExtraReplyMessage): Promise<TextMessage>

replyWithMarkdownV2

  • replyWithMarkdownV2(markdown: string, extra?: ExtraReplyMessage): Promise<TextMessage>

replyWithMediaGroup

  • replyWithMediaGroup(...args: [media: readonly ({} | {})[] | readonly {}[] | readonly {}[], extra?: ExtraMediaGroup]): Promise<(DocumentMessage | AudioMessage | PhotoMessage | VideoMessage)[]>
  • Parameters

    • Rest ...args: [media: readonly ({} | {})[] | readonly {}[] | readonly {}[], extra?: ExtraMediaGroup]

    Returns Promise<(DocumentMessage | AudioMessage | PhotoMessage | VideoMessage)[]>

replyWithPhoto

  • replyWithPhoto(...args: [photo: string | InputFile, extra?: ExtraPhoto]): Promise<PhotoMessage>
  • Parameters

    • Rest ...args: [photo: string | InputFile, extra?: ExtraPhoto]

    Returns Promise<PhotoMessage>

replyWithPoll

  • replyWithPoll(...args: [question: string, options: readonly string[], extra?: ExtraPoll]): Promise<PollMessage>
  • Parameters

    • Rest ...args: [question: string, options: readonly string[], extra?: ExtraPoll]

    Returns Promise<PollMessage>

replyWithQuiz

  • replyWithQuiz(...args: [question: string, options: readonly string[], extra: ExtraPoll]): Promise<PollMessage>
  • Parameters

    • Rest ...args: [question: string, options: readonly string[], extra: ExtraPoll]

    Returns Promise<PollMessage>

replyWithSticker

  • replyWithSticker(...args: [sticker: string | InputFile, extra?: ExtraSticker]): Promise<StickerMessage>
  • Parameters

    • Rest ...args: [sticker: string | InputFile, extra?: ExtraSticker]

    Returns Promise<StickerMessage>

replyWithVenue

  • replyWithVenue(...args: [latitude: number, longitude: number, title: string, address: string, extra?: ExtraVenue]): Promise<VenueMessage>
  • Parameters

    • Rest ...args: [latitude: number, longitude: number, title: string, address: string, extra?: ExtraVenue]

    Returns Promise<VenueMessage>

replyWithVideo

  • replyWithVideo(...args: [video: string | InputFile, extra?: ExtraVideo]): Promise<VideoMessage>
  • Parameters

    • Rest ...args: [video: string | InputFile, extra?: ExtraVideo]

    Returns Promise<VideoMessage>

replyWithVideoNote

  • replyWithVideoNote(...args: [videoNote: string | InputFileVideoNote, extra?: ExtraVideoNote]): Promise<VideoNoteMessage>
  • Parameters

    • Rest ...args: [videoNote: string | InputFileVideoNote, extra?: ExtraVideoNote]

    Returns Promise<VideoNoteMessage>

replyWithVoice

  • replyWithVoice(...args: [voice: string | InputFile, extra?: ExtraVoice]): Promise<VoiceMessage>
  • Parameters

    • Rest ...args: [voice: string | InputFile, extra?: ExtraVoice]

    Returns Promise<VoiceMessage>

restrictChatMember

revokeChatInviteLink

  • revokeChatInviteLink(...args: [inviteLink: string]): Promise<ChatInviteLink>
  • Parameters

    • Rest ...args: [inviteLink: string]

    Returns Promise<ChatInviteLink>

setChatAdministratorCustomTitle

  • setChatAdministratorCustomTitle(...args: [userId: number, title: string]): Promise<true>
  • Parameters

    • Rest ...args: [userId: number, title: string]

    Returns Promise<true>

setChatDescription

  • setChatDescription(...args: [description?: string]): Promise<true>
  • Parameters

    • Rest ...args: [description?: string]

    Returns Promise<true>

setChatPermissions

  • setChatPermissions(...args: [permissions: ChatPermissions]): Promise<true>
  • Parameters

    • Rest ...args: [permissions: ChatPermissions]

    Returns Promise<true>

setChatPhoto

  • setChatPhoto(...args: [photo: InputFile]): Promise<true>
  • Parameters

    • Rest ...args: [photo: InputFile]

    Returns Promise<true>

setChatStickerSet

  • setChatStickerSet(setName: string): Promise<true>
  • Parameters

    • setName: string

    Returns Promise<true>

setChatTitle

  • setChatTitle(...args: [title: string]): Promise<true>
  • Parameters

    • Rest ...args: [title: string]

    Returns Promise<true>

setMyCommands

  • setMyCommands(commands: readonly BotCommand[]): Promise<true>
  • Parameters

    • commands: readonly BotCommand[]

    Returns Promise<true>

setPassportDataErrors

  • setPassportDataErrors(errors: readonly PassportElementError[]): Promise<true>
  • Parameters

    • errors: readonly PassportElementError[]

    Returns Promise<true>

setStickerPositionInSet

  • setStickerPositionInSet(sticker: string, position: number): Promise<true>
  • Parameters

    • sticker: string
    • position: number

    Returns Promise<true>

setStickerSetThumb

  • setStickerSetThumb(...args: [name: string, userId: number, thumb: string | InputFile]): Promise<true>
  • Parameters

    • Rest ...args: [name: string, userId: number, thumb: string | InputFile]

    Returns Promise<true>

stopMessageLiveLocation

  • stopMessageLiveLocation(markup?: InlineKeyboardMarkup): Promise<true | (Edited & LocationMessage)>
  • Parameters

    • Optional markup: InlineKeyboardMarkup

    Returns Promise<true | (Edited & LocationMessage)>

stopPoll

  • stopPoll(...args: [messageId: number, extra?: ExtraStopPoll]): Promise<Poll>

unbanChatMember

  • unbanChatMember(...args: [userId: number, extra?: { only_if_banned?: undefined | boolean }]): Promise<true>
  • Parameters

    • Rest ...args: [userId: number, extra?: { only_if_banned?: undefined | boolean }]

    Returns Promise<true>

unpinAllChatMessages

  • unpinAllChatMessages(...args: []): Promise<true>
  • Parameters

    • Rest ...args: []

    Returns Promise<true>

unpinChatMessage

  • unpinChatMessage(...args: [messageId?: number]): Promise<true>
  • Parameters

    • Rest ...args: [messageId?: number]

    Returns Promise<true>

uploadStickerFile

  • uploadStickerFile(...args: [stickerFile: InputFile]): Promise<File>
  • Parameters

    • Rest ...args: [stickerFile: InputFile]

    Returns Promise<File>

Generated using TypeDoc