/
register.js
38 lines (33 loc) 路 980 Bytes
/
register.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
const Extra = require("telegraf/extra");
const User = require("../../models/user");
module.exports = bot => {
bot.hears("馃 Become a Hunter", async ctx => {
if (ctx.gameStarted) {
ctx.reply("Registration is closed now 馃槶");
} else {
const chatId = ctx.update.message.from.id;
const existingUser = await User.findOne({ chatId });
if (existingUser) {
ctx.reply("You are already a hunter 馃槈");
return;
}
ctx.reply(
"Did you recieve a token from our website?",
Extra.HTML().markup(m =>
m.inlineKeyboard([
m.callbackButton("Yes, let's go 馃尓", "Token"),
m.callbackButton("Not yet 馃対", "No token"),
])
)
);
}
});
bot.action("No token", ctx => {
ctx.reply(
"Visit https://trytohunt.me to get one and then run the command again 馃槈"
);
});
bot.action("Token", ctx => {
ctx.scene.enter("askToken");
});
};