Plugins & Extensions
MTGo has a rich extension ecosystem across three categories:
Plugin System
MTGo supports a plugin system that lets you encapsulate reusable logic and attach it to a Client via client.Use(plugin).
Every plugin implements the telegram.Plugin interface:
go
type Plugin interface {
Name() string
Start(ctx context.Context, client *telegram.Client) error
Stop(ctx context.Context) error
}Register a plugin before calling client.Connect:
go
client.Use(myPlugin)Official Plugins
| Plugin | Description |
|---|---|
| i18n | Internationalization with YAML/FTL formats, pluralization, and gender-aware translations |
| Conversations | Stateful multi-step conversation flows with wait, filter, and timeout support |
Middlewares
MTGo has two middleware levels for different concerns:
| Level | Method | Intercepts | Use case |
|---|---|---|---|
| Invoker | UseInvokerMiddleware | Outgoing RPC calls | Rate limiting, flood wait, logging |
| Handler | UseMiddleware | Incoming update dispatch | Auth, i18n, conversation state |
Official invoker middlewares:
| Middleware | Description |
|---|---|
| Flood Wait | Auto-handles FLOOD_WAIT errors with sleep and retry |
| Rate Limit | Token-bucket rate limiter for outgoing RPC calls |
See Invoker Middlewares for full documentation.
Templates
Bootstrap new extensions with official templates:
| Template | Description |
|---|---|
| Plugin Template | Starting point for new plugins |
| Middleware Template | Starting point for new invoker middlewares |
Ecosystem Repositories
| Repository | Description |
|---|---|
| mtgo-labs/mtgo | Core library |
| mtgo-labs/storage | Storage adapters (SQLite, PostgreSQL, MongoDB, Redis, GORM) |
| mtgo-labs/plugins | Official plugins (i18n, conversations) |
| mtgo-labs/middlewares | Official middlewares (flood wait, rate limit) |
| mtgo-labs/plugins-template | Plugin template |
| mtgo-labs/middlewares-template | Middleware template |
