import type * as t from "@yaebal/types"; import { CallbackQueryContextBase } from "../generated/callback-query.js"; type AnswerExtra = Omit; type EditExtra = Omit; /** * CallbackQueryContext = generated base + hand-written ergonomic overloads. * Positional-string sugar for `answer` (the toast you fire on every tap) and * `editText` (editing the message the button is attached to). */ export class CallbackQueryContext extends CallbackQueryContextBase { /** Id of the chat the button's message is in (if still accessible). */ get chatId(): number | undefined { return this.message?.chat?.id; } /** Answer the callback query. Pass a string to flash text to the user. */ override answer(text: string, params?: AnswerExtra): Promise; override answer( params?: Omit, ): Promise; override answer( a?: string | Omit, b?: AnswerExtra, ): Promise { return super.answer(typeof a === "string" ? { text: a, ...b } : (a ?? {})); } /** Edit the attached message's text. Pass a string for the common case. */ override editText(text: string, params?: EditExtra): Promise; override editText( params: Omit, ): Promise; override editText( a: string | Omit, b?: EditExtra, ): Promise { return super.editText(typeof a === "string" ? { text: a, ...b } : a); } }