diff --git a/packages/client/src/client.ts b/packages/client/src/client.ts index 1f1bcaed..6a5e9594 100644 --- a/packages/client/src/client.ts +++ b/packages/client/src/client.ts @@ -79,6 +79,7 @@ import { start } from './methods/auth/start' import { answerCallbackQuery } from './methods/bots/answer-callback-query' import { answerInlineQuery } from './methods/bots/answer-inline-query' import { deleteMyCommands } from './methods/bots/delete-my-commands' +import { getBotMenuButton } from './methods/bots/get-bot-menu-button' import { getCallbackAnswer } from './methods/bots/get-callback-answer' import { getGameHighScores, @@ -86,6 +87,7 @@ import { } from './methods/bots/get-game-high-scores' import { getMyCommands } from './methods/bots/get-my-commands' import { _normalizeCommandScope } from './methods/bots/normalize-command-scope' +import { setBotMenuButton } from './methods/bots/set-bot-menu-button' import { setGameScore, setInlineGameScore } from './methods/bots/set-game-score' import { setMyCommands } from './methods/bots/set-my-commands' import { setMyDefaultRights } from './methods/bots/set-my-default-rights' @@ -809,6 +811,11 @@ export interface TelegramClient extends BaseTelegramClient { */ langCode?: string }): Promise + /** + * Fetches the menu button set for the given user. + * + */ + getBotMenuButton(user: InputPeerLike): Promise /** * Request a callback answer from a bot, * i.e. click an inline button that contains data. @@ -887,6 +894,14 @@ export interface TelegramClient extends BaseTelegramClient { */ langCode?: string }): Promise + /** + * Sets a menu button for the given user. + * + */ + setBotMenuButton( + user: InputPeerLike, + button: tl.TypeBotMenuButton + ): Promise /** * Set a score of a user in a game * @@ -3698,11 +3713,13 @@ export class TelegramClient extends BaseTelegramClient { answerCallbackQuery = answerCallbackQuery answerInlineQuery = answerInlineQuery deleteMyCommands = deleteMyCommands + getBotMenuButton = getBotMenuButton getCallbackAnswer = getCallbackAnswer getGameHighScores = getGameHighScores getInlineGameHighScores = getInlineGameHighScores getMyCommands = getMyCommands protected _normalizeCommandScope = _normalizeCommandScope + setBotMenuButton = setBotMenuButton setGameScore = setGameScore setInlineGameScore = setInlineGameScore setMyCommands = setMyCommands diff --git a/packages/client/src/methods/bots/get-bot-menu-button.ts b/packages/client/src/methods/bots/get-bot-menu-button.ts new file mode 100644 index 00000000..0f27a4a2 --- /dev/null +++ b/packages/client/src/methods/bots/get-bot-menu-button.ts @@ -0,0 +1,24 @@ +import { TelegramClient } from '../../client' +import { tl } from '@mtcute/tl' +import { InputPeerLike, MtInvalidPeerTypeError } from "../../types"; +import { normalizeToInputUser } from "../../utils/peer-utils"; + +/** + * Fetches the menu button set for the given user. + * + * @internal + */ +export async function getBotMenuButton( + this: TelegramClient, + user: InputPeerLike +): Promise { + const userId = normalizeToInputUser(await this.resolvePeer(user)) + if (!userId) { + throw new MtInvalidPeerTypeError(user, 'user') + } + + return await this.call({ + _: 'bots.getBotMenuButton', + userId, + }) +} diff --git a/packages/client/src/methods/bots/set-bot-menu-button.ts b/packages/client/src/methods/bots/set-bot-menu-button.ts new file mode 100644 index 00000000..15f67c7c --- /dev/null +++ b/packages/client/src/methods/bots/set-bot-menu-button.ts @@ -0,0 +1,26 @@ +import { TelegramClient } from '../../client' +import { tl } from '@mtcute/tl' +import { InputPeerLike, MtInvalidPeerTypeError } from "../../types"; +import { normalizeToInputUser } from "../../utils/peer-utils"; + +/** + * Sets a menu button for the given user. + * + * @internal + */ +export async function setBotMenuButton( + this: TelegramClient, + user: InputPeerLike, + button: tl.TypeBotMenuButton +): Promise { + const userId = normalizeToInputUser(await this.resolvePeer(user)) + if (!userId) { + throw new MtInvalidPeerTypeError(user, 'user') + } + + await this.call({ + _: 'bots.setBotMenuButton', + userId, + button + }) +}