0

如何限制访问以使组中的所有用户都不会显示内联按钮?如果不可能,让管理员单击哪个在聊天中发送命令作为管理员自己回复或发布的最佳选择是什么。

只有当前按下按钮的用户还是所有管理员?

  • 该机器人将向所有用户显示按钮,无论他们是否是管理员
  • 非管理员用户可以点击按钮并在聊天中给出回复但没有采取机器人操作,它被忽略
  • 如果管理员选择任何按钮,非管理员也可以实时看到按钮菜单的变化

如何完全阻止非管理员查看菜单?还是将其限制为仅与它交互的当前用户?

这是我的代码:


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()
4

0 回答 0