telegram-delete-all-messages
telegram-delete-all-messages copied to clipboard
Can I use this tool to delete messages from a bot I own?
I've got a bot which posts images in my super group and I'm not able to delete all of its stuff, so maybe I can use this tool? If yes, please explain how.
Thanks
I too would like to do this.
If I change the following line to include bot (as modified below), I can produce a list of groups to delete that shows the bot group:
groups = [c for c in chats if c.type in ('group', 'bot')]
To print the correct name I change the following to group.username
for i, group in enumerate(groups):
print(f' {i+1}. {group.username}')
The trouble is I don't know how to then delete all messages within that bot group - it just returns 0 messages detected.
I'll post more details tomorrow along with links to the lines of code I've modified for testing.
Ok, I've got this working with the following detailed code changes. I do however have an issue where it won't delete more than 100 messages even when changing the search_limit
and delete_chunk_size
.
Line:
https://github.com/gurland/telegram-delete-all-messages/blob/9142174ec762ada0bc20dd2f4885ab7dfd26a88a/cleaner.py#L44
Change to: groups = [c for c in chats if c.type in ('bot')]
Line:
https://github.com/gurland/telegram-delete-all-messages/blob/9142174ec762ada0bc20dd2f4885ab7dfd26a88a/cleaner.py#L48
Change to: print(f' {i+1}. {group.username}')
Line: https://github.com/gurland/telegram-delete-all-messages/blob/9142174ec762ada0bc20dd2f4885ab7dfd26a88a/cleaner.py#L70
Change to: groups_str = ', '.join(c.username for c in self.chats)
Line: https://github.com/gurland/telegram-delete-all-messages/blob/9142174ec762ada0bc20dd2f4885ab7dfd26a88a/cleaner.py#L83
Change to: print(f'Found {messages_count} of your messages in "{chat.username}"')
Line: https://github.com/gurland/telegram-delete-all-messages/blob/9142174ec762ada0bc20dd2f4885ab7dfd26a88a/cleaner.py#L114
Comment out: # from_id=InputPeerSelf()