8000
Skip to content

Repository files navigation

Telefrag

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.

Status

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.

Repository layout

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.

Getting started

The minimal path to a working bot:

  1. Talk to @BotFather on Telegram to register a bot and get a token. Read Telegram's bot rules first.
  2. Reference Telefrag.Bots and Telefrag.Common from your project.
  3. Create and configure a Bot instance, then either poll for updates or wire up a webhook (ASP.NET extension methods are provided to make this easy from Startup.cs).
  4. Optionally add Layers (from Telefrag.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.

Picking a design

The wiki lays out three ways to structure a bot, in increasing order of reusability and setup cost:

  1. Bot as a service/component — instantiate Bot, call Bot.Methods, subscribe to Bot.Events. Simple, but business logic stays outside the bot class.
  2. Bot as a base class — subclass Bot and put your logic directly in the derived class. Fastest to build, least reusable.
  3. BotLayer as building blocks — compose independent, shareable BotLayers (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.

Documentation

Full documentation lives in the GitHub wiki, including pages on dependency injection, error handling, security, serialization, and more.

License

MIT — see LICENSE.

About

Telefrag is a cross-platform library, service, and suite of utilities that allow you to rapidly develop Telegram integrations (bots, payments, authentication) in either .NET or JavaScript with a toolkit full of ready-made reusable components. Telefrag abstracts away all of Telegram's API details, persistent state and storage, webhooks, certificat…

Topics

Resources

Stars

7 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

0