Dockerized Telegram music and dubplate trading escrow bot with native-sample-rate SoX spectrograms, Soulseek FTS5 catalog indexer, 1999 MB whole-folder swaps, and group trade board.
  • Python 95.6%
  • Batchfile 2.2%
  • Shell 2.1%
  • Dockerfile 0.1%
Find a file
2026-12-02 16:42:43 -05:00
assets chore: initial sanitized import of DeadMoon-Trade-Bot 2026-12-02 16:42:43 -05:00
handlers chore: initial sanitized import of DeadMoon-Trade-Bot 2026-12-02 16:42:43 -05:00
scripts chore: initial sanitized import of DeadMoon-Trade-Bot 2026-12-02 16:42:43 -05:00
tests chore: initial sanitized import of DeadMoon-Trade-Bot 2026-12-02 16:42:43 -05:00
trade_utils chore: initial sanitized import of DeadMoon-Trade-Bot 2026-12-02 16:42:43 -05:00
.gitignore chore: initial sanitized import of DeadMoon-Trade-Bot 2026-12-02 16:42:43 -05:00
docker-compose.yml chore: initial sanitized import of DeadMoon-Trade-Bot 2026-12-02 16:42:43 -05:00
Dockerfile chore: initial sanitized import of DeadMoon-Trade-Bot 2026-12-02 16:42:43 -05:00
main.py chore: initial sanitized import of DeadMoon-Trade-Bot 2026-12-02 16:42:43 -05:00
README.md chore: initial sanitized import of DeadMoon-Trade-Bot 2026-12-02 16:42:43 -05:00
requirements.txt chore: initial sanitized import of DeadMoon-Trade-Bot 2026-12-02 16:42:43 -05:00
token.env.example chore: initial sanitized import of DeadMoon-Trade-Bot 2026-12-02 16:42:43 -05:00

🌕 DeadMoon-Trade-Bot 🌙

Production-Grade Dockerized Telegram Music & Dubplate Escrow Bot with Native-Sample-Rate SoX Spectrograms, Soulseek FTS5 Catalog Indexer, 1,999 MB Whole-Folder Swaps & Group Trade Board (v1.2)

DeadMoon Suite Version 1.2 Python 3.12 PTB 21.6 Telethon MTProto Docker Compose

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 R A D E   B O T   🌙
      Dubplate Escrow, FTS5 Indexer & Spectral Verifier  •  Part of the DeadMoon Tool Suite by @Deadplayerdmr
  ════════════════════════════════════════════════════════════════════════════

🌙 Overview

DeadMoon-Trade-Bot (v1.2) is a production-grade, single-container Dockerized (x86_64 64-bit Linux) Telegram music and dubplate trading escrow bot, Soulseek-style SQLite FTS5 catalog indexer, automated native-sample-rate audio verifier (Uncapped Native-SR SoX Spectrograms + Nuanced Spectral Cutoff Analyzer + 112 kbps preview clip cutter), and group trade-board manager built for DuB Trade (t.me/DuBTradeGroup) and DeadMoon Archives (t.me/DeadMoonArchives).

It combines python-telegram-bot 21.6 with an integrated Telethon MTProto StringSession bridge on the same asyncio event loop to deliver bit-for-bit original audio files and whole-folder archives up to 1,999 MB, issuing cryptographic SHA-256 zero-retention receipts upon completion.


✨ Key Capabilities (v1.2)

1. Simultaneous Escrow Audio & Whole-Folder Swaps (/trade, /traderequests, /verify)

  • Concurrent Database-Backed Escrow (SQLite WAL): Trade sessions are keyed by compact 8-character hex IDs so simultaneous swaps never collide or overwrite each other.
  • Strict 1,999 MB (2,096,103,424 bytes) Hard Cap: Enforced consistently across /browse, /trade, /request, and /offer.
  • Whole-Folder & Dub-Pack Archive Trading (.zip, .rar, .7z up to 1,999 MB): Uncapped Native-SR SoX Spectrogram generation (asyncio.Semaphore(3)) batched into Telegram Media Group Albums (chunks of 5 for 2–15 tracks, chunks of 10 for >15 tracks) with FloodWait retry, optional 3 random 30-second preview clips vs. spectrograms-only, and custom 30-second clip requests (up to 2 custom timestamps per trade).
  • Nuanced Spectral Verification Badges: Renders 1200×600 SoX spectrograms without downsampling (preserving true Nyquist ceilings on 48 kHz / 96 kHz masters) and classifies full-bandwidth (~19.5+ kHz), honest lower-bitrate containers, and frequency-shelf notices cleanly.
  • Inline-Playable 100% Bit-for-Bit Original Delivery: Single tracks delivered via send_audio (<=20 MB) or Telethon MTProto DocumentAttributeAudio (>20 MB up to 1,999 MB) with zero re-encoding, verified via SHA-256 checksums.
  • Zero-Retention Cryptographic Escrow Receipt & /verify (/security): Completion receipts display Original SHA-256 checksums + exact UTC confirmation that /tmp/deadmoon_trades/<trade_id> was purged (0 bytes retained on server).
  • Anti-Boost Reputation System: Max +1 ⭐ per 24 hours per unique trader pair (reputation_awards).

