https://github.com/s3rgeym/telegram-cleanerDelete all your messages of any type.
⚠️ WARNING: before using this utility, you can save all your data using the desktop application: Settings > Advanced > Export Telegram data.
Installation:
# via pip
$ pip install -U telegram-cleaner
# via pipx
$ pipx install telegram-cleaner
Usage:
# help
$ tg-clean -h
# first save your chats because the data exported by telegram does not have information about group and user IDs
$ tg-clean dump_chats > mychats.json
# you can extract data from this file using jq
$ jq -r '.[] | "\( .id ) \( .username ) " +
if has("title")
then .title
else "\( .first_name ) \( .last_name )"
end' mychats.json
777000 null Telegram null
-1001436354653 nwsru NEWS.ru | Новости
...
# delete messages in group chats, comments, posts
$ tg-clean -vv delete_group_messages
# delete private chats without confirmation
$ tg-clean -y delete_private_chats
# delete all your messages of any type in chats except those specified
$ tg-clean --keep-chats 1234567890,1234567891,@durovs
You can use custom
API_ID and
API_HASH (
official apps). Add this lines to ~/.bashrc or ~/.zshrc:
export TG_API_ID=6
export TG_API_HASH=eb06d4abfb49dc3eeb1aeb98ae0f581e
Also you can use .env file with zsh dotenv plugin.