How to make Telegram bot inline keyboard private? Node.JS

// command for starting request with a simple anti-spam shiet
bot.command('movie', (ctx) => {   
        let stopSpam = findUserData(ctx);
        if (stopSpam) {
            ctx.reply(spammerMsg)
        } else {
            userData.push({id: ctx.message.from.id, msgId: ctx.message.message_id});
            ctx.reply('Género',genreMenu);
        } 
});

// So the issue is right here. 
//Right now I'm checking if the user has already used the comand 'movie'. 
//If so, he could use its buttons. But he could use the buttons from another user too...
bot.action(/.+/,(ctx) => {
    let allowed = findUserCallbackData(ctx);
    if (allowed) {
        ctx.editMessageReplyMarkup((m) => m.inlineKeyboard([]));
        allowed.queryGenre = ctx.update.callback_query.data;
        ctx.reply('Época', timeMenu)
            .then(() => {
                ctx.deleteMessage(ctx.update.callback_query.message.message_id)
            })
            .catch(e => {
                console.log(e)
            })
    }   else {
        console.log('noppe')
    }
});

findUserData = (ctx) => {
    let findCmdUser = userData.find(user => user.id === ctx.message.from.id)
    return findCmdUser
}

findUserCallbackData = (ctx) => {
    let findUser = userData.find(user => user.id === ctx.update.callback_query.from.id)
    return findUser
}

I'm in a cinema telegram group and I'm making a bot for movies recomendations using inline keyboard as data giver.

The issue is inline keyboard is not only visible but interactive for every single group member.

So my question is, can I prevent this from happening somehow? Can I make the inline keyboard only accesible (and visible, if possible) for the user which inserts the proper command?

Sorry for my basic English and thank's for your time.

Answers:

Answer

Inline keyboard is attached directly to message so it's not possible to make it visible for some participants only.

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.