Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion docs/04-keyboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ button.link(text: string, url: string);
```typescript
button.requestContact(text: string);
```
Добавляет кнопку запроса контакта. При нажатии на неё боту будет отправлено сообщение с номером телефона, полным имененм и почтой пользователя во вложении в формате `VCF`.
Добавляет кнопку запроса контакта. При нажатии на неё боту будет отправлено сообщение с номером телефона, полным именем и почтой пользователя во вложении в формате `VCF`.

#### RequestGeoLocation
```typescript
Expand All @@ -50,3 +50,9 @@ button.chat(text: string, chatTitle: string, extra?: {
});
```
Добавляет кнопку создания чата. При нажатии на неё будет создан новый чат с ботом и пользователем.

#### OpenApp
```typescript
button.openApp(text: string, webApp?: string, contactId?: number, payload?: string);
```
Добавляет кнопку для запуска мини-приложения. При нажатии на неё откроется окно с мини-приложением бота, ссылка на которого указана в параметре webApp.
12 changes: 12 additions & 0 deletions src/core/helpers/buttons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
Button,
CallbackButton, ChatButton,
LinkButton,
OpenAppButton,
RequestContactButton,
RequestGeoLocationButton,
} from '../network/api';
Expand Down Expand Up @@ -51,3 +52,14 @@ export const chat = (
type: 'chat', text, chat_title: chatTitle, ...extra,
};
};

export const openApp = (
text: string,
webApp: string,
contactId?: number,
payload?: string,
): OpenAppButton => {
return {
type: 'open_app', text, web_app: webApp, contact_id: contactId, payload
};
};
11 changes: 10 additions & 1 deletion src/core/network/api/types/keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,18 @@ export type ChatButton = {
uuid?: string | null;
};

export type OpenAppButton = {
type: 'open_app';
text: string;
web_app?: string | null;
contact_id?: number | null;
payload?: string | null;
};

export type Button =
| CallbackButton
| LinkButton
| RequestContactButton
| RequestGeoLocationButton
| ChatButton;
| ChatButton
| OpenAppButton;