feat(client): support seamless login for bots
also slightly improved docs for BotKeyboard
This commit is contained in:
parent
cae7f90c57
commit
ac0ddc5c6d
1 changed files with 57 additions and 1 deletions
|
@ -186,6 +186,8 @@ export namespace BotKeyboard {
|
||||||
/**
|
/**
|
||||||
* Create a keyboard button with a link.
|
* Create a keyboard button with a link.
|
||||||
*
|
*
|
||||||
|
* Used for inline keyboards, not reply!
|
||||||
|
*
|
||||||
* @param text Button text
|
* @param text Button text
|
||||||
* @param url URL
|
* @param url URL
|
||||||
*/
|
*/
|
||||||
|
@ -200,6 +202,8 @@ export namespace BotKeyboard {
|
||||||
/**
|
/**
|
||||||
* Create a keyboard button with a link.
|
* Create a keyboard button with a link.
|
||||||
*
|
*
|
||||||
|
* Used for inline keyboards, not reply!
|
||||||
|
*
|
||||||
* @param text Button text
|
* @param text Button text
|
||||||
* @param data Callback data (1-64 bytes). String will be converted to `Buffer`
|
* @param data Callback data (1-64 bytes). String will be converted to `Buffer`
|
||||||
* @param requiresPassword
|
* @param requiresPassword
|
||||||
|
@ -226,6 +230,8 @@ export namespace BotKeyboard {
|
||||||
* one of their chats, open that chat and insert the bot‘s
|
* one of their chats, open that chat and insert the bot‘s
|
||||||
* username and the specified inline query (if any) in the input field.
|
* username and the specified inline query (if any) in the input field.
|
||||||
*
|
*
|
||||||
|
* Used for inline keyboards, not reply!
|
||||||
|
*
|
||||||
* @param text Button text
|
* @param text Button text
|
||||||
* @param query Inline query (can be empty or omitted)
|
* @param query Inline query (can be empty or omitted)
|
||||||
* @param currentChat
|
* @param currentChat
|
||||||
|
@ -248,13 +254,63 @@ export namespace BotKeyboard {
|
||||||
/**
|
/**
|
||||||
* Button to start a game
|
* Button to start a game
|
||||||
*
|
*
|
||||||
|
* Used for inline keyboards, not reply!
|
||||||
|
*
|
||||||
* **Note**: This type of button must always be
|
* **Note**: This type of button must always be
|
||||||
* the first button in the first row
|
* the first button in the first row. ID of the
|
||||||
|
* game is inferred from {@link InputMedia.game},
|
||||||
|
* thus this button should only be used with it.
|
||||||
*/
|
*/
|
||||||
export function game(text: string): tl.RawKeyboardButtonGame {
|
export function game(text: string): tl.RawKeyboardButtonGame {
|
||||||
return { _: 'keyboardButtonGame', text }
|
return { _: 'keyboardButtonGame', text }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Button to authorize a user
|
||||||
|
*
|
||||||
|
* Used for inline keyboards, not reply!
|
||||||
|
*
|
||||||
|
* @param text Button label
|
||||||
|
* @param url Authorization URL (see [TL Reference](https://mt.tei.su/tl/class/inputKeyboardButtonUrlAuth))
|
||||||
|
* @param params
|
||||||
|
*/
|
||||||
|
export function urlAuth(
|
||||||
|
text: string,
|
||||||
|
url: string,
|
||||||
|
params: {
|
||||||
|
/**
|
||||||
|
* Button label when forwarded
|
||||||
|
*/
|
||||||
|
fwdText?: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to request the permission for
|
||||||
|
* your bot to send messages to the user
|
||||||
|
*/
|
||||||
|
requestWriteAccess?: boolean
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bot, which will be used for user authorization.
|
||||||
|
* `url` domain must be the same as the domain linked
|
||||||
|
* with the bot.
|
||||||
|
*
|
||||||
|
* Defaults to current bot
|
||||||
|
*/
|
||||||
|
bot?: tl.TypeInputUser
|
||||||
|
} = {}
|
||||||
|
): tl.RawInputKeyboardButtonUrlAuth {
|
||||||
|
return {
|
||||||
|
_: 'inputKeyboardButtonUrlAuth',
|
||||||
|
text,
|
||||||
|
url,
|
||||||
|
bot: params.bot ?? {
|
||||||
|
_: 'inputUserSelf'
|
||||||
|
},
|
||||||
|
fwdText: params.fwdText,
|
||||||
|
requestWriteAccess: params.requestWriteAccess
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
export function _rowsTo2d(
|
export function _rowsTo2d(
|
||||||
rows: tl.RawKeyboardButtonRow[]
|
rows: tl.RawKeyboardButtonRow[]
|
||||||
|
|
Loading…
Reference in a new issue