Transport Grammy API reference
Exports of @gramforge/transport-grammy. Back to the module
Functions
createGrammyClient
functionBuild a {@link GrammyClient} over an injected grammY `Api` instance.
createGrammyClient(api: Api): GrammyClient
mapGrammyError
functionmapGrammyError(error: unknown): DeliveryResult<never>
resetDiagnostics
functionTest-only: clear the dedup set between tests.
resetDiagnostics(): void
setDiagnosticHook
functionsetDiagnosticHook(fn: ((e: DiagnosticEvent) => void) | null): void
warnDegraded
functionwarnDegraded(context: string, detail: string): void
warnNotImplemented
functionwarnNotImplemented(category: string, detail: string): void
warnUnexpected
functionwarnUnexpected(context: string, detail: string, data?: Record<string, unknown>): void
Types
DeliveryResult
typeOutcome of a single Bot API call. `ok` carries the method's parsed result; every other variant is a typed, non-throwing failure.
type DeliveryResult = DeliveryResult<T>
EditMessageResult
typeResult of an `editMessageText` call. A chat-message edit returns the updated `Message`; an inline-message edit returns the wire literal `true` (there is no message object) — modeled as an explicit DU, never `Message | undefined`.
type EditMessageResult = {
readonly kind: "edited";
readonly message: TelegramMessage;
} | {
readonly kind: "inlineEdited";
}DiagnosticKind
typeRuntime diagnostics — the house alternative to deferred-work comments. Three functions: `warnNotImplemented`, `warnDegraded`, `warnUnexpected`. Each fires once per stable key (except `warnUnexpected`, which always fires), is greppable, and can be piped into a UI panel via {@link setDiagnosticHook}. Usage: warnDegraded("MyModule.fallback", "linear interp — cubic deferred, spec:120-140"); warnNotImplemented("MyModule.featureX", "spec §4 not yet lowered"); warnUnexpected("MyModule.parse", "expected number, got string", { value });
type DiagnosticKind = "not-implemented" | "degraded" | "unexpected"
Interfaces
LiveMessage
interfaceA live-progress message handle.
interface LiveMessage
update
methodRecord the latest text and schedule a debounced flush (synchronous).
update(text: string): void
flush
methodForce an immediate write of the pending text now, bypassing the debounce.
flush(): Promise<DeliveryResult<TelegramMessage>>
finish
methodWrite `finalText` once immediately and close the instance.
finish(finalText: string): Promise<DeliveryResult<TelegramMessage>>
TelegramMessage
interfaceA Telegram `Message`, projected to the branded ids the transport exposes.
interface TelegramMessage
messageId
propertymessageId: MessageId
chatId
propertychatId: ChatId
date
propertydate: number
GrammyClient
interfaceThe grammY-backed client surface — mirrors `@gramforge/transport-fetch`'s `BotClient`.
interface GrammyClient
sendMessage
methodsendMessage(args: SendMessageArgs): Promise<DeliveryResult<TelegramMessage>>
sendPhoto
methodsendPhoto(args: SendPhotoArgs): Promise<DeliveryResult<TelegramMessage>>
editMessageText
methodeditMessageText(args: EditMessageTextArgs): Promise<DeliveryResult<EditMessageResult>>
sendMediaGroup
methodsendMediaGroup(args: SendMediaGroupArgs): Promise<DeliveryResult<readonly TelegramMessage[]>>
answerCallbackQuery
methodanswerCallbackQuery(args: AnswerCallbackQueryArgs): Promise<DeliveryResult<true>>
liveMessage
methodliveMessage(args: LiveMessageArgs): LiveMessage
DiagnosticEvent
interfaceinterface DiagnosticEvent
kind
propertykind: DiagnosticKind
category
propertycategory: string
detail
propertydetail: string
stack
propertystack: string
data
propertydata: Record<string, unknown>
timestamp
propertytimestamp: number