How I Recovered Deleted Telegram Messages and Media (and You Can Too)

🧵 TL;DR: I accidentally deleted over 350,000 messages and 20,000 media files from a private Telegram group — a full 3-year archive. Panic mode: ON.
Turns out, deleted messages in Telegram aren’t always lost forever. If you’re quick, there’s a technical way to recover part of it — but only under specific conditions.

I wrote a detailed guide (with code) on how I recovered the data using Telegram’s Admin Log, MTProto, and Python (Telethon library). The tool lets you dump deleted messages and media, and even resend them back into chats.

✅ What’s inside:
– “What Telegram actually deletes (and when)”
– “How I used Admin Log to recover content”
– “How the Telegram API exposes partial traces via MTProto”
– “Open-source Python scripts: backup & resender”
– “Real case: 8 hours to restore 3 years of lost group history”

I’m happy to answer technical questions, help you run the scripts, or improve the code. Also open to collabs if someone wants to take it further.

P.S. This doesn’t work for private 1-on-1 chats — only groups and channels.


This content originally appeared on HackerNoon and was authored by Dmitrii

Losing years of Telegram history by mistake felt like a nightmare. Here’s how I reverse-engineered Telegram’s Admin Log to bring it all back.

⚠️ Heads-up: This method only works for group chats and channels â€” not for one-on-one private conversations.

\


\

The Accident That Started It All

On September 23, 2024, I made a catastrophic mistake.

I accidentally deleted all messages and media from a Telegram group chat with my close friends — a conversation that had spanned over three years, included thousands of files, and over 350,000 messages.

Telegram gives you just five seconds to undo a deletion. I missed the window.

Gopher is unhappy \n Panic. Regret. Despair.

Who Am I?

Hi, I’m Dmitrii Guseva Frontend Developer on the Bricks team at Avito. This isn’t a post about my job — this is about a very personal technical challenge that turned into a mini-investigation, a code project, and ultimately… a successful recovery.

Is Recovery Even Possible?

Telegram doesn’t offer any official method to restore deleted group messages or media. Their export tool only works with existing data — not deleted content.

But I found a clue: Recent Actions.

If you’re an admin of a group or channel, you can see deleted messages there — but only for 48 hours, and there’s no “Restore” button.

Still, I thought:

If Telegram shows deleted messages there… they must be stored somewhere. Maybe I can get them out.

Enter: MTProto

Telegram has two main APIs:

  • Bot API â€” simplified, safe, limited
  • MTProto API â€” complex, powerful, and undocumented in parts

I realized the only way to access deleted content was through MTProto, specifically the GetAdminLogRequest method.

I found an old, buggy script on GitHub Gist that tried this. It didn’t fully work, but it gave me a starting point.

Building the Recovery Tool

I rewrote and extended the script. Here’s what my tool can now do:

  • [x] Extract deleted text messages
  • [x] Download deleted media files
  • [x] Export data into a clean dump.json
  • x Resend messages/media to a Telegram group or chat

I used Telethon, a Python library for interacting with Telegram’s MTProto API.

My friends and I decided to recover only media files â€” dumping 350k messages would’ve taken days.

The script ran for ~8 hours. It successfully downloaded every media file deleted in that accidental wipe. Crisis averted.

\


\

📦 How to Use the Tool

You can try this too. Here’s the full guide.

1. Install Python3

Mac users: Install Homebrew first, then Python 3.

Windows/Linux: Use the official site.

Install VSCode or another IDE and set up Python.

2. Clone the Repo

Install Git and clone the project:

git clone https://github.com/sw1tch3roo/tg-message-lifeguard.git
cd tg-message-lifeguard

3. (Optional) Create a Virtual Environment

python3 -m venv venv
source venv/bin/activate  # macOS/Linux
.\venv\Scripts\activate   # Windows

4. Install Dependencies

pip install -r requirements.txt

5. Get Telegram Credentials

  1. Go to https://my.telegram.org
  2. Log in with your phone
  3. Navigate to API Development Tools
  4. Save your api_id and api_hash

