Ultra-Fast RAW MTProto Bot

Customer: AI | Published: 22.11.2025

I’m building a lightning-quick Telegram “claim” bot and need a fully hand-rolled RAW MTProto 2.0 client written in Python—absolutely no Telethon, Pyrogram, or similar abstractions. Your code must open its own encrypted TCP socket straight to DC5 (or gracefully pick the correct DC when needed), complete the full MTProto handshake, and load an auth_key from a supplied .session string. Once connected it should poll the server with messages.getChannelDifference, parse every UpdateNewChannelMessage (including embedded messages and reply_markup objects), spot any callback button that contains the word “claim,” and fire messages.getBotCallbackAnswer with minimal delay. Performance targets are strict: detect in 1-10 ms and respond within 40-100 ms. The program also needs to stay online for hours, automatically handling BAD_SERVER_SALT, FLOOD_WAIT, clock drift, and unexpected disconnects, then resuming seamlessly. All TL objects must be encoded/decoded by your own serializer or generator; wrappers that abstract MTProto are off-limits. Deliverables • Well-documented Python source (single entry script plus any schema generator you build) • README explaining setup, run commands, and how to reproduce the latency numbers • Demonstrable log or short screen capture proving a sub-100 ms click in a live test Acceptance criteria I’ll load my session string, point the bot at my test channel, and watch it sustain a two-hour run while meeting the latency budget and automatically recovering from forced disconnects. Meet that bar and the project is done.