Не получается через Telegram бота закрывать доступ к написанию сообщений, aiogram
Написал такой код, все работает только не все нужные доступы отключаются.
@dp.message_handler(commands='close_chat', chat_id=config.CHAT_ID)
async def closeChat(msg: types.Message):
await msg.answer('test1')
chatInfo = await bot.get_chat(config.CHAT_ID)
current = chatInfo['permissions']
print(current)
current['can_send_messages'] = False
current['can_send_media_messages'] = False
current['can_send_polls'] = False
current['can_send_other_messages'] = False
print(current)
await bot.set_chat_permissions(chat_id=-1001540521514, permissions=current)
chatInfo = await bot.get_chat(config.CHAT_ID)
current = chatInfo['permissions']
print(current)
await msg.answer('test2')
Изначальный словарь разрешений:
{
"can_send_messages": true,
"can_send_media_messages": true,
"can_send_polls": true,
"can_send_other_messages": true,
"can_add_web_page_previews": true,
"can_change_info": false,
"can_invite_users": true,
"can_pin_messages": false
}
Нужный мне словарь, который я присваиваю:
{
"can_send_messages": false,
"can_send_media_messages": false,
"can_send_polls": false,
"can_send_other_messages": false,
"can_add_web_page_previews": true,
"can_change_info": false,
"can_invite_users": true,
"can_pin_messages": false
}
Итоговый словарь разрешений чата после присваивания:
{
"can_send_messages": true,
"can_send_media_messages": true,
"can_send_polls": false,
"can_send_other_messages": false,
"can_add_web_page_previews": true,
"can_change_info": false,
"can_invite_users": true,
"can_pin_messages": false
}
Никаких ошибок не выдает, не могу понять почему 2 самых нужных разрешения не меняются.