1 | const { VkBotSdk, Keyboard, TextButton } = require('../index');
|
2 |
|
3 | const mainKeyboard = new Keyboard([
|
4 | [
|
5 | new TextButton('Button 1', 'primary', 'payload_action')
|
6 | ],
|
7 | [
|
8 | new TextButton('Button 1', 'primary', ['payload_action', ['arg1']])
|
9 | ],
|
10 | [
|
11 | new TextButton('Button 2', 'default', ['payload_action', ['arg2']])
|
12 | ]
|
13 | ]);
|
14 |
|
15 | const main = async () => {
|
16 | const sdk = new VkBotSdk({
|
17 | debug: true,
|
18 | group_id: 0,
|
19 | access_token: ''
|
20 | });
|
21 |
|
22 | const bot = sdk.getCallback();
|
23 |
|
24 | bot.payload('payload_action', (ctx, params, next) => {
|
25 | const arg = params[0] || '';
|
26 |
|
27 | ctx.reply(`payload_action\n args[0]: ${arg}`);
|
28 | });
|
29 |
|
30 | bot.defaultReply((ctx, params) => {
|
31 | ctx.replyKeyboard(`Default reply`, mainKeyboard);
|
32 | });
|
33 |
|
34 | bot.initLongPoll();
|
35 | };
|
36 |
|
37 |
|
38 | main().then(() => {
|
39 | console.log('Initialized');
|
40 | }).catch((e) => {
|
41 | console.error(e);
|
42 | });
|