我失去了我的群组管理员,所以我想删除群组中的所有消息或者我可以给我的帐户管理员吗?
导入电报
# bot token
TOKEN = "+++++++++++"
# chat_id of the chat whose messages are to be deleted
chat_id = "@+++++++++++"
# create a bot instance
bot = telegram.Bot(token=TOKEN)
# get the list of messages in the chat
messages = bot.get_chat(chat_id).get('message', [])
# delete each message
for message in messages:
bot.delete_message(chat_id=chat_id, message_id=message['message_id'])
coroutine' object has no attribute 'get'
File "C:\Users\serdd\OneDrive\deo\main.py", line 13, in <module>
messages = bot.get_chat(chat_id).get('message', [])
AttributeError: 'coroutine' object has no attribute 'get'