UNPKG

863 BJavaScriptView Raw
1const { VkBotSdk } = require('../index');
2
3const main = async () => {
4 const sdk = new VkBotSdk({
5 debug: true,
6 group_id: 0,
7 access_token: ''
8 });
9
10 const bot = sdk.getCallback();
11 const client = sdk.getClient();
12
13 /*
14 * Варианты использования:
15 *
16 * ctx.request('users.get', { ... });
17 * bot.request('users.get', { ... });
18 * client.request('users.get', { ... });
19 */
20
21 bot.defaultReply(async (ctx, params) => {
22 const [user] = await bot.request('users.get', {
23 user_ids: ctx.user_id
24 });
25
26 ctx.replyKeyboard(`Default reply to ${user['first_name']} ${user['last_name']}`);
27 });
28
29 bot.initLongPoll();
30};
31
32
33main().then(() => {
34 console.log('Initialized');
35}).catch((e) => {
36 console.error(e);
37});