Gramforge

Transport Grammy API reference

Exports of @gramforge/transport-grammy. Back to the module

Functions

createGrammyClient

function

Build a {@link GrammyClient} over an injected grammY `Api` instance.

createGrammyClient(api: Api): GrammyClient

mapGrammyError

function
mapGrammyError(error: unknown): DeliveryResult<never>

resetDiagnostics

function

Test-only: clear the dedup set between tests.

resetDiagnostics(): void

setDiagnosticHook

function
setDiagnosticHook(fn: ((e: DiagnosticEvent) => void) | null): void

warnDegraded

function
warnDegraded(context: string, detail: string): void

warnNotImplemented

function
warnNotImplemented(category: string, detail: string): void

warnUnexpected

function
warnUnexpected(context: string, detail: string, data?: Record<string, unknown>): void

Types

DeliveryResult

type

Outcome 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

type

Result 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

type

Runtime 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

interface

A live-progress message handle.

interface LiveMessage

update

method

Record the latest text and schedule a debounced flush (synchronous).

update(text: string): void

flush

method

Force an immediate write of the pending text now, bypassing the debounce.

flush(): Promise<DeliveryResult<TelegramMessage>>

finish

method

Write `finalText` once immediately and close the instance.

finish(finalText: string): Promise<DeliveryResult<TelegramMessage>>

TelegramMessage

interface

A Telegram `Message`, projected to the branded ids the transport exposes.

interface TelegramMessage

messageId

property
messageId: MessageId

chatId

property
chatId: ChatId

date

property
date: number

GrammyClient

interface

The grammY-backed client surface — mirrors `@gramforge/transport-fetch`'s `BotClient`.

interface GrammyClient

sendMessage

method
sendMessage(args: SendMessageArgs): Promise<DeliveryResult<TelegramMessage>>

sendPhoto

method
sendPhoto(args: SendPhotoArgs): Promise<DeliveryResult<TelegramMessage>>

editMessageText

method
editMessageText(args: EditMessageTextArgs): Promise<DeliveryResult<EditMessageResult>>

sendMediaGroup

method
sendMediaGroup(args: SendMediaGroupArgs): Promise<DeliveryResult<readonly TelegramMessage[]>>

answerCallbackQuery

method
answerCallbackQuery(args: AnswerCallbackQueryArgs): Promise<DeliveryResult<true>>

liveMessage

method
liveMessage(args: LiveMessageArgs): LiveMessage

DiagnosticEvent

interface
interface DiagnosticEvent

kind

property
kind: DiagnosticKind

category

property
category: string

detail

property
detail: string

stack

property
stack: string

data

property
data: Record<string, unknown>

timestamp

property
timestamp: number