-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Limit access to admins only #32
Comments
you need to send different buttons for admin and for users if (admin) {
ctx.reply('you are admin', Keyboard.reply(['Admin button']))
} else {
ctx.reply('you are user', Keyboard.reply(['User button']))
} |
Thank you, I tried it and i still the following issue:
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() |
I understand your bot works in groups. Well, in that case it seems to me that you cannot separate the buttons for the admin and for the users. But I'm not really very familiar with this, so I can't say for sure. |
How to limit access so the buttons don't show up for all users.
Either only the user currently pressing the buttons or all admins?
The text was updated successfully, but these errors were encountered: