Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

381
Visualizações
Telegram - telegraf hide inline keyboard for non admin roles

How to limit access so the inline buttons don't show up for all users in a group? If it's not possible, what's the best alternative to allow admins to click which sends a command in the chat as the admin himself replying or posting.

Either only the user currently pressing the buttons or all admins?

  • The bot will show the buttons to all users regardless of if they are admin or not
  • The non admin users can click the buttons and the reply is given in the chat but no bot action is taken, it's ignored
  • If the admin selects any buttons the non admins can see the button menu change in realtime too

How do I stop non admins from seeing the menu at all? or limiting it to the current user interacting with it only?

Here's my code:


const main = (ctx) => {
    if( ctx.from._is_in_admin_list ){
    return ctx.reply('Select your audio list', Keyboard.reply(['Controls'], { columns: 1 }))
}
else {
}
}

bot.use(function(ctx, next){
    if( ctx.chat.id > 0 ) return next();
        return bot.telegram.getChatAdministrators(ctx.chat.id)
        .then(function(data){
            if( !data || !data.length ) return;
            console.log('admin list:', data);
            ctx.chat._admins = data;
            ctx.from._is_in_admin_list = data.some( adm => adm.user.id === ctx.from.id );
        })
        .catch(console.log)
        .then(_ => next(ctx));
});

bot.start(main)
bot.hears('Back', main)
bot.hears('Controls', (ctx) => {
    if( ctx.from._is_in_admin_list ){
    const keyboard = Keyboard.make(["/stop","/pause","/resume","/skip"], { columns: 2 })
    return ctx.reply('Controls menu selected', Keyboard.combine(keyboard, backKeyboard).reply())
}
else {
//do nothing
}
})

bot.launch()
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda