-
Notifications
You must be signed in to change notification settings - Fork 86
Expand file tree
/
Copy pathsimple-updates-bot.js
More file actions
59 lines (45 loc) · 1.43 KB
/
simple-updates-bot.js
File metadata and controls
59 lines (45 loc) · 1.43 KB
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
53
54
55
56
57
58
59
const { VK } = require('vk-io');
const { HearManager } = require('@vk-io/hear');
const vk = new VK({
token: process.env.TOKEN,
});
const hearManager = new HearManager();
vk.updates.on('message_new', hearManager.middleware);
hearManager.hear('/start', async context => {
await context.send(`
My commands list
/cat - Cat photo
/purr - Cat purring
/time - The current date
/reverse - Reverse text
`);
});
hearManager.hear('/cat', async context => {
await Promise.all([
context.send('Wait for the uploads awesome 😻'),
context.sendPhotos({
value: 'https://loremflickr.com/400/300/',
}),
]);
});
hearManager.hear(['/time', '/date'], async context => {
await context.send(String(new Date()));
});
hearManager.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',
];
hearManager.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({
value: link,
}),
]);
});
vk.updates.start().catch(console.error);