yawaflua.Telegram.Net
1.0.2
dotnet add package yawaflua.Telegram.Net --version 1.0.2
NuGet\Install-Package yawaflua.Telegram.Net -Version 1.0.2
<PackageReference Include="yawaflua.Telegram.Net" Version="1.0.2" />
<PackageVersion Include="yawaflua.Telegram.Net" Version="1.0.2" />
<PackageReference Include="yawaflua.Telegram.Net" />
paket add yawaflua.Telegram.Net --version 1.0.2
#r "nuget: yawaflua.Telegram.Net, 1.0.2"
#:package yawaflua.Telegram.Net@1.0.2
#addin nuget:?package=yawaflua.Telegram.Net&version=1.0.2
#tool nuget:?package=yawaflua.Telegram.Net&version=1.0.2
Telegram Bot Attribute Handlers
This project provides a set of C# attributes to facilitate the handling of different types of Telegram bot updates using reflection.
Features
- Inline Query Handling (
InlineAttribute
) - Edited Message Handling (
EditMessageAttribute
) - Command Handling (
CommandHandlerAttribute
) - Callback Query Handling (
CallbackAttribute
) - PreCheckout Query Handling (
PreCheckoutAttribute
) - General Update Handling (
UpdateAttribute
) - Auto-generate telegram client
Installation
Ensure you have the required dependencies installed:
dotnet add package yawaflua.Telegram.Net
Usage
Provide dependencies in class
You can provide dependencies in class from constructor, and after it use it like static
.
public class Example : IUpdatePollingService
{
private static MyCoolService _service; // It should to be static!
public Example(MyCoolService service)
{
_service = service;
}
}
Inline Query Handling
Use the InlineAttribute
to register a method as an inline query handler.
[Inline("example_query")]
public static async Task HandleInlineQuery(ITelegramBotClient bot, InlineQuery query, CancellationToken cancellationToken)
{
// Handle inline query
}
Edited Message Handling
Use the EditMessageAttribute
to register a method as a handler for edited messages.
[EditMessage]
public static async Task HandleEditedMessage(ITelegramBotClient bot, Message message, CancellationToken cancellationToken)
{
// Handle edited message
}
Command Handling
Use the CommandHandlerAttribute
to register a method as a command handler.
You can provide only begin of command text. Like, /start act-
[CommandHandler("/start")]
public static async Task StartCommand(ITelegramBotClient bot, Message message, CancellationToken cancellationToken)
{
// Handle start command
}
Callback Query Handling
Use the CallbackAttribute
to register a method as a callback query handler.
You can provide only begin of callback data text
[Callback("button_click")]
public static async Task HandleCallbackQuery(ITelegramBotClient bot, CallbackQuery query, CancellationToken cancellationToken)
{
// Handle callback query
}
PreCheckout Query Handling
Use the PreCheckoutAttribute
to register a method as a pre-checkout query handler.
[PreCheckout]
public static async Task HandlePreCheckoutQuery(ITelegramBotClient bot, PreCheckoutQuery query, CancellationToken cancellationToken)
{
// Handle pre-checkout query
}
General Update Handling
Use the UpdateAttribute
to register a method as a generic update handler.
[Update]
public static async Task HandleUpdate(ITelegramBotClient bot, Update update, CancellationToken cancellationToken)
{
// Handle general update
}
We know about this bugs:
- [ X ] Not working providing dependencies in class constructor and this gives an error.
Try to not use provided dependencies in class. We are should to fix it in v1.0.2.Now just use static variables
License
This project is open-source and available under the Apache 2.0 License.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. 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. |
-
net7.0
- Microsoft.Extensions.Hosting.Abstractions (>= 9.0.3)
- Telegram.Bot (>= 22.4.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.