Comments (3)
you need to send different buttons for admin and for users
for example:
if (admin) {
ctx.reply('you are admin', Keyboard.reply(['Admin button']))
} else {
ctx.reply('you are user', Keyboard.reply(['User button']))
}
from telegram-keyboard.
Thank you, I tried it and i still the following issue:
- 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()
from telegram-keyboard.
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.
from telegram-keyboard.
Related Issues (20)
- Unhandled error while processing update HOT 7
- SyntaxError: Unexpected token = HOT 3
- double click on inline buttons
- [HW/FR] Add mobile phone/current location request with callback HOT 5
- How to add one_time_keyboard field in Reply Keyboard HOT 3
- I have implemented an inline keyboard in my bot, but when I click on the button, the message with what is written on the button is not sent. HOT 1
- How to use HTML or Markdown HOT 1
- Write a good README
- Add more interesting examples
- How i can add "one_time_keyboard" option? HOT 1
- How to customize button text and reply HOT 3
- Cannot deploy to heroku HOT 1
- Disable notifications from inline replies HOT 1
- Update options HOT 1
- Migrate to TypeScript HOT 1
- Buttons that open app on mobile HOT 1
- you have video for how to use this bot ?
- Keyboard as command
- customizing the buttons HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from telegram-keyboard.