Telefrag is a cross-platform library, service, and suite of utilities that let you rapidly develop Telegram integrations — bots, payments, authentication — in .NET (and eventually JavaScript), with a toolkit full of ready-made, reusable components.
- Full documentation: GitHub wiki
- License: MIT
Telefrag is under active development, and completion varies a lot by package — some layers are solid, others are still stubs:
| Package | Status | Purpose |
|---|---|---|
Telefrag.Common |
~80% | Shared utilities and constructs required by every other package — DI container, state machine, parsing, storage abstractions. |
Telefrag.Bots |
~80% | Low-level Bot API client. Sends/receives Updates and Events, handles polling and webhooks. |
Telefrag.Security |
~80% | Default authorization model / access-control framework. |
Telefrag.Bots.Toolkit |
~35% | Higher-level abstractions on top of Telefrag.Bots — Command, Callback, Menu, Code, etc. |
Telefrag.Clients |
~1% | Full self-contained MTProto client — connect as a user or bot account without going through the REST Bot API. Half-finished and currently paused: testing it against a live account got that account banned by Telegram, so treat it as experimental until that's sorted out. |
Telefrag.Bots.Utility |
planned | UtilityBot — a diagnostics/learning bot for exploring Telefrag itself via Telegram. |
Telefrag.Data.SqlServer |
~1% | SQL Server-backed ObjectStore (see Telefrag.Storage.EFCore in this repo). |
Hosting layers (console/service/IIS hosts, web/WPF admin consoles) are on the backburner and not currently prioritized.
| Folder | Project | Notes |
|---|---|---|
TelefragCore |
Telefrag.Bots.csproj |
Folder name predates a project rename — this is the Telefrag.Bots package. |
Telefrag.Common |
Telefrag.Common.csproj |
Shared core. |
Telefrag.Bots.Toolkit |
Telefrag.Bots.Toolkit.csproj |
Command/Callback/Menu abstractions. |
Telefrag.Security |
Telefrag.Security.csproj |
Access control / authorization. |
Telefrag.Clients |
Telefrag.Clients.csproj |
MTProto client ("FragLib") — see its own README. |
Telefrag.Storage.EFCore |
Telefrag.Storage.EFCore.csproj |
EF Core storage adapter. |
Telefrag.FSharp |
Telefrag.FSharp.fsproj |
F# bindings/codegen. |
Telefrag.Tools |
Telefrag.Tools.csproj (fragutil) |
CLI for scaffolding C# types from the Telegram Bot API schema. |
Telefrag.Tests |
Telefrag.Tests.csproj |
MSTest suite covering Bots, Common, Storage, and Toolkit. |
Telefrag.Clients.Test |
Telefrag.Clients.Test.csproj |
Manual console harness for the MTProto client (not automated tests). |
WebTest |
WebTest.csproj |
ASP.NET Core scratch/sandbox project for exercising bots locally. |
The minimal path to a working bot:
- Talk to @BotFather on Telegram to register a bot and get a token. Read Telegram's bot rules first.
- Reference
Telefrag.BotsandTelefrag.Commonfrom your project. - Create and configure a
Botinstance, then either poll for updates or wire up a webhook (ASP.NET extension methods are provided to make this easy fromStartup.cs). - Optionally add
Layers(fromTelefrag.Bots.Toolkit) to compose reusable functionality instead of writing one big bot class.
Two connection modes work today: a bot token over the REST Bot API, either against Telegram directly or against a third-party Bot API server. Connecting as a full MTProto client (Telefrag.Clients) is not yet supported end-to-end — see Status above.
The wiki lays out three ways to structure a bot, in increasing order of reusability and setup cost:
- Bot as a service/component — instantiate
Bot, callBot.Methods, subscribe toBot.Events. Simple, but business logic stays outside the bot class. - Bot as a base class — subclass
Botand put your logic directly in the derived class. Fastest to build, least reusable. BotLayeras building blocks — compose independent, shareableBotLayers (e.g. a Greeter layer, a Bouncer layer) into one bot. Most reusable, most upfront design work.
See Determining Your Bot Design Plan on the wiki for the full writeup.
Full documentation lives in the GitHub wiki, including pages on dependency injection, error handling, security, serialization, and more.
MIT — see LICENSE.