UNPKG

930 BJavaScriptView Raw
1const { VkBotSdk, events: e } = 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
12 bot.on(e.group_join, (ctx, next) => {
13 console.log('group_join event', ctx.data);
14 next();
15 });
16
17 bot.on(e.vkpay_transaction, (ctx, next) => {
18 console.log('vkpay_transaction event', ctx.data);
19 next();
20 });
21
22 bot.on(e.like_add, (ctx, next) => {
23 console.log('like_add event', ctx.data);
24 next();
25 });
26
27
28 bot.command(/index/, (ctx, params, next) => {
29 ctx.reply('index');
30 });
31
32 bot.defaultReply((ctx, params) => {
33 ctx.reply('Default reply');
34 });
35
36 bot.initLongPoll();
37};
38
39
40main().then(() => {
41 console.log('Initialized');
42}).catch((e) => {
43 console.error(e);
44});