Skip to content

dasunpamod/Telegram-Manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Telegram Manager

A small, safe, interactive Python tool to clean up your own Telegram account:

  • Leave all channels
  • Leave all groups / supergroups
  • Clear all private chats (delete for both sides where Telegram allows it)
  • Clear your Saved Messages
  • Block & delete bots

It runs as your account using Telegram's official MTProto client API (via Telethon). Every destructive action shows a preview and asks you to type yes first, and a keep-list protects anything you never want touched.


1. Requirements

  • Python 3.8+
  • The Telethon library:
pip install telethon

2. Get your API credentials

  1. Go to https://my.telegram.org and log in with your phone number.
  2. Open API development tools.
  3. Create an app (any name). Copy the api_id and api_hash.

These identify the app, not your login. You still log in with your phone + the code Telegram sends you.

3. Run — no file editing needed

python telegram_manager.py

On the first run the script asks for your api_id and api_hash right in the terminal and saves them to credentials.json, so you only enter them once. Then you'll enter the code Telegram sends you (and your 2FA password if you have one). After that both the credentials and the login session are saved, so future runs go straight to the menu.

Keep credentials.json and the generated *.session file private — they grant access to your account. Don't commit or share them.

4. Optional: customise via config.py

You don't need this to log in. Use it only to set a keep-list or tune rate limits:

copy config.example.py config.py     # Windows
# cp config.example.py config.py     # macOS/Linux

In config.py you can:

  • Add anything you want protected to the KEEP list (usernames, numeric IDs, or exact group/channel titles). These are never left, cleared, or blocked.
  • Adjust DELAY_BETWEEN_ACTIONS, DELAY_EVERY_N, LONG_REST_SECONDS.
  • Optionally pre-set API_ID / API_HASH / PHONE instead of being prompted.

You'll get a menu:

  1) Leave all channels
  2) Leave all groups
  3) Clear all private chats (delete both sides)
  4) Clear Saved Messages
  5) Block & delete all bots
  6) Refresh / re-scan account
  9) NUKE CITY  (clean everything above at once)
  0) Quit

Each option first prints exactly what it will affect (and what it's keeping), then waits for you to type yes.

Nuke City (option 9) runs every cleanup step back to back: leave channels, leave groups, clear private chats (both sides), clear Saved Messages, and block + delete bots. Because it's drastic, it asks you to type NUKE CITY exactly before starting, and each individual step still shows its own preview and confirmation — so you can skip any single step and continue with the rest. The keep-list is respected throughout.


Respecting Telegram's limits (important)

Telegram enforces spam and flood limits. Doing thousands of actions quickly can get an account temporarily restricted. This tool is built to stay on the safe side:

  • Throttling: a pause (default 3s) between each action, plus a longer rest (default 60s) every 20 actions. Tune these in config.py (DELAY_BETWEEN_ACTIONS, DELAY_EVERY_N, LONG_REST_SECONDS).
  • Flood-wait handling: if Telegram returns a FloodWaitError asking you to wait N seconds, the tool automatically sleeps that long and retries once.
  • Hard stop: if Telegram flags the account (PeerFloodError), the tool stops immediately rather than digging the hole deeper. If that happens, wait several hours (sometimes a day) before running again.

Practical tips:

  • If you have hundreds/thousands of chats, do it in sessions — run a while, quit, come back later. Slower is safer.
  • Increase the delays in config.py if you ever see flood warnings.
  • Leaving public channels/groups is generally fine; mass-messaging is what triggers the strictest limits, and this tool doesn't send messages.

Notes & limitations

  • "Both sides" deletion (revoke) works for most private chats. Telegram may not let you revoke very old messages, or messages to certain accounts; those remain on the other person's side. Your own copy is always removed.
  • Saved Messages clearing deletes all messages in your Saved Messages chat.
  • Leaving a channel/group you own may require transferring or deleting it first; those are skipped with a message rather than forced.
  • This only touches your account. Use it responsibly and only on accounts you own.

Files

  • telegram_manager.py — the tool
  • credentials.json — created on first run (your saved api_id/api_hash; keep private)
  • config.example.py — optional template config (copy to config.py)
  • README.md — this file

About

A small, safe, interactive Python tool to clean up your own Telegram account:

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages