Telegram.Bot.AttributeCommands 1.0.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package Telegram.Bot.AttributeCommands --version 1.0.3                
NuGet\Install-Package Telegram.Bot.AttributeCommands -Version 1.0.3                
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="Telegram.Bot.AttributeCommands" Version="1.0.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Telegram.Bot.AttributeCommands --version 1.0.3                
#r "nuget: Telegram.Bot.AttributeCommands, 1.0.3"                
#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.
// Install Telegram.Bot.AttributeCommands as a Cake Addin
#addin nuget:?package=Telegram.Bot.AttributeCommands&version=1.0.3

// Install Telegram.Bot.AttributeCommands as a Cake Tool
#tool nuget:?package=Telegram.Bot.AttributeCommands&version=1.0.3                

Telegram.Bot.Telegram.Bot.AttributeCommands Library Documentation

The Telegram.Bot.Telegram.Bot.AttributeCommands library provides a streamlined approach to managing and executing text, callback, and reply commands for a Telegram bot. The library utilizes custom attributes to mark and categorize methods, simplifying the registration and processing of commands.

Table of Contents

Introduction

The Telegram.Bot.Telegram.Bot.AttributeCommands library offers a convenient solution for managing and processing various types of commands within a Telegram bot. By leveraging custom attributes, the library organizes text, callback, and reply commands, resulting in a more structured and efficient command handling process.

Getting Started

  1. Install the Telegram.Bot.Telegram.Bot.AttributeCommands library via your preferred package manager.
  2. Import necessary namespaces:
using System;
using System.Reflection;
using Telegram.Bot;
using Telegram.Bot.Types;
using Telegram.Bot.AttributeCommands;
using Telegram.Bot.AttributeCommands.Exceptions;
  1. Create an instance of the Telegram.Bot.Telegram.Bot.AttributeCommands class to begin managing your commands.

Usage

Attributes

The Telegram.Bot.AttributeCommands library includes three custom attributes to mark methods as different types of commands.

TextCommandAttribute

The TextCommandAttribute is used to identify methods as text commands for your Telegram bot.

[TextCommand("your_text_command")]
public static void YourTextCommandMethod(TelegramBotClient client, Update update)
{
    // Your text command logic here
}
CallbackCommandAttribute

The CallbackCommandAttribute is employed for marking methods as callback commands.

[CallbackCommand("your_callback_command")]
public static void YourCallbackCommandMethod(TelegramBotClient client, Update update)
{
    // Your callback command logic here
}
ReplyCommandAttribute

The ReplyCommandAttribute is used to indicate methods as reply commands.

[ReplyCommand("your_reply_command")]
public static void YourReplyCommandMethod(TelegramBotClient client, Update update)
{
    // Your reply command logic here
}

Exceptions

The Telegram.Bot.AttributeCommands library provides custom exceptions for error handling.

CommandNotFoundException

Thrown when attempting to process a non-existent command.

CommandExistsException

Thrown when trying to register a command with a duplicate name.

Example

using Telegram.Bot;
using Telegram.Bot.Types;

public class YourCommandsClass
{
    [TextCommand("start")]
    public static void StartCommand(TelegramBotClient client, Update update)
    {
        // Logic for the start text command
    }

    [CallbackCommand("button_click")]
    public static void ButtonClickCallback(TelegramBotClient client, Update update)
    {
        // Logic for the button click callback command
    }

    [ReplyCommand("thanks")]
    public static void ThankYouReply(TelegramBotClient client, Update update)
    {
        // Logic for the thank you reply command
    }
}

Exception Handling

When using the Telegram.Bot.AttributeCommands library, handle exceptions to ensure a smooth user experience. Catch CommandNotFoundException and CommandExistsException exceptions as needed.


This comprehensive documentation covers the Telegram.Bot.AttributeCommands library, including its custom attributes and exceptions. For more detailed information and usage scenarios, refer to the library's source code and comments.

Please note that this documentation is provided for informational purposes and may require adjustments based on the specific implementation of your project.

Product 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. 
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
1.0.4 182 8/14/2023
1.0.3.3 145 8/13/2023
1.0.3.2 140 8/13/2023
1.0.3 129 8/13/2023
1.0.2 164 7/24/2023
1.0.1 143 7/24/2023
1.0.0 137 7/24/2023