2. Soulseek .xml & Dubplate-Aware FTS5 Catalog (/filelist, /search, /browse)

  • Clean Multi-Format Ingestion: Imports Soulseek .xml, .txt, .json, and .md file lists while automatically filtering 0-byte files, <10 KB stubs, .DS_Store, __MACOSX, and artwork/log clutter, plus selective folder filtering and Auto-Uncheck Sample Packs (<1.5 MB avg).
  • Dubplate Folder Context Inheritance: Single-name dubplates such as EPTIC/Eptic Unreleased tracks and Demos/Danger.mp3 automatically inherit Artist EPTIC and Album Eptic Unreleased tracks and Demos for accurate FTS5 search hits.
  • Transparent Air-Gapped Local Scanner Scripts (assets/): Self-contained Windows (DeadMoon_Scanner_Windows.bat) and macOS / Linux (DeadMoon_Scanner_Mac_Linux.sh) scripts with Fast Header vs. Deep ffprobe scan mode, real-time folder & every-25-files progress logs, and live SHA-256 checksums displayed directly in /filelist and /verify.
  • Whole-Folder Browsing (/browse): Displays recursive track counts and MB totals per folder with 1-click [📦 Trade Entire Folder] (<= 1,999 MB).

3. 3-Mode Trader Presence & Group Cleanliness (/register, /status, /tradeusers)

  • Supports auto (🟢 Online within 48h of bot or whitelisted group activity), online, and away, with automatic 7-day inactivity reset back to auto.
  • Strict DM-only command enforcement inside whitelisted groups (45s self-deleting redirect notice; 5m auto-delete on group /start or /help) powered by native asyncio tasks (zero PTBUserWarning: No JobQueue set up).

4. Group Trade Board Relay (/request, /offer, /cancelrequest, /canceloffer)

  • Supports single tracks AND entire folders / dub packs / LP archives (<= 1,999 MB) relayed directly into bound Group Trade Topics (e.g., -1002129306809 topic 1550) with DM misclick handshake protection.
  • Verified Upload /offer Mode: Supports single tracks and .zip/.rar/.7z archives, attaching the lead spectrogram + tracklist count and immediately purging /tmp.
  • Enforces 3/day creation and 7 active per-user quotas, with non-destructive 24h quota reset (quota_reset_at) that preserves all active board posts.

5. Comprehensive In-Telegram Administration (/admin, /adminhelp, /settradetopic, /report, /ban, /unban, /blacklist)

  • Admin / command menu registered automatically via BotCommandScopeChat.
  • Immediate paginated clickable trader directory + 🌕 Admin User Management Card 🌙 (non-destructive 24h quota reset, active post viewer/deleter, reputation editor + clear warnings/reports, official warning issuer with DM notification, warnings viewer, reports viewer for both against and sent reports, registration hours manager, catalog wipe, and ban/unban toggle).
  • System trade statistics reset (🗑️ Reset System Trade Stats) clearing historical counters without touching active trades, catalogs, or active board posts.

⚙️ Configuring token.env

Every setting in token.env is read live on access and persisted atomically with 0600 permissions (safe for Docker single-file bind mounts).

Key Default Purpose
TELEGRAM_BOT_TOKEN (required) Bot token from @BotFather.
TELEGRAM_API_ID 0 Telegram MTProto API ID from my.telegram.org (required for >20 MB Telethon transfers up to 1,999 MB).
TELEGRAM_API_HASH (required for >20 MB) Telegram MTProto API hash paired with TELEGRAM_API_ID.
ADMIN_ID 0 Primary numeric Telegram admin user ID.
EXTRA_ADMIN_IDS (blank) Optional comma-separated additional numeric admin user IDs.
WHITELISTED_GROUPS -1002126373823,-1002129306809 Comma-separated group chat IDs where passive activity tracking and DM-redirect guards operate.
GROUP_TRADE_TOPICS -1002129306809:1550 Per-group trade board forum topic mapping (group_id:topic_thread_id, editable live via /settradetopic).
MAX_REGISTRATION_HOURS 2222 Maximum hours a user can register as an active trader.
AUTO_AWAY_HOURS 48 Hours of inactivity before auto presence transitions to away.
MANUAL_STATUS_EXPIRY_DAYS 7 Days before manual online/away presence resets to auto.
CLIP_BITRATE 112k Bitrate for 30-second escrow verification preview clips.
TRADE_EXPIRY_HOURS 24 Hours before an incomplete escrow session expires and purges /tmp.
SEARCH_BROWSE_DELETE_MINUTES 30 Auto-delete timer for /search and /browse menus in DM.
MAX_TRADE_SIZE_MB 1999 Hard upper limit in MB for single-file and whole-folder/archive swaps (clamped to 1..1999).
REQUESTS_ENABLED 1 Toggle /request group trade-board wizard (1 = on, 0 = off).
OFFERS_ENABLED 1 Toggle /offer group trade-board wizard (1 = on, 0 = off).
XML_IMPORTS_ENABLED 1 Toggle catalog file-list uploads via /filelist.
DAILY_REQUEST_LIMIT 3 Maximum new /request board posts per user per 24h.
MAX_ACTIVE_REQUESTS 7 Maximum simultaneous active /request posts per user.
DAILY_OFFER_LIMIT 3 Maximum new /offer board posts per user per 24h.
MAX_ACTIVE_OFFERS 7 Maximum simultaneous active /offer posts per user.

