Tgin
infrastructure layer for high-load Telegram bots
Install / Use
/learn @chesnokpeter/TginREADME
__
/\ \__ __
\ \ ,_\ __ /\_\ ___
\ \ \/ /'_ `\/\ \ /' _ `\
\ \ \_/\ \L\ \ \ \/\ \/\ \
\ \__\ \____ \ \_\ \_\ \_\
\/__/\/___L\ \/_/\/_/\/_/
/\____/
\_/__/
dedicated routing layer for Telegram bot infrastructure that enables efficient distribution of incoming updates across multiple bot instances. Think of it as NGINX for Telegram's Bot API ecosystem
[!IMPORTANT] active development is continuing: there is no stable version yet
Why Tgin?
-
Load balancing: distributes Telegram updates evenly across multiple bot instances
-
Protocol flexibility: Supports both webhook and longpoll methods for receiving and sending updates
-
Framework integration: works with any Telegram bot framework
-
Scalability: enables horizontal scaling by adding more bot instances without code changes
-
Zero-downtime deployments: update or restart bot instances without interrupting service
-
Microservices support: route updates to specialized bot services in a distributed architecture
-
Production reliability: includes health monitoring, automatic retries, and failover handling
Architecture Overview
Telegram Bot API
↓ Webhook / LongPoll
TGIN
↓ Webhook / LongPoll
Bot Instance 1 | Bot Instance 2 | Bot Instance N
Quick start
# Clone the repository
git clone https://github.com/chesnokpeter/tgin.git
cd tgin
# Build the project
cargo build --release
# Start with config
./target/release/tgin -f tgin.ron
Configuration
Simple configuration in the ron
// tgin.ron
(
dark_threads: 6,
server_port: Some(3000),
updates: [
LongPollUpdate(
token: "${TOKEN}",
)
],
route: RoundRobinLB(
routes: [
LongPollRoute(path: "/bot1/getUpdates"),
WebhookRoute(url: "http://127.0.0.1:8080/bot2"),
]
)
)
Future features
- Complete API
- More tests / Performance tests
- Perfect logging
- Anti-DDoS guard
- Message-brokers support
- Microservices-style
- Collect analytics
- Cache for bot
- Support userbots
- Tests for Bot
Main Goal
Provide a complete infrastructure toolkit for building scalable, high-load Telegram bots with microservices architecture and production-ready support
Performance
<table> <tr> <td><img src="tests/performance/diagram/loss.png" alt="Loss Rate" width="500"></td> <td><img src="tests/performance/diagram/median.png" alt="Median Latency" width="500"></td> </tr> <tr> <td><img src="tests/performance/diagram/mean.png" alt="Mean Latency" width="500"></td> <td><img src="tests/performance/diagram/max.png" alt="Max Latency" width="500"></td> </tr> </table>Related Skills
himalaya
346.4kCLI to manage emails via IMAP/SMTP. Use `himalaya` to list, read, write, reply, forward, search, and organize emails from the terminal. Supports multiple accounts and message composition with MML (MIME Meta Language).
taskflow
346.4kname: taskflow description: Use when work should span one or more detached tasks but still behave like one job with a single owner context. TaskFlow is the durable flow substrate under authoring layer
tmux
346.4kRemote-control tmux sessions for interactive CLIs by sending keystrokes and scraping pane output.
coding-agent
346.4kDelegate coding tasks to Codex, Claude Code, or Pi agents via background process