You’ll also need your group or channel’s internal ID — follow the script instructions to get it.

6. Run the Backup Script

python3 -m src.backup

You’ll be prompted for:

  • api_id
  • api_hash
  • Your phone number
  • Your group’s chat ID

âť— Note: You must use your personal Telegram account, not a bot — bots don’t have access to admin logs.

You can choose to export:

  1. Text only
  2. Media only
  3. Both text and media

You can also specify:

  • A message range (min_message_idmax_message_id)
  • Your group or channel ID (group_chat_id)

🔢 How minmessageid and maxmessageid work:

This defines the range of messages to export:

  • min_message_id = 0 â†’ start from the very first message in the chat
  • max_message_id = 0 â†’ export all available messages

For example:

min_message_id = 23456
max_message_id = 25673

This will export only messages within that range, including media.

8. Let It Run

Files and metadata will be saved in a folder called backup_will_be_inside_me. You can interrupt and resume anytime — the script supports resuming via message ID.

⚠️ Each media file is saved with its corresponding message ID as the file name. This is extremely helpful if the script stops and you need to resume. Just restart the script and set min_message_id to the last downloaded ID — the export will pick up from there.

What It Looks Like

  • .json file with message metadata and IDs
  • Downloaded media: photos, videos, documents
  • Easy mapping between message ID and file

You can also use a companion resender.py script to re-post content into Telegram.

Lessons Learned

  • Telegram does temporarily store deleted content for group chats
  • You can access this data via MTProto, if you act within 48 hours
  • Scripts using Telethon and GetAdminLogRequest can download it
  • Private chats? Unfortunately, there’s no way to recover those once deleted

The Repo

đź›  Check out the tool here.

Open to contributions, suggestions, or bug reports!

\


\

Final Thoughts

What started as a dumb mistake turned into a deep technical dive — and a surprising success. I hope this tool helps you if you ever find yourself in a similar situation.

Got questions? DM me or leave a comment — happy to help.

And hey — maybe go back up your favourite chats today, just in case.

\


This content originally appeared on HackerNoon and was authored by Dmitrii


Print Share Comment Cite Upload Translate Updates
APA

Dmitrii | Sciencx (2025-06-19T14:00:26+00:00) How I Recovered Deleted Telegram Messages and Media (and You Can Too). Retrieved from https://www.scien.cx/2025/06/19/how-i-recovered-deleted-telegram-messages-and-media-and-you-can-too/

MLA
" » How I Recovered Deleted Telegram Messages and Media (and You Can Too)." Dmitrii | Sciencx - Thursday June 19, 2025, https://www.scien.cx/2025/06/19/how-i-recovered-deleted-telegram-messages-and-media-and-you-can-too/
HARVARD
Dmitrii | Sciencx Thursday June 19, 2025 » How I Recovered Deleted Telegram Messages and Media (and You Can Too)., viewed ,<https://www.scien.cx/2025/06/19/how-i-recovered-deleted-telegram-messages-and-media-and-you-can-too/>
VANCOUVER
Dmitrii | Sciencx - » How I Recovered Deleted Telegram Messages and Media (and You Can Too). [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/06/19/how-i-recovered-deleted-telegram-messages-and-media-and-you-can-too/
CHICAGO
" » How I Recovered Deleted Telegram Messages and Media (and You Can Too)." Dmitrii | Sciencx - Accessed . https://www.scien.cx/2025/06/19/how-i-recovered-deleted-telegram-messages-and-media-and-you-can-too/
IEEE
" » How I Recovered Deleted Telegram Messages and Media (and You Can Too)." Dmitrii | Sciencx [Online]. Available: https://www.scien.cx/2025/06/19/how-i-recovered-deleted-telegram-messages-and-media-and-you-can-too/. [Accessed: ]
rf:citation
» How I Recovered Deleted Telegram Messages and Media (and You Can Too) | Dmitrii | Sciencx | https://www.scien.cx/2025/06/19/how-i-recovered-deleted-telegram-messages-and-media-and-you-can-too/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.