Answer the question
In order to leave comments, you need to log in
How to make the code individual for each user?
There is a function that selects documents from the database upon request, writes the result to an object. The response message is built from this object. While one person is working, everything is fine, but as parallel requests appear, complete confusion begins.
How to isolate this code from other users?
function sendFileByQuery(chatId, query) {
File.find(query).then(files => {
let rndFile = file[Math.floor(Math.random() * files.length)]
bot.sendDocument(chatId, rndFile.gif, {
reply_markup: {
inline_keyboard: [
[
{
text: 'Следующий',
callback_data: 'somedata'
}
]
})
})
}
Answer the question
In order to leave comments, you need to log in
Can use a state machine to keep track of the "state" of the user?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question