Telegram Uploader Bot (Telegram Serverless)
Telegram Uploader Bot (Telegram Serverless) (AZiPA/telegram-uploader-bot) is a production-grade Telegram file storage and distribution bot built natively for Telegram Serverless (@tgcloud/cli 0.2.0). It executes inside Telegram’s V8 Serverless isolates backed by a built-in SQLite database—requiring zero VPS, zero external hosting, zero runtime node_modules, and zero process.env.
High-Level Delivery Flow
Section titled “High-Level Delivery Flow”flowchart LR Admin["Admin Upload (/upload or /batch)"] --> Isolate["Telegram Serverless (V8 Isolate)"] Isolate <--> SQLite["21-Table SQLite (sdk/db)"] Isolate <--> Mirror["Optional Storage Channel Mirror"] Isolate --> Gate["Force-Join Gate & Quota Check"] Gate --> User["User Deep-Link Delivery (?start=code)"]
Core Capabilities
Section titled “Core Capabilities”1. Single & Batch Uploads Across 8 Media Types
Section titled “1. Single & Batch Uploads Across 8 Media Types”- Flexible Upload Sessions: Send
/uploadfor a single item or/batchfor multi-file bundles up to 25 items (MAX_BUNDLE_ITEMS = 25), committed with/doneor aborted with/cancel. Media groups (albums) are tracked atomically viaupload_sessionsandupload_items. - Dynamic Media Allowlist: Supports
photo,document,video,audio,voice,video_note,animation, andsticker. Runtime filtering readssystem_config.allowed_media_types(default:['photo', 'document', 'video', 'audio']), configurable via the Owner Media GUI.
2. Storage Channel Mirroring & Resilient Fallback
Section titled “2. Storage Channel Mirroring & Resilient Fallback”- Automatic Redundancy: Optionally mirror every upload to a private storage channel via
api.copyMessage(). - Self-Healing Delivery: Delivery tries direct
file_idsending first and transparently falls back toapi.copyMessages()from the storage channel onsource_deaderrors (FILE_REFERENCE_EXPIRED,wrong remote file identifier). If storage permissions are revoked or content protection is enabled on the storage channel, mirroring self-disables (storage_channel_active = 'false') and alerts the log channel.
3. Chunked Delivery, Protection & Ephemeral Lifecycles
Section titled “3. Chunked Delivery, Protection & Ephemeral Lifecycles”- Idempotent 10-Item Pagination: Large bundles deliver in chunks of 10 items (
CHUNK_DELIVERY_SIZE = 10) with progress headers (Part 1/3) and inline continuation (dl:p:o:<operation_id>:<offset>), protected against duplicate webhook retries by atomic leases inrouter_updates. - Content Protection & Link Formats: Regular bundles receive 8-character Base62 codes; protected bundles (
protect_content: true) receive 36-character RFC 4122 UUID v4 links (crypto.randomUUID()). Enabling protection on a Base62 bundle automatically upgrades its code to UUID v4. - Ephemeral Controls & Live Link Rotation: Supports queued auto-delete (
/setautodel), per-bundle or global TTL expiration (/setexpiry,/setbundlettl), atomic one-time burn bundles (is_one_timeviadelivery_claims), and live link rotation that updates/postbundlechannel post buttons viaapi.editMessageReplyMarkup().
4. Force-Join Gatekeeping & Community Engagement
Section titled “4. Force-Join Gatekeeping & Community Engagement”- Bounded Parallel Verification: Supports up to 8 mandatory Force-Join channels (
MAX_FORCE_JOIN_CHANNELS = 8), checked in batches of at most 6 outgoing sockets (MAX_OUTGOING_SOCKETS = 6) with a 15-second in-memory cache and 3-second verify button cooldown (FORCE_JOIN_THROTTLE_SEC = 3). - Voting & Custom Emoji Circuit Breaker: Built-in per-user like/dislike voting (
bundle_votes) and optional Telegram Premium<tg-emoji>tags protected by an automatic circuit breaker that falls back to plain Unicode onENTITY_CUSTOM_EMOJI_INVALID.
5. Five-Level Role Hierarchy & Fail-Closed Security
Section titled “5. Five-Level Role Hierarchy & Fail-Closed Security”- Granular RBAC: Enforces 5 access levels—Owner (Level 4), SuperAdmin (Level 3), Admin (Level 2), VIP (Level 1), and User (Level 0).
- Fail-Closed Operations: Restricts interactions to private chats (
private_only), enforces Zero-State initialization (bot_uninitialized) until ownership is claimed, limits abuse with sliding-window rate limiting (MAX_STRIKES = 5,1800s lockout), supports clean two-step ownership transfer, and provides an Owner-only SQLite console (/sql,/terminal).
Next Steps
Section titled “Next Steps”- Setup & Deployment — Configure
@BotFather, deploy with GitHub Actions CI or@tgcloud/cli, and initialize ownership. - Uploads, Delivery & Protection — Explore upload workflows, storage fallback, link rotation, and Force-Join mechanics.
- Roles, Security & Operations — Review the 5-level role hierarchy, rate limiting, ownership transfer, and SQLite console.
- Commands & Configuration — Browse all role-grouped commands,
system_configkeys, and runtime constants. - Architecture & SQLite Schema — Inspect V8 isolate invariants, the 3 handlers, and all 21 SQLite tables.