Answer the question
In order to leave comments, you need to log in
Telegram bot js, how to make a test using a bot?
How are tests created on js for a telegram bot?
i write this code
const testQuest1 = {
reply_markup:JSON.stringify({
inline_keyboard:[
[{text:"Да",callback_data:11},{text:"нет",callback_data:12}]
]
})
}
const startTest = async(chatId) =>{
await bot.sendMessage(chatId,"У тебя часто нет аппетита?",testQuest1)
}
const startTest2 =async(chatId) =>{
await bot.sendMessage(chatId,"У тебя часто усталость утром?",testQuest1)
}
const start = () =>{
bot.setMyCommands([
{command:"/start",description:"Приветствие "},
{command:"/info",description:"Напомнить твое имя и фамилию."},
{command:"/game",description:"сыграть в игру."},
{command:"/test",description:"пройти тест."},
])
bot.on("message",async msg =>{
const text = msg.text;
const chatId = msg.chat.id;
if(text === "/start"){
await bot.sendSticker(chatId,"https://tlgrm.ru/_/stickers/5a7/cb3/5a7cb3d0-bca6-3459-a3f0-5745d95d54b7/1.jpg")
return bot.sendMessage(chatId,`Привет,я бот с помощью которого ты можешь пройти тест!`);
}
if(text === "/info"){
return bot.sendMessage(chatId,`Тебя зовут ${msg.from.first_name} ${msg.from.last_name} `);
}
if(text ==="/test"){
return startTest(chatId)
}
})
bot.on("callback_query",msg =>{
const data = msg.message.chat.id;
if(data)
return startTest2;
})
}
start();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question