import type { Api } from "./api.js"; import { type FormatResult } from "./format.js"; import { type MediaSource } from "./media.js"; import type { CallbackQuery, Chat, Message, MessageEntity, Update, UpdateName, User } from "./telegram-types.js"; export interface ContextOptions { api: Api; update: Update; updateType: UpdateName; /** the bot's own account (from `getMe`), when known — long polling fills it in. */ me?: User; } type SendText = string | FormatResult; /** the object form of `send`/`reply` — full `sendMessage` params minus `chat_id`. */ type SendParams = { text: string; } & Record; /** * the message payload an update carries, straight from the raw update — unlike * `ctx.message` this can't be shadowed by enrichment, so filter queries and * `command`/`hears` route on what telegram actually sent. */ export declare function messageOf(update: Update): Message | undefined; /** * the base context every update is wrapped in. plugins and `derive`/`decorate` * enrich it with extra properties; those extras are tracked at the type level * by the Composer, so handlers see them without casting. */ export declare class Context { readonly api: Api; readonly update: Update; readonly updateType: UpdateName; /** the bot's own account (from `getMe`), when known — e.g. `command` checks `/cmd@botname` against it. */ readonly me?: User; constructor(options: ContextOptions); get message(): Message | undefined; get callbackQuery(): CallbackQuery | undefined; /** * the business connection this update belongs to, if any. `send`/`reply` thread it * into outgoing calls automatically — without it Telegram would deliver the message * as the bot (into the bot's own chat with the user) instead of as the connected * business account. */ get businessConnectionId(): string | undefined; /** the forum topic this update's message is in, if any — `send`/`reply` stay in it. */ get messageThreadId(): number | undefined; /** the direct-messages topic (channel DM chat) this update's message is in, if any. */ get directMessagesTopicId(): number | undefined; /** the user this update came from, whatever kind of update carries it. */ get from(): User | undefined; /** the chat this update happened in, whatever kind of update carries it. */ get chat(): Chat | undefined; /** * the chat that sent this update's message on the user's behalf, if any — an anonymous * admin/owner posting as the group, or an automatic forward from a linked channel. equal * to `ctx.chat.id` for the former, different for the latter (see `@yaebal/guards`' * `isAnonymousAdmin`/`fromLinkedChannel`, which key off this). */ get senderChat(): Chat | undefined; get text(): string | undefined; /** entities of `text` — `message.entities` falling back to `message.caption_entities`. */ get entities(): MessageEntity[] | undefined; /** narrowing helper in the puregram spirit: `if (ctx.is("callback_query"))`. */ is(updateType: UpdateName): boolean; /** send a message to the current chat. accepts a plain string or a `format` result. */ send(text: SendText, extra?: Record): Promise; /** object form: full `sendMessage` params (minus `chat_id`) in one object. */ send(params: SendParams): Promise; /** * the business connection this update's message must be routed through, as a spreadable * params fragment — empty object if there isn't one. safe for any method (send or edit). * exposed so plugins that build their own `api.call(...)` params (editMessageText, * deleteMessage, …) get the same routing send/sendPhoto/sendDocument use, instead of * re-deriving it by hand. */ businessRouting(): Record; /** * full outgoing routing for a NEW message: {@link businessRouting} plus the forum / * direct-messages topic this update's message lives in, so a reply doesn't fall back to * General. only send-family methods accept the topic ids — edits don't. */ routing(): Record; /** reply to the triggering message. */ reply(text: SendText, extra?: Record): Promise; /** object form: full `sendMessage` params (minus `chat_id`) in one object. */ reply(params: SendParams): Promise; /** * send a photo. accepts a {@link MediaSource} or a raw file_id / URL string. * `extra.caption` accepts a plain string or a `format`/`fmt` result. */ sendPhoto(photo: MediaSource | string, extra?: Record): Promise; /** object form: full `sendPhoto` params (minus `chat_id`) in one object. */ sendPhoto(params: { photo: MediaSource | string; } & Record): Promise; /** * send a document. accepts a {@link MediaSource} or a raw file_id / URL string. * `extra.caption` accepts a plain string or a `format`/`fmt` result. */ sendDocument(document: MediaSource | string, extra?: Record): Promise; /** object form: full `sendDocument` params (minus `chat_id`) in one object. */ sendDocument(params: { document: MediaSource | string; } & Record): Promise; /** answer the current callback query (no-op if there is none). */ answerCallbackQuery(extra?: Record): Promise; } export {}; //# sourceMappingURL=context.d.ts.map