forked from wezuwiusz/wezuwiuszowybot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
52 lines (41 loc) · 1.34 KB
/
index.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 { Telegraf } = require('telegraf')
const fs = require('fs');
let catfacts = fs.readFileSync('assets/catfacts.txt').toString('UTF8').split('\n');
let nodiscord = [
'Nie planujemy posiadać Discorda.',
'Kiedy będzie Discord? Jak Wyjdzie Half-Life 3',
'Kiedy będzie Discord? Jak firma, której nazwy nie wolno wymawiać będzie miała stabilne API',
'Top 5 rzeczy ktore nigdy sie nie stana:\n1. Discord Wezuwiusza'
]
let roll = [
"Tak",
"Nie",
"Może",
"Xiaomi lepsze"
]
function RandomFromArray(array) {
return array[Math.floor(Math.random() * array.length)]
}
const bot = new Telegraf(process.env.BOT_TOKEN)
// Garbage
bot.start((ctx) => ctx.reply('Dzień dobry!'))
bot.command('roll', async (ctx) => {
ctx.reply("Odpowiedź to: " + RandomFromArray(roll))
})
bot.command('catfact', async (ctx) => {
ctx.reply(RandomFromArray(catfacts));
})
bot.command("zrzutbazy", ctx =>
ctx.replyWithPhoto({ url: "https://mobidziennik.pl/grafika/forbidden.jpg" }),
);
// Filters
bot.on('message', async ctx => {
let content = ctx.message.text;
if (content !== undefined && content.toLowerCase().includes('discord')) {
ctx.reply(RandomFromArray(nodiscord));
}
})
bot.launch()
// Enable graceful stop
process.once('SIGINT', () => bot.stop('SIGINT'))
process.once('SIGTERM', () => bot.stop('SIGTERM'))