bot.on('callback_query', async (query) => {
const chatId = query.message.chat.id
const data = query.data
chats = {}
const cuefaArr = ['stone', 'scissors', 'paper', 'lizard', 'spock']
if (data === 'startCuefa') {
await bot.sendMessage(chatId, 'Что выбираете?', {
reply_markup: {
inline_keyboard: [keyboard.gameCuefa],
},
})
} else {
chats[chatId] = helper.random(cuefaArr)
await bot.sendMessage(chatId, chats[chatId])
if (data === chats[chatId]) {
return bot.sendMessage(chatId, 'Ничья.')
} else if (helper.compare(query, chatId, 'lizard', 'scissors', 'stone') || helper.compare(query, chatId, 'paper', 'lizard', 'scissors') || helper.compare(query, chatId, 'spock', 'stone', 'paper') || helper.compare(query, chatId, 'spock', 'paper', 'lizard') || helper.compare(query, chatId, 'stone', 'scissors', 'spock')) {
return bot.sendMessage(chatId, 'Вы проиграли!')
}
}
})