// AUTO-GENERATED — do not edit by hand. regenerate: pnpm --filter @yaebal/contexts generate import type { Api } from "@yaebal/core"; import type * as t from "@yaebal/types"; import { requiredId } from "../require-id.js"; export interface BusinessConnectionContext extends t.BusinessConnection {} export class BusinessConnectionContext { readonly api: Api; readonly update: t.Update; constructor(api: Api, update: t.Update) { this.api = api; this.update = update; Object.assign(this, update.business_connection ?? {}); } /** id of the user this update is from. */ get senderId(): number { return this.user.id; } /** first name of the user this update is from. */ get firstName(): string | undefined { return this.user.first_name; } /** Use this method to get information about the connection of the bot with a business account. Returns a [BusinessConnection](https://core.telegram.org/bots/api/#businessconnection) object on success. */ getBusinessConnection(params?: Omit & { business_connection_id?: string }) { return this.api.call("getBusinessConnection", { ...(params?.business_connection_id !== undefined ? {} : { business_connection_id: requiredId(this.id, "business_connection_id", "getBusinessConnection") }), ...params }); } /** Delete messages on behalf of a business account. Requires the *can\_delete\_sent\_messages* business bot right to delete messages sent by the bot itself, or the *can\_delete\_all\_messages* business bot right to delete any message. Returns *True* on success. */ deleteBusinessMessages(params: Omit & { business_connection_id?: string }) { return this.api.call("deleteBusinessMessages", { ...(params?.business_connection_id !== undefined ? {} : { business_connection_id: requiredId(this.id, "business_connection_id", "deleteBusinessMessages") }), ...params }); } /** Changes the first and last name of a managed business account. Requires the *can\_change\_name* business bot right. Returns *True* on success. */ setBusinessAccountName(params: Omit & { business_connection_id?: string }) { return this.api.call("setBusinessAccountName", { ...(params?.business_connection_id !== undefined ? {} : { business_connection_id: requiredId(this.id, "business_connection_id", "setBusinessAccountName") }), ...params }); } /** Changes the username of a managed business account. Requires the *can\_change\_username* business bot right. Returns *True* on success. */ setBusinessAccountUsername(params: Omit & { business_connection_id?: string }) { return this.api.call("setBusinessAccountUsername", { ...(params?.business_connection_id !== undefined ? {} : { business_connection_id: requiredId(this.id, "business_connection_id", "setBusinessAccountUsername") }), ...params }); } /** Changes the bio of a managed business account. Requires the *can\_change\_bio* business bot right. Returns *True* on success. */ setBusinessAccountBio(params: Omit & { business_connection_id?: string }) { return this.api.call("setBusinessAccountBio", { ...(params?.business_connection_id !== undefined ? {} : { business_connection_id: requiredId(this.id, "business_connection_id", "setBusinessAccountBio") }), ...params }); } /** Changes the profile photo of a managed business account. Requires the *can\_edit\_profile\_photo* business bot right. Returns *True* on success. */ setBusinessAccountProfilePhoto(params: Omit & { business_connection_id?: string }) { return this.api.call("setBusinessAccountProfilePhoto", { ...(params?.business_connection_id !== undefined ? {} : { business_connection_id: requiredId(this.id, "business_connection_id", "setBusinessAccountProfilePhoto") }), ...params }); } /** Removes the current profile photo of a managed business account. Requires the *can\_edit\_profile\_photo* business bot right. Returns *True* on success. */ removeBusinessAccountProfilePhoto(params: Omit & { business_connection_id?: string }) { return this.api.call("removeBusinessAccountProfilePhoto", { ...(params?.business_connection_id !== undefined ? {} : { business_connection_id: requiredId(this.id, "business_connection_id", "removeBusinessAccountProfilePhoto") }), ...params }); } /** Changes the privacy settings pertaining to incoming gifts in a managed business account. Requires the *can\_change\_gift\_settings* business bot right. Returns *True* on success. */ setBusinessAccountGiftSettings(params: Omit & { business_connection_id?: string }) { return this.api.call("setBusinessAccountGiftSettings", { ...(params?.business_connection_id !== undefined ? {} : { business_connection_id: requiredId(this.id, "business_connection_id", "setBusinessAccountGiftSettings") }), ...params }); } /** Returns the amount of Telegram Stars owned by a managed business account. Requires the *can\_view\_gifts\_and\_stars* business bot right. Returns [StarAmount](https://core.telegram.org/bots/api/#staramount) on success. */ getBusinessAccountStarBalance(params?: Omit & { business_connection_id?: string }) { return this.api.call("getBusinessAccountStarBalance", { ...(params?.business_connection_id !== undefined ? {} : { business_connection_id: requiredId(this.id, "business_connection_id", "getBusinessAccountStarBalance") }), ...params }); } /** Transfers Telegram Stars from the business account balance to the bot's balance. Requires the *can\_transfer\_stars* business bot right. Returns *True* on success. */ transferBusinessAccountStars(params: Omit & { business_connection_id?: string }) { return this.api.call("transferBusinessAccountStars", { ...(params?.business_connection_id !== undefined ? {} : { business_connection_id: requiredId(this.id, "business_connection_id", "transferBusinessAccountStars") }), ...params }); } /** Returns the gifts received and owned by a managed business account. Requires the *can\_view\_gifts\_and\_stars* business bot right. Returns [OwnedGifts](https://core.telegram.org/bots/api/#ownedgifts) on success. */ getBusinessAccountGifts(params: Omit & { business_connection_id?: string }) { return this.api.call("getBusinessAccountGifts", { ...(params?.business_connection_id !== undefined ? {} : { business_connection_id: requiredId(this.id, "business_connection_id", "getBusinessAccountGifts") }), ...params }); } /** Converts a given regular gift to Telegram Stars. Requires the *can\_convert\_gifts\_to\_stars* business bot right. Returns *True* on success. */ convertGiftToStars(params: Omit & { business_connection_id?: string }) { return this.api.call("convertGiftToStars", { ...(params?.business_connection_id !== undefined ? {} : { business_connection_id: requiredId(this.id, "business_connection_id", "convertGiftToStars") }), ...params }); } /** Upgrades a given regular gift to a unique gift. Requires the *can\_transfer\_and\_upgrade\_gifts* business bot right. Additionally requires the *can\_transfer\_stars* business bot right if the upgrade is paid. Returns *True* on success. */ upgradeGift(params: Omit & { business_connection_id?: string }) { return this.api.call("upgradeGift", { ...(params?.business_connection_id !== undefined ? {} : { business_connection_id: requiredId(this.id, "business_connection_id", "upgradeGift") }), ...params }); } /** Transfers an owned unique gift to another user. Requires the *can\_transfer\_and\_upgrade\_gifts* business bot right. Requires *can\_transfer\_stars* business bot right if the transfer is paid. Returns *True* on success. */ transferGift(params: Omit & { business_connection_id?: string }) { return this.api.call("transferGift", { ...(params?.business_connection_id !== undefined ? {} : { business_connection_id: requiredId(this.id, "business_connection_id", "transferGift") }), ...params }); } /** Posts a story on behalf of a managed business account. Requires the *can\_manage\_stories* business bot right. Returns [Story](https://core.telegram.org/bots/api/#story) on success. */ postStory(params: Omit & { business_connection_id?: string }) { return this.api.call("postStory", { ...(params?.business_connection_id !== undefined ? {} : { business_connection_id: requiredId(this.id, "business_connection_id", "postStory") }), ...params }); } /** Edits a story previously posted by the bot on behalf of a managed business account. Requires the *can\_manage\_stories* business bot right. Returns [Story](https://core.telegram.org/bots/api/#story) on success. */ editStory(params: Omit & { business_connection_id?: string }) { return this.api.call("editStory", { ...(params?.business_connection_id !== undefined ? {} : { business_connection_id: requiredId(this.id, "business_connection_id", "editStory") }), ...params }); } /** Deletes a story previously posted by the bot on behalf of a managed business account. Requires the *can\_manage\_stories* business bot right. Returns *True* on success. */ deleteStory(params: Omit & { business_connection_id?: string }) { return this.api.call("deleteStory", { ...(params?.business_connection_id !== undefined ? {} : { business_connection_id: requiredId(this.id, "business_connection_id", "deleteStory") }), ...params }); } /** Use this method to edit text, rich and [game](https://core.telegram.org/bots/api/#games) messages. On success, if the edited message is not an inline message, the edited [Message](https://core.telegram.org/bots/api/#message) is returned, otherwise *True* is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within **48 hours** from the time they were sent. */ editText(params: Omit) { return this.api.call("editMessageText", { ...(((this.id) === undefined) ? {} : { business_connection_id: this.id }), ...params }); } /** Use this method to edit captions of messages. On success, if the edited message is not an inline message, the edited [Message](https://core.telegram.org/bots/api/#message) is returned, otherwise *True* is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within **48 hours** from the time they were sent. */ editCaption(params: Omit) { return this.api.call("editMessageCaption", { ...(((this.id) === undefined) ? {} : { business_connection_id: this.id }), ...params }); } /** Use this method to edit animation, audio, document, live photo, photo, or video messages, or to replace a text or a rich message with a media. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo, a live photo, or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited [Message](https://core.telegram.org/bots/api/#message) is returned, otherwise *True* is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within **48 hours** from the time they were sent. */ editMedia(params: Omit) { return this.api.call("editMessageMedia", { ...(((this.id) === undefined) ? {} : { business_connection_id: this.id }), ...params }); } /** Use this method to edit live location messages. A location can be edited until its *live\_period* expires or editing is explicitly disabled by a call to [stopMessageLiveLocation](https://core.telegram.org/bots/api/#stopmessagelivelocation). On success, if the edited message is not an inline message, the edited [Message](https://core.telegram.org/bots/api/#message) is returned, otherwise *True* is returned. */ editLiveLocation(params: Omit) { return this.api.call("editMessageLiveLocation", { ...(((this.id) === undefined) ? {} : { business_connection_id: this.id }), ...params }); } /** Use this method to stop updating a live location message before *live\_period* expires. On success, if the message is not an inline message, the edited [Message](https://core.telegram.org/bots/api/#message) is returned, otherwise *True* is returned. */ stopMessageLiveLocation(params: Omit) { return this.api.call("stopMessageLiveLocation", { ...(((this.id) === undefined) ? {} : { business_connection_id: this.id }), ...params }); } /** Use this method to edit only the reply markup of messages. On success, if the edited message is not an inline message, the edited [Message](https://core.telegram.org/bots/api/#message) is returned, otherwise *True* is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within **48 hours** from the time they were sent. */ editReplyMarkup(replyMarkup: t.InlineKeyboardMarkup | { toJSON(): t.InlineKeyboardMarkup }, params?: Omit): Promise; editReplyMarkup(params?: Omit): Promise; editReplyMarkup(a?: t.InlineKeyboardMarkup | { toJSON(): t.InlineKeyboardMarkup } | Omit, b?: Omit): Promise { const params = a !== undefined && (typeof a === "object" && a !== null && ("inline_keyboard" in a || "toJSON" in a)) ? ({ reply_markup: a, ...b } as unknown as Omit) : ((a ?? {}) as Omit); return this.api.call("editMessageReplyMarkup", { ...(((this.id) === undefined) ? {} : { business_connection_id: this.id }), ...params }); } /** Use this method to create a link for an invoice. Returns the created invoice link as *String* on success. */ createInvoiceLink(params: Omit) { return this.api.call("createInvoiceLink", { ...(((this.id) === undefined) ? {} : { business_connection_id: this.id }), ...params }); } }