Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/mtkruto/client/5_client.ts>Context

[WIP] Cross-runtime JavaScript library for building Telegram clients
Go to Latest
interface Context
implements Update
import { type Context } from "https://deno.land/x/mtkruto@0.1.130/client/5_client.ts";

Properties

client: Client

The client that received the update.

me: undefined extends this["connectionState"] ? undefined extends this["authorizationState"] ? User : (User | undefined) : (User | undefined)
msg: undefined extends this["message"] ? undefined extends this["editedMessage"] ? undefined extends this["callbackQuery"] ? never : this["callbackQuery"] extends With<CallbackQuery, "message"> ? this["callbackQuery"]["message"] : this["callbackQuery"] extends With<CallbackQuery, "inlineMessageId"> ? never : (Message | undefined) : this["editedMessage"] : this["message"]

Resolves to ctx.message ?? ctx.editedMessage ?? ctx.callbackQuery?.message.

chat: this["msg"] extends never ? never : this["msg"]["chat"]

Resolves to effectiveMessage?.chat.

from: this["message"] extends Message ? this["message"]["from"] : this["editedMessage"] extends Message ? this["editedMessage"]["from"] : this["callbackQuery"] extends CallbackQuery ? this["callbackQuery"]["from"] : this["inlineQuery"] extends InlineQuery ? this["inlineQuery"]["from"] : never

Resolves to (ctx.message ?? ctx.editedMessage)?.from ?? ctx.callbackQuery?.from ?? ctx.inlineQuery?.from.

senderChat: this["msg"] extends never ? never : this["msg"]["senderChat"]

Resolves to effectiveMessage?.senderChat.

reply: (text: string, params?: Omit<SendMessageParams, "replyToMessageId"> & ReplyParams) => Promise<With<Message, "text">>

Reply the received message with a text message.

replyPoll: (
question: string,
options: [string, string, ...string[]],
params?: Omit<SendPollParams, "replyToMessageId"> & ReplyParams,
) => Promise<With<Message, "poll">>

Reply the received message with a poll.

replyPhoto: (photo: FileSource, params?: Omit<SendPhotoParams, "replyToMessageId"> & ReplyParams) => Promise<With<Message, "photo">>

Reply the received message with a photo.

replyDocument: (document: FileSource, params?: Omit<SendDocumentParams, "replyToMessageId"> & ReplyParams) => Promise<With<Message, "document">>

Reply the received message with a document.

delete: () => Promise<void>

Delete the received message.

forward: (to: ChatID, params?: ForwardMessagesParams) => Promise<this["msg"]>

Forward the received message.

sendChatAction: (action: ChatAction, params?: { messageThreadId?: number; }) => Promise<void>

Send a chat action to the chat which the message was received from.

editMessageText: (
messageId: number,
text: string,
) => Promise<With<Message, "text">>

Edit a message in the chat which the message was received from.

answerCallbackQuery: (params?: AnswerCallbackQueryParams) => Promise<void>

Answer the received callback query.

answerInlineQuery: (results: InlineQueryResult[], params?: AnswerInlineQueryParams) => Promise<void>

Answer the received inline query.

getMessage: (messageId: number) => Promise<Omit<Message, "replyToMessage"> | null>

Retrieve a single message of the chat which the message was received from.

getMessages: (messageIds: number[]) => Promise<Omit<Message, "replyToMessage">[]>

Retrieve multiple messages of the chat which the message was received from.

forwardMessage: (
to: ChatID,
messageId: number,
) => Promise<Message>

Forward a message of the chat which the message was received from.

forwardMessages: (
to: ChatID,
messageIds: number[],
) => Promise<Message[]>

Forward multiple messages of the chat which the message was received from.

deleteMessage: (messageId: number, params?: DeleteMessagesParams) => Promise<void>

Delete a message in the chat which the message was received from.

deleteMessages: (messageIds: number[], params?: DeleteMessagesParams) => Promise<void>

Delete multiple messages in the chat which the message was received from.

toJSON: () => Update