How danog/madelineproto works
MadelineProto is an asynchronous PHP client for Telegram’s MTProto API, supporting phone-number and bot-token accounts without using the Bot API. A client starts or logs in, invokes Telegram methods through its API namespaces, and exchanges MTProto traffic with Telegram; incoming updates can be converted to typed events and dispatched to user handlers. Other major capabilities include file transfer, broadcasting, IPC/persistence, private and group calls, and VoIP media. The graph follows the README and tree; where implementation excerpts were unavailable, subsystem wiring is shown only when the documented client workflow supports it.
Main entry points: Namespace API namespaces · MTProto.php MTProto engine · API.php Client API · EventHandler.php Event handlers
Components 20
Client API
- Client API
src/API.php - Login and auth
src/MTProtoSession/AuthKeyHandler.php - API namespaces
src/Namespace - Session state
src/Settings/Database
MTProto transport
- MTProto engine
src/MTProto.php - Connections
src/Connection.php - Protocol crypto
src/MTProtoTools/Crypt.php
Updates and handlers
- Update processing
src/MTProtoTools/UpdateHandler.php - Event handlers
src/EventHandler.php - Update filters
src/EventHandler/Filter - Plugins
src/PluginEventHandler.php
Messaging features
- Broadcasting
src/Broadcast/Broadcast.php - File transfer
src/MTProtoTools/Files.php - IPC
src/Ipc/Client.php
Calls and media
- Private calls
src/Tgcalls/PrivateCallController.php - Group calls
src/GroupCall/GroupCallController.php - VoIP media
src/Loop/VoIPLoop.php - Media codecs
src/Matroska.php
Other components
- Application
- Telegram
Connections 26
- Application → Client API: starts client
- Client API → Login and auth: logs in
- Client API → API namespaces: exposes methods
- API namespaces → MTProto engine: invokes methods
- Login and auth → MTProto engine: establishes keys
- MTProto engine → Connections: sends traffic
- Connections → Telegram: exchanges MTProto
- MTProto engine → Protocol crypto: encrypts messages
- MTProto engine → Session state: persists session
- Telegram → Update processing: delivers updates
- Update processing → Event handlers: dispatches events
- Event handlers → Update filters: applies filters
- Event handlers → Plugins: loads handlers
- Application → Broadcasting: configures broadcast
- Broadcasting → API namespaces: sends messages
- Application → File transfer: requests transfer
- File transfer → API namespaces: calls upload methods
- Application → IPC: uses client remotely
- Client API → IPC: supports IPC
- Application → Private calls: controls calls
- Private calls → VoIP media: runs media loop
- Application → Group calls: controls group calls
- Group calls → VoIP media: runs media loop
- VoIP media → Media codecs: processes streams
- Private calls → API namespaces: signals calls
- Group calls → API namespaces: signals calls