How rootmax84/pytgw works
PYTGW is a Python Telegram Bot API reverse proxy. Clients send Bot API requests to its FastAPI routes; the gateway parses the token and method, forwards the request to Telegram, and returns the upstream response. The main runtime also provides health checks, request safeguards, configurable outbound connections, retries, and token-masked logging. The repository has one substantial source file, so these responsibilities share its path. Some features are documented in the README but their implementation details are not shown in the excerpts.
Main entry points: main.py Request handler
Components 13
Gateway entry
- HTTP routes
app/main.py - Health check
app/main.py - Request handler
app/main.py
Request safeguards
- Trusted proxy handling
app/main.py - Connection ID guard
app/main.py - Body size limit
app/main.py
Proxy runtime
- Token and method parsing
app/main.py - Payload forwarding
app/main.py - Async HTTP client
app/main.py - Masked logging
app/main.py
Other components
- Bot API client
- Telegram Bot API
- SOCKS5 proxy
Connections 9
- Bot API client → HTTP routes: sends requests
README.md - HTTP routes → Health check: serves health
app/main.py - HTTP routes → Request handler: dispatches to
app/main.py - Request handler → Token and method parsing: parses path
app/main.py - Request handler → Payload forwarding: forwards request
app/main.py - Payload forwarding → Async HTTP client: sends request
app/main.py - Async HTTP client → Telegram Bot API: proxies Bot API
README.md - Async HTTP client → SOCKS5 proxy: routes optionally
README.md - Request handler → Masked logging: masks tokens
README.md