Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

384
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda