UNPKG

564 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
12 bot.use((ctx, next) => {
13 ctx.date = new Date();
14 next();
15 });
16
17 bot.defaultReply((ctx, params) => {
18 ctx.reply(`Default reply\nCurrent date: ${ctx.date}`);
19 });
20
21 bot.initLongPoll();
22};
23
24
25main().then(() => {
26 console.log('Initialized');
27}).catch((e) => {
28 console.error(e);
29});