/
simple-updates-bot.js
52 lines (40 loc) · 1.14 KB
/
simple-updates-bot.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const { VK } = require('vk-io');
const vk = new VK({
token: process.env.TOKEN
});
vk.updates.hear('/start', async (context) => {
await context.send(`
My commands list
/cat - Cat photo
/purr - Cat purring
/time - The current date
/reverse - Reverse text
`);
});
vk.updates.hear('/cat', async (context) => {
await Promise.all([
context.send('Wait for the uploads awesome 😻'),
context.sendPhotos('https://loremflickr.com/400/300/')
]);
});
vk.updates.hear(['/time', '/date'], async (context) => {
await context.send(String(new Date()));
});
vk.updates.hear(/^\/reverse (.+)/i, async (context) => {
await context.send(
context.$match[1].split('').reverse().join('')
);
});
const catsPurring = [
'http://ronsen.org/purrfectsounds/purrs/trip.mp3',
'http://ronsen.org/purrfectsounds/purrs/maja.mp3',
'http://ronsen.org/purrfectsounds/purrs/chicken.mp3'
];
vk.updates.hear('/purr', async (context) => {
const link = catsPurring[Math.floor(Math.random() * catsPurring.length)];
await Promise.all([
context.send('Wait for the uploads purring 😻'),
context.sendAudioMessage(link)
]);
});
vk.updates.start().catch(console.error);