PmEngine.Telegram 2.96.108.1848

dotnet add package PmEngine.Telegram --version 2.96.108.1848
                    
NuGet\Install-Package PmEngine.Telegram -Version 2.96.108.1848
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PmEngine.Telegram" Version="2.96.108.1848" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PmEngine.Telegram" Version="2.96.108.1848" />
                    
Directory.Packages.props
<PackageReference Include="PmEngine.Telegram" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add PmEngine.Telegram --version 2.96.108.1848
                    
#r "nuget: PmEngine.Telegram, 2.96.108.1848"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package PmEngine.Telegram@2.96.108.1848
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=PmEngine.Telegram&version=2.96.108.1848
                    
Install as a Cake Addin
#tool nuget:?package=PmEngine.Telegram&version=2.96.108.1848
                    
Install as a Cake Tool

PMEngine.Telegram

Модуль для работы с Telegram

Используемые переменные

В модуле используются следующие переменные среды:

BOT_TOKEN - Токен ТГ бота
HOST_URL - URL приложения, куда будут приходить запросы от Telegram

Подключение

Подключение модуля

Для подключения модуля необходимо просто добавить его в список сервисов

builder.Services.AddTelegramModule();

Так же при добавлении можно сконфигурировать модуль, например:

builder.Services.AddTelegramModule(tg => tg.DefaultInLineMessageAction = MessageActionType.Delete);

Настройка веб-хука

Для настройки веб-хука необходимо выполнить следующее

builder.Services.AddHttpClient("tgwebhook").AddTypedClient<ITelegramBotClient>(httpClient => new TelegramBotClient(envBotToken, httpClient));

...

app.UseEndpoints(ep =>
{
    ep.MapControllerRoute(name: "tgwebhook",
        pattern: $"TGBot/{envBotToken}",
        new { controller = "TGBot", action = "Post" });
    ep.MapControllers();
});

Создание контроллера

Для приема запросов от Telegram необходимо добавить в приложение свой контроллер. Пример простого контроллера приведен ниже:

public class TGBotController : ControllerBase
{
    private readonly ILogger<TGBotController> _logger;
    private readonly ITelegramBotClient _client;
    private readonly IServiceProvider _serviceProvider;
	
	public TGBotController(IServiceProvider services, ILogger<TGBotController> logger, ITelegramBotClient botClient)
	{
		_logger = logger;
		_client = botClient;
		_serviceProvider = services;
	}
	
	[HttpPost]
	public async Task Post([FromBody] Update update)
	{
		var tgcontroller = new BaseTGController();
		await tgcontroller.Post(update, _client, _logger, _serviceProvider);
	}
}

Он использует класс BaseTGController для обработки сообщений. Если вам необходимо обернуть обработку по-особому, то вы можете изменить логику контроллера на свою, опирась на код этого класса.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.96.108.1848 171 1/8/2026
2.96.108.220 146 1/7/2026
2.96.106.142 135 1/5/2026
2.96.105.2141 146 1/5/2026
2.96.105.1850 138 1/5/2026
2.96.105.1803 131 1/5/2026
2.96.105.1741 140 1/5/2026
2.96.105.1734 125 1/5/2026
2.96.105.1643 130 1/5/2026
2.95.1205.2253 658 12/5/2025
2.95.1204.2156 240 12/4/2025
2.95.1204.1946 222 12/4/2025
2.95.1204.1942 243 12/4/2025
2.95.1116.233 447 11/20/2025
2.95.1109.1545 257 11/9/2025
2.95.1107.2346 167 11/7/2025
2.95.1017.2318 167 10/17/2025
2.95.1017.2305 166 10/17/2025
1.905.515.1304 387 5/15/2025
1.905.510.1847 202 5/10/2025
Loading failed