diff --git a/packages/client/src/types/bots/keyboards.ts b/packages/client/src/types/bots/keyboards.ts index 6eba9b24..c22e09ea 100644 --- a/packages/client/src/types/bots/keyboards.ts +++ b/packages/client/src/types/bots/keyboards.ts @@ -1,6 +1,8 @@ import { assertNever } from '@mtcute/core' import { tl } from '@mtcute/tl' import { BotKeyboardBuilder } from './keyboard-builder' +import { normalizeToInputUser } from '../../utils/peer-utils' +import { MtInvalidPeerTypeError } from '../errors' /** * Reply keyboard markup @@ -353,6 +355,28 @@ export namespace BotKeyboard { } } + /** + * Button to open user profile + * + * @param text Text of the button + * @param user User to be opened (use {@link TelegramClient.resolvePeer}) + */ + export function userProfile( + text: string, + user: tl.TypeInputPeer + ): tl.RawInputKeyboardButtonUserProfile { + const userId = normalizeToInputUser(user) + if (!userId) { + throw new MtInvalidPeerTypeError(user, 'user') + } + + return { + _: 'inputKeyboardButtonUserProfile', + text, + userId, + } + } + /** * Find a button in the keyboard by its text or by predicate *