🎛️ Telegram Commands

👤 Trader Profile & Presence

Command Description
/start / /help Interactive Help Hub with beginner guide, catalog guide, spectrogram explainer, board rules, and live /verify view.
/register Activate or renew your trader pass (up to 2,222h).
/unregister End trader registration early.
/status [online|away|auto] Set your 3-mode trader presence badge.
/genreofinterest Set your preferred genres (max 32 characters).
/tradeusers Browse active registered traders, presence badges, and reputation scores.

📂 Catalog, Search & Browse

Command Description
/filelist (or /sharefilelist) Upload Soulseek .xml/.txt/.json/.md lists, filter sample packs, or download air-gapped Windows/Mac/Linux scanner scripts.
/search <query> Global FTS5 catalog search across all active traders with punctuation/filler normalization and 1-click trade triggers.
/browse Interactive catalog explorer organized By Folders or By Artists with whole-folder swap buttons (<= 1,999 MB).

🤝 Escrow Trading, Group Board & Verification

Command Description
/trade @username Initiate a simultaneous escrow swap for single tracks or .zip/.rar/.7z dub packs.
/traderequests (or /accepttrade) View and manage incoming, outgoing, and active escrow trades.
/cancel Cancel an active wizard or abort an active trade (purging temp files).
/request / /cancelrequest Post or close a Group Trade Board track/folder request from DM.
/offer / /canceloffer Post or close a standard or Verified-Spectrogram Group Trade Board offer from DM.
/verify (or /security) Displays GitHub links, live scanner SHA-256 checksums, and a real-time /tmp/deadmoon_trades zero-retention audit.
/report @username [reason] Report scam attempts or fake transcodes to admins.

🛡️ Administration (ADMIN_ID Only)

Command Description
/admin / /adminhelp Opens the paginated trader management directory, user cards, system toggles, and trade stats controls.
/settradetopic <link_or_id> Binds or updates a whitelisted group's forum topic ID (supports t.me/DuBTradeGroup/1550, t.me/c/..., or bare integer).
/ban / /unban / /blacklist Manage trader bans and inspect blacklisted accounts.

🚀 Quick Deployment (64-bit Linux VPS with Docker)

The container uses python:3.12-slim-bookworm with sox, libsox-fmt-all, ffmpeg, unzip, unrar-free, p7zip-full, libmagic1, and tini as PID 1.

git clone https://github.com/Deadplayerdmr/DeadMoon-Trade-Bot.git
cd DeadMoon-Trade-Bot
cp token.env.example token.env
chmod 600 token.env
nano token.env   # fill in TELEGRAM_BOT_TOKEN, TELEGRAM_API_ID, TELEGRAM_API_HASH, ADMIN_ID
docker compose up -d --build

Monitor live logs:

docker logs -f DeadMoon_Trade_Bot

Volume Mounts

Host / Volume Container Path Purpose
./token.env /app/token.env (rw) Hot-reloadable configuration and admin topic/toggle persistence
./data /app/data (rw) Persistent SQLite WAL + FTS5 database (tradebot.db)
trade_temp (named volume) /tmp/deadmoon_trades Ephemeral escrow staging workspaces purged immediately after every completed/cancelled trade

🧪 Running Tests & Building Release Archives

Run the offline unit test suite:

python3 -m unittest discover -s tests -v

Build release bundles:

python3 scripts/package_releases.py

Generates githubready.zip (sanitized for public GitHub publication) and deploy.zip (pre-configured VPS deployment bundle — never commit deploy.zip).


🔧 Troubleshooting

Symptom Cause Solution
Commands typed in the group disappear with a redirect notice Intentional DM-only cleanliness guard in whitelisted groups Click 💬 Open Bot in Private Chat and run /search, /browse, /trade, /request, or /offer in DM.
Files larger than 20 MB fail to transfer Telethon MTProto bridge is missing TELEGRAM_API_ID or TELEGRAM_API_HASH Populate both keys from my.telegram.org in token.env and restart with docker compose restart.
Folder/archive rejected for size Exceeds the strict 1,999 MB (2,096,103,424 bytes) Telegram MTProto cap Split oversized packs into archives <= 1,999 MB before uploading.
Board posts land in the wrong group topic GROUP_TRADE_TOPICS needs updating Run /settradetopic <topic_link_or_id> as admin to rebind cleanly.
Need to verify zero-retention or scanner integrity Transparency check Run /verify (or /security) in DM for live scanner SHA-256 hashes and an active /tmp/deadmoon_trades file count audit.

🌌 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-Trade-Bot 🌙 — Crafted by @Deadplayerdmr