add display chat information and ask for confirm

This commit is contained in:
2021-12-11 10:17:20 +08:00
parent a08ff709d1
commit 9a021e3c5b
2 changed files with 104 additions and 5 deletions

View File

@@ -42,6 +42,21 @@ async def main(lib: TdLib, arg):
se.get("proxy"), se.get("phone_number")):
raise ValueError('Can not login')
chat_id = arg.chat_id if arg.chat_id is not None else await get_chat_id_from_name(lib, arg.chat_name) # noqa: E501
chat = await lib.getChat(chat_id)
if chat is None:
print('Chat not found.')
return -1
print('Chat information:')
print(f"Chat ID: {chat['id']}")
print(f"Chat Title: {chat['title']}")
print(f"Chat Type: {chat['type']}")
yes = False
if not yes:
inp = input('Do you want to delete messages in this chat?(y/n)')
if inp[0].lower() == 'y':
yes = True
if not yes:
return 0
re = await lib.deleteAllMyMessageInChat(chat_id, arg.start_time, arg.end_time) # noqa: E501
print(re)
return 0 if re else -1