Add method to .delete_messages() (#282)

This commit is contained in:
Joscha Götzer
2017-10-02 18:59:29 +02:00
committed by Lonami
parent a6099f92bf
commit 6c375a7aed
2 changed files with 52 additions and 8 deletions

View File

@@ -94,11 +94,11 @@ class InteractiveTelegramClient(TelegramClient):
# Enter a while loop to chat as long as the user wants
while True:
# Retrieve the top dialogs
dialog_count = 10
dialog_count = 15
# Entities represent the user, chat or channel
# corresponding to the dialog on the same index
dialogs, entities = self.get_dialogs(dialog_count)
dialogs, entities = self.get_dialogs(limit=dialog_count)
i = None
while i is None:
@@ -141,6 +141,7 @@ class InteractiveTelegramClient(TelegramClient):
print(' !h: prints the latest messages (message History).')
print(' !up <path>: Uploads and sends the Photo from path.')
print(' !uf <path>: Uploads and sends the File from path.')
print(' !d <msg-id>: Deletes a message by its id')
print(' !dm <msg-id>: Downloads the given message Media (if any).')
print(' !dp: Downloads the current dialog Profile picture.')
print()
@@ -206,6 +207,13 @@ class InteractiveTelegramClient(TelegramClient):
# Slice the message to get the path
self.send_document(path=msg[len('!uf '):], entity=entity)
# Delete messages
elif msg.startswith('!d '):
# Slice the message to get message ID
deleted_msg = self.delete_messages(entity, msg[len('!d '):])
print('Deleted. {}'.format(deleted_msg))
# Download media
elif msg.startswith('!dm '):
# Slice the message to get message ID