UNPKG

1.74 kBJavaScriptView Raw
1const { Keyboard, TextButton, LinkButton, LocationButton, VKPayButton, VKAppButton } = require('../index');
2
3/**
4 * Обычная клавиатура
5 */
6new Keyboard([
7 [new TextButton('button 1', 'default')],
8 [new TextButton('button 2', 'primary')]
9]);
10
11
12/**
13 * Инлайн-клавиатуры
14 */
15new Keyboard({ inline: true }, [
16 [new TextButton('button 1', 'positive')],
17 [new TextButton('button 2', 'negative')]
18]);
19
20new Keyboard(
21 [[ new TextButton('button 1', 'default') ]]
22).inline();
23
24
25/**
26 * Скрываемые после испольвания клавиатуры
27 */
28new Keyboard({ one_time: true }, [
29 [new TextButton('button 1', 'default')],
30 [new TextButton('button 2', 'primary')]
31]);
32
33new Keyboard(
34 [[ new TextButton('button 1', 'default') ]]
35).oneTime();
36
37
38/**
39 * Клавиатура с полезной нагрузкой на кнопках
40 */
41new Keyboard([
42 [ new TextButton('button 1', 'positive', ['payload_action']) ],
43 [ new TextButton('button 2', 'negative', ['payload_action', 'argument']) ],
44 [ new TextButton('button 2', 'negative', ['payload_action', ['arg1', 'arg2']]) ]
45]);
46
47
48/**
49 * Клавиатура с кастомными типами кнопок
50 */
51new Keyboard([
52 [ new LocationButton() ],
53 [
54 new VKPayButton('action=transfer-to-group&group_id=1&aid=10')
55 ],
56 [
57 new VKPayButton({ action: 'transfer-to-group', group_id: 1, aid: 1 })
58 ],
59 [
60 new LinkButton('Открыть ссылку', 'https://google.com')
61 ],
62 [
63 new VKAppButton('Открыть приложение', { app_id: 1, owner_id: -1, hash: 'debug' })
64 ]
65]);
66