Skip to content

Telegramper is the Telegram.Framework, which is similar to ASP.Net Core. It contains services, middleware, configuration, controllers (executors), and more.

Notifications You must be signed in to change notification settings

GineTik/Telegramper-TelegramFramework

Repository files navigation

Telegramper

It is framework similar to a ASP.Net Core. Framework contains services, middlewares, configuration, controllers(executors) and other.

The framework is under development, so unexpected errors, changes in functionality, and names are possible! I would be grateful if you could report any bugs or functionality you need.

Installation

To install the framework, you can use NuGet.org https://www.nuget.org/packages/Telegramper.

Learn more about the framework

  1. About UpdateContext (similar to HttpContext)
  2. Configuration bot in Program.cs (Services, Middlewares, etc.)
  3. Executors and attributes
  4. Session

Chapters coming soon

  • Dialog (comleted, documentation in process)
  • Examples of projects written on the Telegramper framework

Donates

If you want to support to me, you can do it send me a crypto: BNB Smart Chain 0x0aB4b9A02bcaF822c3AeA91bc566aEA4194e1cEF

Quick start

internal class Program
{
   static void Main(string[] args)
   {
       var builder = new BotApplicationBuilder();
       builder.ConfigureApiKey("your api key");
       builder.ReceiverOptions.ConfigureAllowedUpdates(UpdateType.Message, UpdateType.CallbackQuery); // default is UpdateType.Message
       builder.Services.AddExecutors(); // identical to the controller in ASP.Net Core
   
       var app = builder.Build();
       app.UseExecutors();
       app.RunPolling(); // webhooks are not implemented, but in the future you will be able to, for example, change polling to webhooks and vice versa
   }
}

public class BasicExecutor : Executor
{
    [TargetCommand] // identical to [TargetCommand("start")]
    public async Task Start()
    {
        var sender = UpdateContext.User.ToString();
        await Client.SendTextMessageAsync($"You are {sender}"); // send a text response
    }

    [TargetCommand("echo, command2")]
    [EmptyParameterSeparator] // remove separator, by default is space(" ")
    public async Task Echo(string phrase) // more about the parameters later 
    {
        await Client.SendTextMessageAsync(phrase);
    }
}

About

Telegramper is the Telegram.Framework, which is similar to ASP.Net Core. It contains services, middleware, configuration, controllers (executors), and more.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages