Answer the question
In order to leave comments, you need to log in
How to make a request repeat button with current parameters?
Now there is a button that calls the function of choosing a random movie from the database by genre
bot.on('message', msg => {
const chatId = helpers.getChatid(msg)
switch (msg.text) {
case kb.home.drama:
sendFilmsByQuery(chatId, {type: 'Драма'})
bot.sendMessage(chatId, 'Подбираем фильм', {
reply_markup: { keyboard: keyboard.film }
})
break
function sendFilmsByQuery(chatId, query) {
Film.find(query).then(films => {
//выбор случайного фильма из массива
rndFilm = films[Math.floor(Math.random() * films.length)]
const caption = `${rndFilm.name}
Год: ${rndFilm.year}
Кинопоиск: ${rndFilm.rate}
${rndFilm.description}`
bot.sendVideo(chatId, rndFilm.trailer, {
caption: caption
})
})
}
rndFilm = films[Math.floor(Math.random() * films.length)]
const caption = `${rndFilm.name}
Год: ${rndFilm.year}
Кинопоиск: ${rndFilm.rate}
${rndFilm.description}`
bot.sendVideo(chatId, rndFilm.trailer, {
caption: caption
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