- Batchfile 100%
| .gitignore | ||
| DeadMoon-Telegram-Scraper.cmd | ||
| README.md | ||
🌕 DeadMoon-Telegram-Scraper 🌙
Zero-Friction All-in-One Windows Polyglot Telegram Channel & Group Scraper, 4-Layer URL Intelligence Engine & Granular Media Harvester with Kinetic Moonlight ASCII UI, Browser/ANSI QR Login & Local Python Provisioning
Part of the DeadMoon Tool Suite by @Deadplayerdmr
🖥️ Terminal Preview
* d~~b . .================. . d~~b *
. d b .===' .------------. '===. d b .
* / .-' . o '-. \ *
/ .' o . . '. \ .
* [===] . / \ . [===] . *
(( .--[===] \____/ \____/ [===]--. )) d~b
(( [===] o .----. O [===] )) d b
. '--- [===] . / \ . [===] ---'
* \ '. . o .' / *
. '. '-. o . . .-' .' .
* '===='--------------'====' .
════════════════════════════════════════════════════════════════════════════
🌕 D E A D M O O N // T E L E G R A M S C R A P E R 🌙
Telegram Channel Exporter & 4-Layer URL Intelligence • Part of the DeadMoon Tool Suite by @Deadplayerdmr
════════════════════════════════════════════════════════════════════════════
🌙 Overview
DeadMoon-Telegram-Scraper is a self-contained, single-file Windows polyglot (Batch + PowerShell + Python) MTProto channel and group archiving engine — powered by the DeadMoon [Moonlight Engine] kinetic ASCII interface.
Designed for bot development, URL/domain reconnaissance, and clean local archiving, DeadMoon exports full message histories (including channels with "Restrict Saving Content" / forwarding disabled), extracts URLs from four distinct message layers, ranks detected domains for downstream bot parsing, and optionally downloads categorized media in parallel — all without polluting your global Python installation.
✨ Key Features
- 🌕 Kinetic Moonlight ASCII UI & Live Harvest Dashboard:
- Renders a flicker-free animated boot splash and a live real-time telemetry dashboard featuring sinusoidal orbital sway, vertical levitation bob, pulsing headphone soundwaves, floating musical notes, periodic blinks, and orbiting moon phases.
- Adaptive Terminal Rendering: Automatically detects Windows Terminal, VS Code, and ConEmu for full Unicode/moon emojis, while seamlessly switching to crisp pure-ASCII lunar glyphs on legacy
conhost.exeso borders and icons never garble.
- 🐍 Zero-Setup Local Environment & Portable Python Provisioning:
- Keeps every single runtime artifact neatly isolated inside
.deadmoon_local\right next to the.cmdfile. - Auto-detects System Python 3.9+ (ignoring broken
WindowsAppsStore stubs) to build a local.deadmoon_local\venv. - On machines without Python installed, automatically downloads and unpacks official Portable Python 3.12.10 (
amd64), enablessite-packages, bootstrapspip, and installstelethon,colorama,qrcode, and optional prebuiltcryptgC-crypto acceleration entirely locally.
- Keeps every single runtime artifact neatly isolated inside
- 📱 Bulletproof Dual-Mode Authentication (QR Code + Smart Phone Login):
- QR Code Login (Default
[1]): Generates a scannable high-contrast SVG popup (deadmoon_qr.html) in your browser and a font-immune ANSI background-color block QR code in the terminal — scan directly via Telegram → Settings → Devices → Link Desktop Device with zero SMS wait. - Smart Phone Login (
[2]): Auto-normalizes phone numbers with or without+, spaces, or dashes, inspects Telegram's exact delivery response (In-App Chat777000, SMS, Call, Fragment, or Email), and supports interactiveresend,qrswitching, and hidden 2FA password entry. - Authenticates once and caches your session locally in
.deadmoon_local\deadmoon_session.session.
- QR Code Login (Default
- 🎯 Universal Target Parser & Built-in Dialog Browser:
- Prompts interactively at startup and accepts any Telegram target format:
- Numeric channel/group IDs (
-1001302878715) - Usernames (
bazar_tahlilor@bazar_tahlil) - Public message or channel URLs (
https://t.me/channel_name/12269) - Private channel links (
https://t.me/c/1302878715/12269) & invite links (t.me/+...) - Telegram Web URLs (
https://web.telegram.org/a/?embed=true#-1001302878715)
- Numeric channel/group IDs (
- Or simply type
listto browse all of your joined channels and groups in a numbered table and select one instantly.
- Prompts interactively at startup and accepts any Telegram target format:
- 🔗 4-Layer Deep URL Extraction & Bot-Ready Domain Intelligence:
- Captures every link from:
- Hidden hyperlinked text entities (
MessageEntityTextUrl, avoiding UTF-16 custom-emoji offset truncation) - Raw message text (
https://,http://,www., andt.me/regex scan) - Attached web page previews (
media.webpage.url) - Inline keyboard URL buttons (
reply_markup)
- Hidden hyperlinked text entities (
- Outputs both a sorted, deduplicated
unique_urls.txtand a rankeddomains_summary.jsonwith occurrence counts and sample URLs to accelerate downstream bot design.
- Captures every link from:
- 📦 Granular Media Saving & Concurrent Download Worker Pool:
- Toggle Text & URLs ONLY (fastest) or selectively save any combination of:
[1]Images / Photos & Stickers[2]Audio (Music, MP3/FLAC/OGG, Voice Notes)[3]Videos & GIFs[4]Documents & Other Files (PDF, ZIP, APK, etc.)[5]ALL Media Types
- Combine categories with commas (e.g.,
1,2), set an optional per-file max MB size cap, and stream downloads across 3 concurrent async workers with automatic skip-if-exists deduplication.
- Toggle Text & URLs ONLY (fastest) or selectively save any combination of:
- ♻️ Incremental Checkpoints, Resumable History & Smart Filters:
- Saves
checkpoint.jsonper channel so future runs offer[1] Incremental(fetch only new messages),[2] Resume older(continue backwards from an earlier limit or interruption), or[3] Fresh scrape(new timestamped export folder). - Supports flexible Message Limits (any count or
allfor complete history), Keyword/Regex filtering, URLs-only filtering, andYYYY-MM-DDstart-date boundaries.
- Saves
- 🛡️ Rate-Limit (
FloodWait) Recovery & GracefulCtrl+CSaving:- Automatically pauses with a live countdown whenever Telegram enforces a
FloodWaitError, then resumes seamlessly from the exact message ID. - Pressing
Ctrl+Cmid-scrape cancels in-flight tasks cleanly and writes every collected message, URL, and checkpoint safely to disk.
- Automatically pauses with a live countdown whenever Telegram enforces a
📊 Export Formats & Bot-Design Outputs
Every completed or paused harvest writes a structured, UTF-8 export bundle into .\exports\<channel_slug>\:
| Output File / Folder | Format | Purpose |
|---|---|---|
messages.json |
UTF-8 JSON | Complete structured archive (id, date_utc, sender_id, message_link, views, forwards, reply_to_id, media_type, media_file, urls, text) |
messages.csv |
UTF-8-SIG CSV | Excel-ready spreadsheet (BOM-encoded so non-Latin scripts such as Persian/Arabic/Cyrillic and emojis render cleanly) |
unique_urls.txt |
Plain Text | Deduplicated, alphabetically sorted list of every extracted URL |
domains_summary.json |
UTF-8 JSON | Ranked domain frequency analytics with up to 10 sample URLs per domain for bot rule design |
checkpoint.json |
UTF-8 JSON | Tracks newest_id, oldest_id, and run metadata to power Incremental and Resume modes |
media\{type}\ |
Categorized Folders | Downloaded files organized into images\, audio\, videos\, and documents\ prefixed with message IDs |
📂 Default Directory Layout
All runtime files, sessions, and scraped exports stay self-contained inside whatever folder holds the .cmd script:
| Component | Default Host Path | Purpose |
|---|---|---|
| Polyglot Launcher | .\DeadMoon-Telegram-Scraper.cmd |
Single-file Batch + PowerShell + Python scraper & interactive CLI |
| Local Runtime Vault | .\.deadmoon_local\ |
Isolated local workspace for Python runtime, engine, and session |
| Local Python Venv | .\.deadmoon_local\venv\ |
Created automatically when System Python 3.9+ is detected |
| Portable Python | .\.deadmoon_local\python_portable\ |
Downloaded automatically only if no suitable System Python is installed |
| Extracted Engine | .\.deadmoon_local\deadmoon_engine.py |
UTF-8 Python engine unpacked automatically on each launch |
| Telegram Session | .\.deadmoon_local\deadmoon_session.session |
Local MTProto login cache so you only authenticate once |
| Exports Root | .\exports\<channel_slug>\ |
Per-channel JSON, CSV, URL lists, domain summaries, checkpoints & media |
🚀 Quick Start
1. Obtain Your Telegram API Credentials
Because standard @BotFather bots cannot read historical messages from channels where they are not administrators, DeadMoon connects through Telegram's official client MTProto API:
- Log in at https://my.telegram.org and open API development tools.
- Create an application (any name/short name works) to obtain your numeric
api_idand 32-characterapi_hash.
2. Download & Configure Credentials
Clone this repository or download DeadMoon-Telegram-Scraper.cmd into its own folder:
git clone https://github.com/Deadplayerdmr/DeadMoon-Telegram-Scraper.git
Provide your credentials either via environment variables (recommended before pushing forks to GitHub):
$env:TG_API_ID = "YOUR_API_ID"
$env:TG_API_HASH = "YOUR_API_HASH"
.\DeadMoon-Telegram-Scraper.cmd
...or set DEFAULT_API_ID and DEFAULT_API_HASH directly inside the # CONFIGURATION block of DeadMoon-Telegram-Scraper.cmd.
3. Launch & Authenticate
Double-click DeadMoon-Telegram-Scraper.cmd (or run it in Windows Terminal for full color moon emojis):
- Bootstrap: On first run, DeadMoon creates
.deadmoon_local\, sets up Python, and installstelethon,colorama,qrcode, and optionalcryptglocally. - Sign In (First Run Only):
- Press Enter to pick
[1] QR Code Login— scan the browser popup (or terminal QR) from your phone (Telegram → Settings → Devices → Link Desktop Device). - Or choose
[2] Phone Number + Codeto authenticate with your phone number.
- Press Enter to pick
- Configure Your Harvest:
- Paste a Channel/Group ID,
@username,t.meURL, Web URL, or typelistto pick from your joined chats. - Choose a Message Limit (e.g.,
500for a quick test, orallfor full history). - Pick your Media Saving Option (
0for Text & URLs only,1–4individually or comma-combined like1,2, or5for ALL) plus an optional max MB cap. - Optionally apply a Keyword/Regex, URLs-Only, or
YYYY-MM-DDstart-date filter.
- Paste a Channel/Group ID,
- Harvest & Inspect: Watch the kinetic live dashboard stream messages and top domains in real time. When finished (or paused with
Ctrl+C), press Enter to open the export folder directly in Windows Explorer.
🔐 Privacy, Safety & .gitignore Recommendations
- Never commit your credentials or session file: Anyone holding your
.sessionfile can access your Telegram account without a login code. Always keep.deadmoon_local/andexports/out of version control:
.deadmoon_local/
exports/
*.session
*.session-journal
- Respect Telegram rate limits & channel rules: DeadMoon includes automatic
FloodWaitErrorbackoff, but avoid running aggressive back-to-back full scrapes of restricted channels on a fresh account. Always respect applicable terms of service and content ownership.
🔧 Troubleshooting
| Symptom | Cause | Solution |
|---|---|---|
| Didn't receive an SMS login code | Telegram sends login codes to the official Telegram in-app chat (777000) first when you are logged in on another device |
Use [1] QR Code Login (instant, no code required), or check Archived Chats and search Telegram in your mobile/desktop app. You can also type resend at the code prompt. |
Emojis look like ASCII (D) instead of 🌙 |
Launched inside legacy Windows Console Host (conhost.exe) rather than Windows Terminal |
DeadMoon intentionally falls back to crisp ASCII glyphs on conhost.exe to prevent font corruption. Run inside Windows Terminal (wt.exe) for full moon emojis (🌑🌒🌓🌔🌕🌖🌗🌘). |
Cannot resolve a numeric -100... private channel ID |
Telethon needs the channel's access_hash in its local entity cache |
Make sure your account is a member of the channel. DeadMoon automatically refreshes your dialog cache once; you can also type list at the target prompt and select the chat by number. |
| Browser didn't open the QR popup | OS file association or browser restriction | Scan the matching high-contrast ANSI black-and-white block QR code printed right below in the console, or open .deadmoon_local\deadmoon_qr.html manually. |
Scrape pauses with Telegram FloodWait |
Telegram temporarily throttled rapid history or media requests | Leave the window open — DeadMoon counts down automatically and resumes from the exact message ID without losing progress. |
📄 License
This project is licensed under the MIT License — see the LICENSE file for details.
🌌 The DeadMoon Tool Suite
| Repository | Role in the Ecosystem |
|---|---|
| 🌕 DeadMoon-Download-Bot | Whitelisted 8-platform Telegram audio acquisition bot with direct lossless engines, lock-free scheduler & 477 offline tests |
| 📻 DeadMoon-Radio-Telegram-Synchronizer | Dockerized Telegram radio bot & dynamic 1280×720 RTMPS audio-visual livestream engine with 3-tier metadata auto-probe |
| 🤝 DeadMoon-Trade-Bot | Dockerized Telegram music & dubplate escrow bot with native-SR SoX spectrograms, FTS5 catalog indexer & group trade board |
| 📡 DeadMoon-Telegram-Scraper | Single-file Windows polyglot Telegram channel/group exporter with 4-layer URL intelligence, granular media harvesting & QR login |
| 🤖 DeadMoon-OpenHands-Launcher | Zero-friction Windows launcher & installer for OpenHands with kinetic ASCII UI & automatic winnat port recovery |
| 📚 DeadMoon-RaveBSD-Launcher | Zero-friction Windows installer & launcher for RaveBSD 2.0 with kinetic ASCII UI, auto-Docker setup & Downloads mapping |
| 🎓 DeadMoon-Scholarly-Harvester | Single-file Windows polyglot scholarly PDF harvester with 7-API Recursive Omni-Resolver, 25-source Quality Judge & Command Deck WebUI |
| 🌾 DeadMoon-Credential-Harvester | Local Tampermonkey userscript (2.3v) for harvesting streaming ARLs, OAuth tokens, Netscape cookies & Widevine .wvd bundles |
| 🔐 DeadMoon-Unified-Spotify-Provisioner | Automated Windows polyglot provisioner for Spotify Premium sp_dc cookies & Android Widevine L3 device.wvd CDMs |
| 🎶 DeadMoon-Playlist-Transfer-Tool | Single-file Windows polyglot tool for migrating Deezer Favorites (Artists, Albums & Playlists) via CSV |
| 🔍 DeadMoon-Universal-API-Verify-Script | Self-contained Windows LLM statistical fingerprint verifier (lmfpd) with Smart Auto-Heal & catalog scanner |
🌕 DeadMoon-Telegram-Scraper 🌙 — Crafted by @Deadplayerdmr