Answer the question
In order to leave comments, you need to log in
How to fix Unresolved attribute reference 'set_chat_permission' for class 'Bot' error?
I'm trying to write a bot that will put the chat to sleep at night.
please help me fix the error.
Unresolved attribute reference 'set_chat_permission' for class 'Bot'
main.py
sleep_premissions = {
'can_send_messages': False,
'can_send_media_messages': False,
'can_send_polls': False,
'can_send_other_messages': False
}
wakeup_premissions = {
'can_send_messages': True,
'can_send_media_messages': True,
'can_send_polls': True,
'can_send_other_messages': True
}
async def tsleep():
await bot.send_message(chat_id=config.GROUP_ID, text="НОЧНОЙ РЕЖИМ ВКЛЮЧЁН\n\n"
"❌ Начиная с этого времени, до 9 утра - "
"НИКТО ИЗ ПОЛЬЗОВАТЕЛЕЙ не сможет посылать текстовые "
"сообщения и ссылки в группу.")
await bot.set_chat_permission(chat_id=config.GROUP_ID, permissions=sleep_premissions)
async def twakeup():
await bot.send_message(chat_id=config.GROUP_ID, text="НОЧНОЙ РЕЖИМ ОТКЛЮЧЁН\n\n"
"✅ Доброе утро! Пользователи могут снова присылать текстовые "
"сообщения и ссылки в группу.")
await bot.set_chat_permission(chat_id=config.GROUP_ID, permissions=wakeup_premissions)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question