Avatar r50 a6ce93fe35b158fd29ba0e8681c918c22117160e9586a56eee4ffbc20df9bda1
Python senior developer

telegram-cleaner

Добавлено 24 ноя 2024 в 06:38
https://github.com/s3rgeym/telegram-cleaner
Delete 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.
310d4fd663