Skip to content

Public API overview

Tim4ik edited this page Aug 18, 2025 · 4 revisions

Caution

This page was generated using hand-writen compiler's XML-Summaries output parser If you find any missing syntax, errors in structure, mis-formats or empty sections, please contact owner or open an issue

Telegrator

Class AbstractHandlerContainerExtensions

Provides usefull helper methods for abstract handler containers

Methods:

  • React(IAbstractHandlerContainer<Message>, ReactionType, Boolean, CancellationToken)

    Changes bot's reaction to message

  • React(IAbstractHandlerContainer<Message>, IEnumerable<ReactionType>, Boolean, CancellationToken)

    Changes bot's reaction to message

  • Reply(IAbstractHandlerContainer<Message>, String, ParseMode, ReplyMarkup, LinkPreviewOptions, Nullable<Int32>, IEnumerable<MessageEntity>, Boolean, Boolean, String, String, Boolean, Nullable<Int32>, SuggestedPostParameters, CancellationToken)

    Sends a reply message to the current message.

  • Responce(IAbstractHandlerContainer<Message>, String, ParseMode, ReplyParameters, ReplyMarkup, LinkPreviewOptions, Nullable<Int32>, IEnumerable<MessageEntity>, Boolean, Boolean, String, String, Boolean, Nullable<Int32>, SuggestedPostParameters, CancellationToken)

    Sends a response message to the current chat.

  • Responce(IAbstractHandlerContainer<CallbackQuery>, String, ParseMode, ReplyParameters, ReplyMarkup, LinkPreviewOptions, Nullable<Int32>, IEnumerable<MessageEntity>, Boolean, Boolean, String, String, Boolean, Nullable<Int32>, SuggestedPostParameters, CancellationToken)

    Responnces to message that this CallbackQuery was originated from

  • EditMessage(IAbstractHandlerContainer<CallbackQuery>, String, ParseMode, InlineKeyboardMarkup, IEnumerable<MessageEntity>, LinkPreviewOptions, CancellationToken)

    Edits message text that this CallbackQuery was originated from

  • AnswerCallbackQuery(IAbstractHandlerContainer<CallbackQuery>, String, Boolean, String, Int32, CancellationToken)

    Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert

  • AnswerInlineQuery(IAbstractHandlerContainer<InlineQuery>, IEnumerable<InlineQueryResult>, Nullable<Int32>, Boolean, String, InlineQueryResultsButton, CancellationToken)

    Answers inline query

Class AwaiterHandlerBuilderExtensions

Extensions methods for Awaiter Handler Builders

Methods:

  • ByChatId<TUpdate>(IAwaiterHandlerBuilder<TUpdate>, CancellationToken)

    Awaits an update using the chat id key resolver and cancellation token.

  • BySenderId<TUpdate>(IAwaiterHandlerBuilder<TUpdate>, CancellationToken)

    Awaits an update using the sender id key resolver and cancellation token.

Class AwaitingProviderExtensions

Extensions methods for awaiting providers Provides convenient methods for creating awaiter builders.

Methods:

  • CreateAbstract<TUpdate>(IAwaitingProvider, UpdateType, Update)

    Creates an awaiter handler builder for a specific update type.

  • AwaitAny(IAwaitingProvider, Update)

    Creates an awaiter builder for any update type.

  • AwaitMessage(IAwaitingProvider, Update)

    Creates an awaiter builder for message updates.

  • AwaitCallbackQuery(IAwaitingProvider, Update)

    Creates an awaiter builder for callback query updates.

Enum ChatTypeFlags

Flags version of Type of the , from which the message or inline query was sent

Values:

  • Private — Normal one-to-one chat with a user or bot
  • Group — Normal group chat
  • Channel — A channel
  • Supergroup — A supergroup
  • Sender — Value possible only in : private chat with the inline query sender

Class CollectionFrozenException

Exception thrown when attempting to modify a frozen collection.

Constructors:

  • CollectionFrozenException()

    Initializes a new instance of the class.

Class ColletionsExtensions

Provides extension methods for working with collections.

Methods:

  • ToReadOnlyDictionary<TKey, TValue>(IEnumerable<TValue>, Func<TValue, TKey>)

    Creates a from an according to a specified key selector function.

  • ForEach<TValue>(IEnumerable<TValue>, Action<TValue>)

    Enumerates objects in a and executes an on each one

  • Set<TKey, TValue>(IDictionary<TKey, TValue>, TKey, TValue)

    Sets the value of a key in a dictionary, or if the key does not exist, adds it

  • Set<TKey, TValue>(IDictionary<TKey, TValue>, TKey, TValue, TValue)

    Sets the value of a key in a dictionary, or if the key does not exist, adds its default value.

  • Random<TSource>(IEnumerable<TSource>)

    Return the random object from

  • Random<TSource>(IEnumerable<TSource>, Random)

    Return the random object from

  • Union<TSource>(IList<TSource>, IEnumerable<TSource>)

    Adds a range of elements to collection if they dont already exist using default equality comparer

Enum DiceType

Enumeration of dice types supported by Telegram. Used for filtering dice messages and determining dice emoji representations.

Values:

  • Dice — Standard dice (🎲).
  • Darts — Darts (🎯).
  • Bowling — Bowling (🎳).
  • Basketball — Basketball (🏀).
  • Football — Football (⚽).
  • Casino — Casino slot machine (🎰).

Class HandlerBuilderExtensions

Extension methods for handler builders. Provides convenient methods for creating handlers and setting state keepers.

Methods:

  • SetUpdateValidating<TBuilder>(TBuilder, UpdateValidateAction)

  • SetConcurreny<TBuilder>(TBuilder, Int32)

  • SetPriority<TBuilder>(TBuilder, Int32)

  • SetIndexer<TBuilder>(TBuilder, Int32, Int32)

  • AddFilter<TBuilder>(TBuilder, IFilter<Update>)

  • AddFilters<TBuilder>(TBuilder)

  • SetStateKeeper<TBuilder, TKey, TState, TKeeper>(TBuilder, TState, IStateKeyResolver<TKey>)

  • SetStateKeeper<TBuilder, TKey, TState, TKeeper>(TBuilder, SpecialState, IStateKeyResolver<TKey>)

  • AddTargetedFilter<TBuilder, TFilterTarget>(TBuilder, Func<Update, TFilterTarget>, IFilter<TFilterTarget>)

    Adds a targeted filter for a specific filter target type.

  • AddTargetedFilters<TBuilder, TFilterTarget>(TBuilder, Func<Update, TFilterTarget>)

    Adds multiple targeted filters for a specific filter target type.

  • SetNumericState<TBuilder>(TBuilder, Int32, IStateKeyResolver<Int64>)

    Sets a numeric state keeper with a custom key resolver.

  • SetNumericState<TBuilder>(TBuilder, SpecialState, IStateKeyResolver<Int64>)

    Sets a numeric state keeper with a special state and custom key resolver.

  • SetNumericState<TBuilder>(TBuilder, Int32)

    Sets a numeric state keeper with the default sender ID resolver.

  • SetNumericState<TBuilder>(TBuilder, SpecialState)

    Sets a numeric state keeper with a special state and the default sender ID resolver.

  • SetEnumState<TBuilder, TEnum>(TBuilder, TEnum, IStateKeyResolver<Int64>)

    Sets an enum state keeper with a custom key resolver.

  • SetEnumState<TBuilder, TEnum>(TBuilder, SpecialState, IStateKeyResolver<Int64>)

    Sets an enum state keeper with a special state and custom key resolver.

  • SetEnumState<TBuilder, TEnum>(TBuilder, TEnum)

    Sets an enum state keeper with the default sender ID resolver.

  • SetEnumState<TBuilder, TEnum>(TBuilder, SpecialState)

    Sets an enum state keeper with a special state and the default sender ID resolver.

Class HandlerContainerExtensions

Extension methods for handler containers. Provides convenient methods for creating awaiter builders and state keeping.

Methods:

  • AwaitUpdate<TUpdate>(IHandlerContainer, UpdateType)

    Creates an awaiter builder for a specific update type.

  • AwaitAny(IHandlerContainer)

    Creates an awaiter builder for any update type.

  • AwaitMessage(IHandlerContainer)

    Creates an awaiter builder for message updates.

  • AwaitCallbackQuery(IHandlerContainer)

    Creates an awaiter builder for callback query updates.

  • GetStateKeeper<TKey, TState, TKeeper>(IHandlerContainer)

    Gets a state keeper instance for the specified types.

Class HandlerFaultedException

Exception thrown when a handler execution fails. Contains information about the handler and the inner exception.

Constructors:

  • HandlerFaultedException(DescribedHandlerInfo, Exception)

    Initializes a new instance of the class.

Class HandlersCollectionExtensions

Extension methods for handlers collections. Provides convenient methods for creating implicit handlers.

Methods:

  • CollectHandlersDomainWide(IHandlersCollection)

    Collects all handlers from the current app domain. Scans for types that implement handlers and adds them to the collection.

  • CollectHandlersAssemblyWide(IHandlersCollection)

    Collects all handlers from the calling this function assembly. Scans for types that implement handlers and adds them to the collection.

  • CreateHandler<TUpdate>(IHandlersCollection, UpdateType)

    Creates a handler builder for a specific update type.

  • CreateAny(IHandlersCollection)

    Creates a handler builder for any update type.

  • CreateMessage(IHandlersCollection)

    Creates a handler builder for message updates.

  • CreateCallbackQuery(IHandlersCollection)

    Creates a handler builder for callback query updates.

  • AddMethod<TUpdate>(IHandlersCollection, AbstractHandlerAction<TUpdate>)

    Creates implicit handler from method

Class HandlersProviderExtensions

Extesions method for handlers providers

Methods:

  • GetBotCommands(IHandlersProvider, CancellationToken)

    Gets the list of bot commands supported by the provider.

Interface ITelegratorBot

Interface for reactive Telegram bot implementations. Defines the core properties and capabilities of a reactive bot.

Properties:

  • UpdateRouter

    Gets the update router for handling incoming updates.

Class MessageExtensions

Provides usefull helper methods for messages

Methods:

  • SubstringEntity(Message, MessageEntity)

    Substrings entity content from text

  • IsCommand(Message, String)

    Checkes if sent contains command. Automatically cuts bot name from it

  • SplitArgs(Message)

    Split message text into arguments, ignoring command instance. Splits by space character

  • TrySplitArgs(Message)

    Tries to split message text into arguments, ignoring command instance. Splits by space character. Exception-free version of

Class NotFilterTypeException

Exception thrown when a type is not a valid filter type.

Constructors:

  • NotFilterTypeException(Type)

    Initializes a new instance of the class.

Class NumbersExtensions

Contains extension method for number types

Methods:

  • HasFlag(Int32, Int32)

    Check if int value has int flag using bit compare

  • HasFlag<T>(Int32, T)

    Check if int value has enum flag using bit compare

Class ReflectionExtensions

Provides extension methods for reflection and type inspection.

Methods:

  • IsCustomDescriptorsProvider(Type)

    Checks if a type implements the interface.

  • IsFilterType(Type)

    Checks if is a

  • IsHandlerAbstract(Type)

    Checks if is a descendant of class

  • IsHandlerRealization(Type)

    Checks if is an implementation of class or its descendants

  • HasParameterlessCtor(Type)

    Checks if has a parameterless constructor

  • HasPublicProperties(Type)

    Checks is has public properties

  • IsAssignableToGenericType(Type, Type)

    Determines whether an instance of a specified type can be assigned to an instance of the current type

Class Result

Represents handler results, allowing to communicate with router and control aspect execution

Properties:

  • Positive

    Is result positive

  • RouteNext

    Should router search for next matching handler

  • NextType

    Exact type that router should search

Methods:

  • Ok()

    Represents 'success' Inside - let handler's main block be executedInside - tells that he can stop describing, as needed handler was foundInside - let continue describing

  • Fault()

    Represents 'fault' or 'error'. Use cases: Inside - interupts execution of handler, main block and wont be executedInside - interupts 's describing sequence

  • Next()

    Represents 'continue'. Use cases: Inside - let continue describingInside - Tells to continue describing handlers

  • Next<T>()

    Represents 'chain'. Use cases: Inside - Tells to continue describing handlers and execute only handlers of exact type

Class StringExtensions

Provides extension methods for string manipulation.

Methods:

  • SliceBy(String, Int32)

    Slices a string into a array of substrings of fixed

Class TelegramBotInfo

Implementation of that provides bot information. Contains metadata about the Telegram bot including user details.

Constructors:

  • TelegramBotInfo(User)

    Implementation of that provides bot information. Contains metadata about the Telegram bot including user details.

Properties:

  • User

    Gets the user information for the bot.

Class TelegratorClient

Main client class for the Telegrator library. Extends TelegramBotClient with reactive capabilities for handling updates.

Constructors:

  • TelegratorClient(String, HttpClient, CancellationToken)

    Initializes a new instance of the class with a bot token.

  • TelegratorClient(TelegramBotClientOptions, HttpClient, CancellationToken)

    Initializes a new instance of the class with bot options.

  • TelegratorClient(TelegramBotClientOptions, TelegratorOptions, HttpClient, CancellationToken)

    Initializes a new instance of the class with bot options and Telegrator options.

Properties:

  • Options

  • Handlers

  • BotInfo

  • UpdateRouter

Methods:

  • StartReceiving(ReceiverOptions, CancellationToken)

    Starts receiving updates from Telegram. Initializes the update router and begins polling for updates.

Class TelegratorOptions

Configuration options for Telegram bot behavior and execution settings. Controls various aspects of bot operation including concurrency, routing, and execution policies.

Constructors:

  • TelegratorOptions()

Properties:

  • MaximumParallelWorkingHandlers

  • ExclusiveAwaitingHandlerRouting

  • ExceptIntersectingCommandAliases

  • GlobalCancellationToken

Class UpdateExtensions

Provides extension methods for working with Telegram Update objects.

Methods:

  • GetSenderId(Update)

    Selects from Update an object from which you can get the sender's ID

  • GetChatId(Update)

    Selects from Update an object from which you can get the chat's ID

  • GetActualUpdateObject(Update)

    Selects from an object that contains information about the update

  • GetAllowedUpdateTypes(Type)

    Selecting corresponding s for 's sub-type

  • GetAllowedUpdateTypes<T>()

    Selecting corresponding s for 's sub-type

  • GetActualUpdateObject<T>(Update)

    Selects from an that contains information about the update

Class UpdateTypeExtensions

Provides extension methods for working with UpdateType enums.

Methods:

  • IsUpdateObjectAllowed<T>()

    Checks if matches one of the 's give on

  • IsValidUpdateObject<TUpdate>(UpdateType)

    Checks if matches the given

  • ReflectUpdateObject(UpdateType)

    Returns an update object corresponding to the .

Annotations

Class ArgumentContainsAttribute

Attribute for filtering messages where a command argument contains the specified content.

Constructors:

  • ArgumentContainsAttribute(String, StringComparison, Int32)

    Attribute for filtering messages where a command argument contains the specified content.

Class ArgumentEndsWithAttribute

Attribute for filtering messages where a command argument ends with the specified content.

Constructors:

  • ArgumentEndsWithAttribute(String, StringComparison, Int32)

    Attribute for filtering messages where a command argument ends with the specified content.

Class ArgumentEqualsAttribute

Attribute for filtering messages where a command argument equals the specified content.

Constructors:

  • ArgumentEqualsAttribute(String, StringComparison, Int32)

    Attribute for filtering messages where a command argument equals the specified content.

Class ArgumentRegexAttribute

Attribute for filtering messages where a command argument matches a regular expression pattern.

Constructors:

  • ArgumentRegexAttribute(String, RegexOptions, TimeSpan, Int32)

    Attribute for filtering messages where a command argument matches a regular expression pattern.

Class ArgumentStartsWithAttribute

Attribute for filtering messages where a command argument starts with the specified content.

Constructors:

  • ArgumentStartsWithAttribute(String, StringComparison, Int32)

    Attribute for filtering messages where a command argument starts with the specified content.

Class CallbackDataAttribute

Attribute for filtering 's data

Constructors:

  • CallbackDataAttribute(String)

    Attribute for filtering 's data

Class CallbackInlineIdAttribute

Attribute to check if belongs to a specific message by its ID

Constructors:

  • CallbackInlineIdAttribute(String)

    Attribute to check if belongs to a specific message by its ID

Class CallbackQueryAttribute

Abstract base attribute for filtering callback-based updates. Supports various message types including regular messages, edited messages, channel posts, and business messages.

Properties:

  • AllowedTypes

    Gets the allowed update types that this filter can process.

Methods:

  • GetFilterringTarget(Update)

    Extracts the message from various types of updates.

Class ChatIdAttribute

Attribute for filtering messages sent in a specific chat by ID.

Constructors:

  • ChatIdAttribute(Int64)

    Attribute for filtering messages sent in a specific chat by ID.

Class ChatIsForumAttribute

Attribute for filtering messages sent in forum chats.

Constructors:

  • ChatIsForumAttribute()

    Attribute for filtering messages sent in forum chats.

Class ChatNameAttribute

Attribute for filtering messages based on the chat name (first name and optionally last name).

Constructors:

  • ChatNameAttribute(String, String, StringComparison)

    Initializes the attribute to filter messages from chats with specific first and last names.

  • ChatNameAttribute(String, String)

    Initializes the attribute to filter messages from chats with specific first and last names.

Class ChatTitleAttribute

Attribute for filtering messages based on the chat title.

Constructors:

  • ChatTitleAttribute(String, StringComparison)

    Initializes the attribute to filter messages from chats with a specific title and comparison method.

  • ChatTitleAttribute(String)

    Initializes the attribute to filter messages from chats with a specific title.

Class ChatTypeAttribute

Attribute for filtering messages sent in chats of a specific type.

Constructors:

  • ChatTypeAttribute(ChatType)

    Initialize new instance of to filter messages from chat from specific chats

  • ChatTypeAttribute(ChatTypeFlags)

    Initialize new instance of to filter messages from chat from specific chats (with flags)

Class ChatUsernameAttribute

Attribute for filtering messages based on the chat username.

Constructors:

  • ChatUsernameAttribute(String, StringComparison)

    Initializes the attribute to filter messages from chats with a specific username and comparison method.

  • ChatUsernameAttribute(String)

    Initializes the attribute to filter messages from chats with a specific username.

Class CommandAlliasAttribute

Attribute for filtering messages based on command aliases. Allows handlers to respond to multiple command variations using a single attribute.

Constructors:

  • CommandAlliasAttribute()

    Initializes a new instance of the CommandAlliasAttribute with the specified command aliases.

Properties:

  • AllowedTypes

    Gets the allowed update types for this filter.

  • Alliases

    Gets the array of command aliases that this filter will match.

  • Description

    Gets or sets the description of the command. Must be between 0 and 256 characters in length.

Methods:

  • GetFilterringTarget(Update)

    Gets the filtering target (Message) from the update.

Class DiceThrowedAttribute

Attribute for filtering messages that contain dice throws with specific values.

Constructors:

  • DiceThrowedAttribute(Int32)

    Initializes the attribute to filter dice throws with a specific value.

  • DiceThrowedAttribute(DiceType, Int32)

    Initializes the attribute to filter dice throws with a specific type and value.

Class EnvironmentFilterAttribute

Abstract base attribute for filtering updates based on environment conditions. Can process all types of updates and provides environment-specific filtering logic.

Properties:

  • AllowedTypes

    Gets the allowed update types that this filter can process. Environment filters can process all update types.

Methods:

  • GetFilterringTarget(Update)

    Gets the update as the filtering target. Environment filters work with the entire update object.

Class EnvironmentVariableAttribute

Attribute for filtering updates based on environment variable values.

Constructors:

  • EnvironmentVariableAttribute(String, String, StringComparison)

    Initializes the attribute to filter based on an environment variable with a specific value and comparison method.

  • EnvironmentVariableAttribute(String, String)

    Initializes the attribute to filter based on an environment variable with a specific value.

  • EnvironmentVariableAttribute(String)

    Initializes the attribute to filter based on the existence of an environment variable.

  • EnvironmentVariableAttribute(String, StringComparison)

    Initializes the attribute to filter based on an environment variable with a specific comparison method.

Class FromBotAttribute

Attribute for filtering messages sent by bots.

Constructors:

  • FromBotAttribute()

    Attribute for filtering messages sent by bots.

Class FromPremiumUserAttribute

Attribute for filtering messages sent by premium users.

Constructors:

  • FromPremiumUserAttribute()

    Attribute for filtering messages sent by premium users.

Class FromReplyChainAttribute

Helper filter class for filters that operate on replied messages. Provides functionality to traverse reply chains and access replied message content.

Constructors:

  • FromReplyChainAttribute(Int32)

    Helper filter class for filters that operate on replied messages. Provides functionality to traverse reply chains and access replied message content.

Class FromUserAttribute

Attribute for filtering messages based on the sender's name (first name and optionally last name).

Constructors:

  • FromUserAttribute(String, String, StringComparison)

    Initializes the attribute to filter messages from a user with specific first and last names.

  • FromUserAttribute(String, String)

    Initializes the attribute to filter messages from a user with specific first and last names.

  • FromUserAttribute(String)

    Initializes the attribute to filter messages from a user with a specific first name.

  • FromUserAttribute(String, StringComparison)

    Initializes the attribute to filter messages from a user with a specific first name and custom comparison.

Class FromUserIdAttribute

Attribute for filtering messages from a specific user ID.

Constructors:

  • FromUserIdAttribute(Int64)

    Attribute for filtering messages from a specific user ID.

Class FromUsernameAttribute

Attribute for filtering messages based on the sender's username.

Constructors:

  • FromUsernameAttribute(String)

    Initializes the attribute to filter messages from a specific username.

  • FromUsernameAttribute(String, StringComparison)

    Initializes the attribute to filter messages from a specific username with custom comparison.

Class HasReplyAttribute

Attribute for checking message's reply chain.

Constructors:

  • HasReplyAttribute(Int32)

    Attribute for checking message's reply chain.

Class HasTextAttribute

Attribute for filtering messages that contain any non-empty text.

Constructors:

  • HasTextAttribute()

    Attribute for filtering messages that contain any non-empty text.

Class IsAutomaticFormwardMessageAttribute

Attribute for filtering messages that are automatically forwarded.

Constructors:

  • IsAutomaticFormwardMessageAttribute()

    Attribute for filtering messages that are automatically forwarded.

Class IsDebugEnvironmentAttribute

Attribute for filtering updates that occur in debug environment. Only allows updates when the application is running in debug mode.

Constructors:

  • IsDebugEnvironmentAttribute()

    Attribute for filtering updates that occur in debug environment. Only allows updates when the application is running in debug mode.

Class IsFromOfflineMessageAttribute

Attribute for filtering messages sent while the user was offline.

Constructors:

  • IsFromOfflineMessageAttribute()

    Attribute for filtering messages sent while the user was offline.

Class IsReleaseEnvironmentAttribute

Attribute for filtering updates that occur in release environment. Only allows updates when the application is running in release mode.

Constructors:

  • IsReleaseEnvironmentAttribute()

    Attribute for filtering updates that occur in release environment. Only allows updates when the application is running in release mode.

Class IsServiceMessageMessageAttribute

Attribute for filtering service messages (e.g., user joined, left, etc.).

Constructors:

  • IsServiceMessageMessageAttribute()

    Attribute for filtering service messages (e.g., user joined, left, etc.).

Class IsTopicMessageMessageAttribute

Attribute for filtering topic messages in forum chats.

Constructors:

  • IsTopicMessageMessageAttribute()

    Attribute for filtering topic messages in forum chats.

Class MentionedAttribute

Attribute for filtering messages that contain mentions. Allows handlers to respond only to messages that mention the bot or specific users.

Constructors:

  • MentionedAttribute()

    Initializes a new instance of the MentionedAttribute that matches any mention.

  • MentionedAttribute(Int32)

    Initializes a new instance of the MentionedAttribute that matches mentions at a specific offset.

  • MentionedAttribute(String)

    Initializes a new instance of the MentionedAttribute that matches a specific mention.

  • MentionedAttribute(String, Int32)

    Initializes a new instance of the MentionedAttribute that matches a specific mention at a specific offset.

Class MeRepliedAttribute

Attribute for filtering messages with reply to messages of this bot.

Constructors:

  • MeRepliedAttribute()

    Attribute for filtering messages with reply to messages of this bot.

Class MessageFilterAttribute

Abstract base attribute for filtering message-based updates. Supports various message types including regular messages, edited messages, channel posts, and business messages.

Properties:

  • AllowedTypes

    Gets the allowed update types that this filter can process.

Methods:

  • GetFilterringTarget(Update)

    Extracts the message from various types of updates.

Class MessageHasEntityAttribute

Attribute for filtering messages based on their entities (mentions, links, etc.).

Constructors:

  • MessageHasEntityAttribute(MessageEntityType)

    Initializes the attribute to filter messages with a specific entity type.

  • MessageHasEntityAttribute(MessageEntityType, Int32, Nullable<Int32>)

    Initializes the attribute to filter messages with a specific entity type at a specific position.

  • MessageHasEntityAttribute(MessageEntityType, String, StringComparison)

    Initializes the attribute to filter messages with a specific entity type and content.

  • MessageHasEntityAttribute(MessageEntityType, Int32, Nullable<Int32>, String, StringComparison)

    Initializes the attribute to filter messages with a specific entity type, position, and content.

Class MessageRegexAttribute

Attribute for filtering messages based on regular expression patterns.

Constructors:

  • MessageRegexAttribute(String, RegexOptions)

    Initializes the attribute with a regex pattern and options.

  • MessageRegexAttribute(Regex)

    Initializes the attribute with a precompiled regex.

Class NotFromBotAttribute

Attribute for filtering messages sent by not bots (users).

Constructors:

  • NotFromBotAttribute()

    Attribute for filtering messages sent by not bots (users).

Class TextContainsAttribute

Attribute for filtering messages where the text contains the specified content.

Constructors:

  • TextContainsAttribute(String, StringComparison)

    Attribute for filtering messages where the text contains the specified content.

Class TextEndsWithAttribute

Attribute for filtering messages where the text ends with the specified content.

Constructors:

  • TextEndsWithAttribute(String, StringComparison)

    Attribute for filtering messages where the text ends with the specified content.

Class TextEqualsAttribute

Attribute for filtering messages where the text equals the specified content.

Constructors:

  • TextEqualsAttribute(String, StringComparison)

    Attribute for filtering messages where the text equals the specified content.

Class TextStartsWithAttribute

Attribute for filtering messages where the text starts with the specified content.

Constructors:

  • TextStartsWithAttribute(String, StringComparison)

    Attribute for filtering messages where the text starts with the specified content.

Annotations.StateKeeping

Class EnumStateAttribute<TEnum>

Attribute for managing enum-based states in Telegram bot handlers. Provides a convenient way to associate enum values with state management functionality.

Constructors:

  • EnumStateAttribute<TEnum>(SpecialState, IStateKeyResolver<Int64>)

    Initializes a new instance of the EnumStateAttribute with a special state and custom key resolver.

  • EnumStateAttribute<TEnum>(TEnum, IStateKeyResolver<Int64>)

    Initializes a new instance of the EnumStateAttribute with a specific enum state and custom key resolver.

  • EnumStateAttribute<TEnum>(SpecialState)

    Initializes a new instance of the EnumStateAttribute with a special state and default sender ID resolver.

  • EnumStateAttribute<TEnum>(TEnum)

    Initializes a new instance of the EnumStateAttribute with a specific enum state and default sender ID resolver.

Class NumericStateAttribute

Attribute for associating a handler or method with a numeric (integer) state keeper. Provides constructors for flexible state and key resolver configuration.

Constructors:

  • NumericStateAttribute(SpecialState, IStateKeyResolver<Int64>)

    Initializes the attribute with a special state and a custom key resolver.

  • NumericStateAttribute(Int32, IStateKeyResolver<Int64>)

    Initializes the attribute with a specific numeric state and a custom key resolver.

  • NumericStateAttribute(SpecialState)

    Initializes the attribute with a special state and the default sender ID resolver.

  • NumericStateAttribute(Int32)

    Initializes the attribute with a specific numeric state and the default sender ID resolver.

Enum SpecialState

Represents special states for state keeping logic.

Values:

  • None — No special state.
  • NoState — Indicates that no state is present.
  • AnyState — Indicates that any state is acceptable.

Class StringStateAttribute

Attribute for associating a handler or method with a string-based state keeper. Provides various constructors for flexible state and key resolver configuration.

Constructors:

  • StringStateAttribute(SpecialState, IStateKeyResolver<Int64>)

    Initializes the attribute with a special state and a custom key resolver.

  • StringStateAttribute(String, IStateKeyResolver<Int64>)

    Initializes the attribute with a specific state and a custom key resolver.

  • StringStateAttribute(SpecialState)

    Initializes the attribute with a special state and the default sender ID resolver.

  • StringStateAttribute(String)

    Initializes the attribute with a specific state and the default sender ID resolver.

Annotations.Targetted

Class WelcomeAttribute

Attribute for filtering message with command "start" in bot's private chats. Allows handlers to respond to "welcome" bot commands.

Constructors:

  • WelcomeAttribute(Boolean)

    Creates new instance of

Aspects

Class AfterExecutionAttribute<T>

Attribute that specifies a post-execution processor to be executed after the handler. The processor type must implement interface.

Constructors:

  • AfterExecutionAttribute<T>()

Properties:

  • ProcessorType

    Gets the type of the post-processor.

Class BeforeExecutionAttribute<T>

Attribute that specifies a pre-execution processor to be executed before the handler. The processor type must implement interface.

Constructors:

  • BeforeExecutionAttribute<T>()

Properties:

  • ProcessorType

    Gets the type of the pre-processor.

Interface IPostProcessor

Interface for post-execution processors that are executed after handler execution. Implement this interface to add cross-cutting concerns like logging, cleanup, or metrics collection.

Methods:

  • AfterExecution(IHandlerContainer, CancellationToken)

    Executes after the handler's main execution logic.

Interface IPreProcessor

Interface for pre-execution processors that are executed before handler execution. Implement this interface to add cross-cutting concerns like validation, logging, or authorization.

Methods:

  • BeforeExecution(IHandlerContainer, CancellationToken)

    Executes before the handler's main execution logic.

Attributes

Class DontCollectAttribute

Attribute that prevents a class from being automatically collected by the handler collection system. When applied to a class, it will be excluded from domain-wide handler collection operations.

Constructors:

  • DontCollectAttribute()

Class FilterAnnotation<T>

Reactive way to implement a new of type

Constructors:

  • FilterAnnotation<T>()

    Initializes new instance of

Properties:

  • IsCollectible

  • AllowedTypes

Methods:

  • GetFilterringTarget(Update)

  • CanPass(FilterExecutionContext<T>)

Enum FilterModifier

Enumeration of filter modifiers that can be applied to update filters. Defines how filters should be combined and applied in filter chains.

Values:

  • None — No modifier applied. Filter is applied as-is.
  • OrNext — OR modifier. This filter or the next filter in the chain should match.
  • Not — NOT modifier. The inverse of this filter should match.

Class MightAwaitAttribute

Attribute that says if this handler can await some of await types, that is not listed by its handler base. Used for automatic collecting allowed to receiving 's. If you don't use it, you won't be able to await the updates inside handler.

Constructors:

  • MightAwaitAttribute()

    main ctor of

Properties:

  • UpdateTypes

    Update types that may be awaited

Class StateKeeperAttribute<TKey, TState, TKeeper>

Abstract attribute for associating a handler or method with a state keeper. Provides logic for state-based filtering and state management.

Properties:

  • Shared

    Gets or sets the singleton instance of the state keeper for this attribute type.

  • DefaultState

    Gets the default state value of this statekeeper.

  • MyState

    Gets the state value associated with this attribute instance.

  • SpecialState

    Gets the special state mode for this attribute instance.

Methods:

  • CanPass(FilterExecutionContext<Update>)

    Determines whether the current update context passes the state filter.

Class UpdateFilterAttribute<T>

Abstract base attribute for defining update filters for a specific type of update target. Provides logic for filter composition, modifier processing, and target extraction.

Properties:

  • AnonymousFilter

    Gets the compiled anonymous filter for this attribute.

  • UpdateFilter

    Gets the compiled filter logic for the update target.

Methods:

  • ProcessModifiers(UpdateFilterAttributeBase)

    Processes filter modifiers and combines this filter with the previous one if needed.

  • GetFilterringTarget(Update)

    Extracts the filtering target of type from the given update.

Class UpdateHandlerAttribute<T>

Abstract base attribute for marking update handler classes. Provides a type-safe way to associate handler types with specific update types and importance settings.

Attributes.Components

Class StateKeeperAttributeBase

Sets the state in which the can be executed

Properties:

  • IsCollectible

Methods:

  • CanPass(FilterExecutionContext<Update>)

    Realizes a for validation of the current in the polling routing

Class UpdateFilterAttributeBase

Defines the to validation for entry into execution of the

Properties:

  • AllowedTypes

    Gets the 's that processing

  • AnonymousFilter

    Gets the that processing

  • Modifiers

    Gets or sets the filter modifiers that affect how this filter is combined with others.

Methods:

  • ProcessModifiers(UpdateFilterAttributeBase)

    Determines the logic of filter modifiers. Exceptionally internal implementation

Class UpdateHandlerAttributeBase

Defines the 's and validator () of the that will process

Properties:

  • IsCollectible

  • ExpectingHandlerType

    Gets an array of that this attribute can be attached to

  • Type

    Gets an that handlers processes

  • Importance

    Gets or sets importance of this in same pool

  • Priority

    Gets or sets priority of this in same type handlers pool

  • FormReport

    Gets or sets a value indicating whether to form a fallback report.

Methods:

  • GetIndexer()

    Gets an of this from and

  • CanPass(FilterExecutionContext<Update>)

    Validator () of the that will process

Configuration

Interface ITelegramBotInfo

Interface for providing bot information and metadata. Contains information about the bot user and provides initialization capabilities.

Properties:

  • User

    Gets the representing the bot.

Interface ITelegratorOptions

Interface for configuring Telegram bot behavior and execution settings. Controls various aspects of bot operation including concurrency, routing, collecting, and execution policies.

Properties:

  • MaximumParallelWorkingHandlers

    Gets or sets the maximum number of parallel working handlers. Null means no limit.

  • ExclusiveAwaitingHandlerRouting

    Gets or sets a value indicating whether awaiting handlers should be routed separately from regular handlers.

  • ExceptIntersectingCommandAliases

    Gets or sets a value indicating whether to exclude intersecting command aliases.

  • GlobalCancellationToken

    Gets or sets the global cancellation token for all bot operations.

Filters

Class AndFilter<T>

A filter that passes only if both joined filters pass.

Constructors:

  • AndFilter<T>(IFilter<T>, IFilter<T>)

    Initializes a new instance of the class.

Methods:

  • CanPass(FilterExecutionContext<T>)

Class AnyFilter<T>

A filter that always passes.

Constructors:

  • AnyFilter<T>()

Methods:

  • CanPass(FilterExecutionContext<T>)

Class ArgumentContainsFilter

Filter that checks if a command argument contains a specified content.

Constructors:

  • ArgumentContainsFilter(String, StringComparison, Int32)

    Filter that checks if a command argument contains a specified content.

Class ArgumentEndsWithFilter

Filter that checks if a command argument ends with a specified content.

Constructors:

  • ArgumentEndsWithFilter(String, StringComparison, Int32)

    Filter that checks if a command argument ends with a specified content.

Class ArgumentEqualsFilter

Filter that checks if a command argument equals a specified content.

Constructors:

  • ArgumentEqualsFilter(String, StringComparison, Int32)

    Filter that checks if a command argument equals a specified content.

Class ArgumentRegexFilter

Filter that checks if a command argument matches a regular expression pattern.

Constructors:

  • ArgumentRegexFilter(Regex, Int32)

    Filter that checks if a command argument matches a regular expression pattern.

  • ArgumentRegexFilter(String, RegexOptions, TimeSpan, Int32)

    Initializes a new instance of with a regex pattern.

Properties:

  • Match

    Gets the match found by the regex.

Class ArgumentStartsWithFilter

Filter that checks if a command argument starts with a specified content.

Constructors:

  • ArgumentStartsWithFilter(String, StringComparison, Int32)

    Filter that checks if a command argument starts with a specified content.

Class CallbackDataFilter

Filter thet checks 's data

Constructors:

  • CallbackDataFilter(String)

    Initialize new instance of

Methods:

  • CanPass(FilterExecutionContext<CallbackQuery>)

Class CallbackInlineIdFilter

Filter that checks if belongs to a specific message

Constructors:

  • CallbackInlineIdFilter(String)

    Initialize new instance of

Methods:

  • CanPass(FilterExecutionContext<CallbackQuery>)

Class CallbackRegexFilter

Filters callback queries by matching their data with a regular expression.

Constructors:

  • CallbackRegexFilter(String, RegexOptions)

    Initializes a new instance of the class with a pattern and options.

  • CallbackRegexFilter(Regex)

    Initializes a new instance of the class with a regex object.

Class CommandAlliasFilter

Filter that checks if a command matches any of the specified aliases. Requires a to be applied first to extract the command.

Constructors:

  • CommandAlliasFilter()

    Filter that checks if a command matches any of the specified aliases. Requires a to be applied first to extract the command.

Properties:

  • ReceivedCommand

    Gets the command that was received and extracted by the .

Methods:

  • CanPass(FilterExecutionContext<Message>)

    Checks if the received command matches any of the specified aliases. This filter requires a to be applied first to extract the command from the message.

Class CommandArgumentFilterBase

Abstract base class for filters that operate on command arguments. Provides functionality to extract and validate command arguments from message text.

Methods:

  • CanPass(FilterExecutionContext<Message>)

    Determines whether the filter can pass by extracting the command argument and validating it.

Class DiceThrowedFilter

Filters messages by dice throw value and optionally by dice type.

Constructors:

  • DiceThrowedFilter(Int32)

    Initializes a new instance of the class for a specific value.

  • DiceThrowedFilter(DiceType, Int32)

    Initializes a new instance of the class for a specific dice type and value.

Class EnvironmentFilter

Abstract base class for filters that operate based on the current environment. Provides functionality to detect debug vs release environments.

Class EnvironmentVariableFilter

Filter that checks environment variable values.

Constructors:

  • EnvironmentVariableFilter(String, String, StringComparison)

    Filter that checks environment variable values.

  • EnvironmentVariableFilter(String, String)

    Initializes a new instance of the class with a specific value.

  • EnvironmentVariableFilter(String)

    Initializes a new instance of the class that checks for non-null values.

  • EnvironmentVariableFilter(String, StringComparison)

    Initializes a new instance of the class with custom comparison.

Methods:

  • CanPass(FilterExecutionContext<Update>)

    Checks if the environment variable matches the expected criteria.

Class Filter<T>

Base class for filters, providing logical operations and collectability.

Properties:

  • IsCollectible

    Gets a value indicating whether this filter is collectible.

Methods:

  • If(Func<FilterExecutionContext<T>, Boolean>)

    Creates a filter from a function.

  • Any()

    Creates a filter that always passes.

  • Not()

    Creates a filter that inverts the result of this filter.

  • Not<Q>(IFilter<Q>)

    Creates a filter that inverts the result of this filter.

  • And(IFilter<T>)

    Creates a filter that passes only if both this and the specified filter pass.

  • Or(IFilter<T>)

    Creates a filter that passes if either this or the specified filter pass.

  • Or<Q>(IFilter<Q>, IFilter<Q>)

    Creates a filter that passes if either this or the specified filter pass.

  • CanPass(FilterExecutionContext<T>)

    Determines whether the filter can pass for the given context.

Class FromBotFilter

Filter that checks if the message was sent by a bot.

Constructors:

  • FromBotFilter()

    Filter that checks if the message was sent by a bot.

Class FromPremiumUserFilter

Filter that checks if the message was sent by a premium user.

Constructors:

  • FromPremiumUserFilter()

    Filter that checks if the message was sent by a premium user.

Class FromReplyChainFilter

Helper filter class for filters that operate on replied messages. Provides functionality to traverse reply chains and access replied message content and shifts any next message filter to filter the content of found reply.

Constructors:

  • FromReplyChainFilter(Int32)

    Helper filter class for filters that operate on replied messages. Provides functionality to traverse reply chains and access replied message content and shifts any next message filter to filter the content of found reply.

Properties:

  • Reply

    Gets the replied message at the specified depth in the reply chain.

  • ReplyDepth

    Gets the depth of reply chain traversal.

Methods:

  • CanPass(FilterExecutionContext<Message>)

    Determines if the message can pass through the filter by first validating the reply chain and then applying specific filter logic.

Class FromUserFilter

Filter that checks if the message sender has specific first and/or last name.

Constructors:

  • FromUserFilter(String, String, StringComparison)

    Filter that checks if the message sender has specific first and/or last name.

  • FromUserFilter(String, String)

    Initializes a new instance of the class with first and last name.

  • FromUserFilter(String)

    Initializes a new instance of the class with first name only.

  • FromUserFilter(String, StringComparison)

    Initializes a new instance of the class with first name and custom comparison.

Class FromUserIdFilter

Filter that checks if the message sender has a specific user ID.

Constructors:

  • FromUserIdFilter(Int64)

    Filter that checks if the message sender has a specific user ID.

Class FromUsernameFilter

Filter that checks if the message sender has a specific username.

Constructors:

  • FromUsernameFilter(String)

    Filter that checks if the message sender has a specific username.

  • FromUsernameFilter(String, StringComparison)

    Initializes a new instance of the class with custom string comparison.

Class FunctionFilter<T>

A filter that uses a function to determine if it passes.

Constructors:

  • FunctionFilter<T>(Func<FilterExecutionContext<T>, Boolean>)

    Initializes a new instance of the class.

Methods:

  • CanPass(FilterExecutionContext<T>)

Class IsAutomaticFormwardMessageFilter

Filters messages that are automatic forwards.

Constructors:

  • IsAutomaticFormwardMessageFilter()

Class IsDebugEnvironmentFilter

Filter that only passes in debug environment builds.

Constructors:

  • IsDebugEnvironmentFilter()

    Filter that only passes in debug environment builds.

Methods:

  • CanPass(FilterExecutionContext<Update>)

    Checks if the current environment is debug mode.

Class IsFromOfflineMessageFilter

Filters messages that are sent from offline.

Constructors:

  • IsFromOfflineMessageFilter()

Class IsReleaseEnvironmentFilter

Filter that only passes in release environment builds.

Constructors:

  • IsReleaseEnvironmentFilter()

    Filter that only passes in release environment builds.

Methods:

  • CanPass(FilterExecutionContext<Update>)

    Checks if the current environment is release mode.

Class IsServiceMessageMessageFilter

Filters service messages (e.g., chat events).

Constructors:

  • IsServiceMessageMessageFilter()

Class IsTopicMessageMessageFilter

Filters messages that are topic messages.

Constructors:

  • IsTopicMessageMessageFilter()

Class JoinedFilter<T>

Base class for filters that join multiple filters together.

Properties:

  • Filters

    Gets the array of joined filters.

Class MentionedFilter

Filter that checks if a message contains a mention of the bot or a specific user. Requires a to be applied first to identify mention entities.

Constructors:

  • MentionedFilter()

    Initializes a new instance of the class that checks for bot mentions.

  • MentionedFilter(String)

    Initializes a new instance of the class that checks for specific user mentions.

Class MeRepliedFilter

Filter that checks if the replied message was sent by the bot itself. ( ! ): REQUIRES before

Constructors:

  • MeRepliedFilter()

Methods:

  • CanPass(FilterExecutionContext<Message>)

    Checks if the replied message was sent by the bot.

Class MessageChatFilter

Base class for filters that operate on the chat of the message being processed.

Properties:

  • Chat

    Gets the chat of the message being processed.

Class MessageChatIdFilter

Filters messages whose chat ID matches the specified value.

Constructors:

  • MessageChatIdFilter(Int64)

    Filters messages whose chat ID matches the specified value.

Class MessageChatIsForumFilter

Filters messages whose chat is a forum.

Constructors:

  • MessageChatIsForumFilter()

Class MessageChatNameFilter

Filters messages whose chat first and/or last name matches the specified values.

Constructors:

  • MessageChatNameFilter(String, String)

    Initializes a new instance of the class.

  • MessageChatNameFilter(String, String, StringComparison)

    Initializes a new instance of the class with a specific string comparison.

Class MessageChatTitleFilter

Filters messages whose chat title matches the specified value.

Constructors:

  • MessageChatTitleFilter(String)

    Initializes a new instance of the class.

  • MessageChatTitleFilter(String, StringComparison)

    Initializes a new instance of the class with a specific string comparison.

Class MessageChatTypeFilter

Filters messages whose chat type matches the specified value.

Constructors:

  • MessageChatTypeFilter(ChatType)

    Initialize new instance of

  • MessageChatTypeFilter(ChatTypeFlags)

    Initialize new instance of with

Class MessageChatUsernameFilter

Filters messages whose chat username matches the specified value.

Constructors:

  • MessageChatUsernameFilter(String)

    Initializes a new instance of the class.

  • MessageChatUsernameFilter(String, StringComparison)

    Initializes a new instance of the class with a specific string comparison.

Class MessageFilterBase

Base abstract class for all filter of updates

Methods:

  • CanPass(FilterExecutionContext<Message>)

Class MessageHasEntityFilter

Filters messages that contain a specific entity type, content, offset, or length.

Constructors:

  • MessageHasEntityFilter(MessageEntityType)

    Initializes a new instance of the class for a specific entity type.

  • MessageHasEntityFilter(MessageEntityType, Nullable<Int32>, Nullable<Int32>)

    Initializes a new instance of the class for a specific entity type, offset, and length.

  • MessageHasEntityFilter(MessageEntityType, String, StringComparison)

    Initializes a new instance of the class for a specific entity type and content.

  • MessageHasEntityFilter(MessageEntityType, Nullable<Int32>, Nullable<Int32>, String, StringComparison)

    Initializes a new instance of the class for a specific entity type, offset, length, and content.

Properties:

  • FoundEntities

    Gets the entities found in the message that match the filter.

Class MessageHasReplyFilter

Filter that checks if message has appropriate reply chain. DOES NOT SHiFT MESSAGE FILTERS TARGET

Constructors:

  • MessageHasReplyFilter(Int32)

    Filter that checks if message has appropriate reply chain. DOES NOT SHiFT MESSAGE FILTERS TARGET

Properties:

  • Reply

    Gets the replied message at the specified depth in the reply chain.

  • ReplyDepth

    Gets the depth of reply chain traversal.

Methods:

  • CanPass(FilterExecutionContext<Message>)

    Determines if the message can pass through the filter by first validating the reply chain and then applying specific filter logic.

Class MessageRegexFilter

Filters messages by matching their text with a regular expression.

Constructors:

  • MessageRegexFilter(String, RegexOptions)

    Initializes a new instance of the class with a pattern and options.

  • MessageRegexFilter(Regex)

    Initializes a new instance of the class with a regex object.

Class MessageSenderFilter

Abstract base class for filters that operate on message senders. Provides functionality to access and validate the user who sent the message.

Properties:

  • User

    Gets the user who sent the message.

Methods:

  • CanPass(FilterExecutionContext<Message>)

    Determines if the message can pass through the filter by validating that the message has a valid sender.

Class MessageTextFilter

Abstract base class for filters that operate on message text content. Provides common functionality for extracting and validating message text.

Properties:

  • Message

    Gets the current message being processed by the filter.

  • Text

    Gets the extracted text content from the current message.

Methods:

  • CanPass(FilterExecutionContext<Message>)

    Determines if the message can pass through the filter by validating the message and extracting its text content for further processing.

Class MessageTypeFilter

Filters messages by their .

Constructors:

  • MessageTypeFilter(MessageType)

    Initializes a new instance of the class.

Class OrFilter<T>

A filter that passes if at least one of the joined filters passes.

Constructors:

  • OrFilter<T>(IFilter<T>, IFilter<T>)

    Initializes a new instance of the class.

Methods:

  • CanPass(FilterExecutionContext<T>)

Class RegexFilterBase<T>

Base class for filters that use regular expressions to match text in updates.

Properties:

  • Matches

    Gets the collection of matches found by the regex.

Methods:

  • CanPass(FilterExecutionContext<T>)

    Determines whether the regex matches the text extracted from the input.

Class ReverseFilter<T>

A filter that inverts the result of another filter.

Constructors:

  • ReverseFilter<T>(IFilter<T>)

    Initializes a new instance of the class.

Methods:

  • CanPass(FilterExecutionContext<T>)

Class StateKeyFilter<TKey>

Filters updates by comparing a resolved state key with a target key.

Constructors:

  • StateKeyFilter<TKey>(IStateKeyResolver<TKey>, TKey)

    Initializes a new instance of the class.

Methods:

  • CanPass(FilterExecutionContext<Update>)

Class TextContainsFilter

Filter that checks if the message text contains a specified content.

Constructors:

  • TextContainsFilter(String, StringComparison)

    Filter that checks if the message text contains a specified content.

Class TextEndsWithFilter

Filter that checks if the message text ends with a specified content.

Constructors:

  • TextEndsWithFilter(String, StringComparison)

    Filter that checks if the message text ends with a specified content.

Class TextEqualsFilter

Filter that checks if the message text equals a specified content.

Constructors:

  • TextEqualsFilter(String, StringComparison)

    Filter that checks if the message text equals a specified content.

Class TextNotNullOrEmptyFilter

Filter that checks if the message text is not null or empty.

Constructors:

  • TextNotNullOrEmptyFilter()

    Filter that checks if the message text is not null or empty.

Class TextStartsWithFilter

Filter that checks if the message text starts with a specified content.

Constructors:

  • TextStartsWithFilter(String, StringComparison)

    Filter that checks if the message text starts with a specified content.

Filters.Components

Class AnonymousCompiledFilter

Represents a compiled filter that applies a set of filters to an anonymous target type.

Properties:

  • Name

    Gets the name of this compiled filter.

Methods:

  • Compile<T>(IEnumerable<IFilter<T>>, Func<Update, Object>)

    Compiles a set of filters into an for a specific target type.

  • Compile<T>(String, IEnumerable<IFilter<T>>, Func<Update, Object>)

    Compiles a set of filters into an for a specific target type with a custom name.

  • CanPass(FilterExecutionContext<Update>)

Class AnonymousTypeFilter

Represents a filter that applies a filter action to an anonymous target type extracted from an update.

Constructors:

  • AnonymousTypeFilter(String, Func<Update, Object>, Func<FilterExecutionContext<Update>, Object, Boolean>)

    Initializes a new instance of the class.

Properties:

  • Name

    Gets the name of this filter.

Methods:

  • Compile<T>(IFilter<T>, Func<Update, T>)

    Compiles a filter for a specific target type.

  • Compile<T>(String, IFilter<T>, Func<Update, T>)

    Compiles a filter for a specific target type with a custom name.

  • CanPass(FilterExecutionContext<Update>)

    Determines whether the filter can pass for the given context by extracting the filtering target and applying the filter action.

Class CompiledFilter<T>

Represents a filter that composes multiple filters and passes only if all of them pass.

Constructors:

  • CompiledFilter<T>()

    Initializes a new instance of the class.

  • CompiledFilter<T>(String, )

    Initializes a new instance of the class with a custom name.

Properties:

  • Name

    Gets the name of this compiled filter.

Methods:

  • CanPass(FilterExecutionContext<T>)

    Determines whether all composed filters pass for the given context.

Class CompletedFiltersList

The list containing filters worked out during Polling to further obtain additional filtering information

Constructors:

  • CompletedFiltersList()

Methods:

  • Add<TUpdate>(IFilter<TUpdate>)

    Adds the completed filter to the list.

  • AddRange<TUpdate>(IEnumerable<IFilter<TUpdate>>)

    Adds many completed filters to the list.

  • Get<TFilter>()

    Looks for filters of a given type in the list.

  • Get<TFilter>(Int32)

    Looks for a filter of a given type at the specified index in the list.

  • GetOrDefault<TFilter>(Int32)

    Returns a filter of a given type at the specified index, or null if it does not exist.

  • GetEnumerator()

Class FilterExecutionContext<T>

Represents the context for filter execution, including update, input, and additional data.

Constructors:

  • FilterExecutionContext<T>(ITelegramBotInfo, Update, T, Dictionary<String, Object>, CompletedFiltersList)

    Initializes a new instance of the class with all parameters.

  • FilterExecutionContext<T>(ITelegramBotInfo, Update, T)

    Initializes a new instance of the class with default data and filters.

Properties:

  • BotInfo

    Gets the for the current context.

  • Data

    Gets the additional data dictionary for the context.

  • CompletedFilters

    Gets the list of completed filters for the context.

  • Update

    Gets the being processed.

  • Type

    Gets the of the update.

  • Input

    Gets the input object for the filter.

Methods:

  • CreateChild<C>(C)

    Creates a child context for a different input type, sharing the same data and completed filters.

Interface IFilter<T>

Represents a filter for a specific update type.

Methods:

  • CanPass(FilterExecutionContext<T>)

    Determines whether the filter can pass for the given context.

Interface IFilterCollectable

Interface for filters that can be collected into a completed filters list. Provides information about whether a filter should be tracked during execution.

Properties:

  • IsCollectible

    Gets if filter can be collected to

Interface IJoinedFilter<T>

Represents a filter that joins multiple filters together.

Properties:

  • Filters

    Gets the array of joined filters.

Interface INamedFilter

Interface for filters that have a name for identification and debugging purposes.

Properties:

  • Name

    Gets the name of the filter.

Handlers

Class AbstractHandlerContainer<TUpdate>

Container class that holds the context and data for handler execution. Provides access to the update, client, filters, and other execution context.

Constructors:

  • AbstractHandlerContainer<TUpdate>(DescribedHandlerInfo)

    Initializes new instance of

  • AbstractHandlerContainer<TUpdate>(TUpdate, Update, ITelegramBotClient, Dictionary<String, Object>, CompletedFiltersList, IAwaitingProvider)

    Initializes new instance of

Properties:

  • ActualUpdate

    Gets the actual update object of type TUpdate.

  • HandlingUpdate

  • Client

  • ExtraData

  • CompletedFilters

  • AwaitingProvider

Methods:

  • CreateChild<QUpdate>()

    Creates new container of specific update type from thos contatiner

  • From<QUpdate>(IAbstractHandlerContainer<QUpdate>)

    Creates new container of specific update type from existing container

Class AnyUpdateHandler

Abstract base class for handlers that can process any type of update. Provides a foundation for creating handlers that respond to all incoming updates.

Class AnyUpdateHandlerAttribute

Attribute that marks a handler to process any type of update. This handler will be triggered for all incoming updates regardless of their type.

Constructors:

  • AnyUpdateHandlerAttribute(Int32)

    Attribute that marks a handler to process any type of update. This handler will be triggered for all incoming updates regardless of their type.

Methods:

  • CanPass(FilterExecutionContext<Update>)

    Always returns true, allowing any update to pass through this filter.

Class BranchingCommandHandler

Abstract base class for branching handlers that process command messages. Provides functionality to extract and parse command arguments for branching scenarios.

Class BranchingMessageHandler

Abstract base class for branching handlers that process message updates. Provides convenient methods for sending replies and responses to messages in branching scenarios.

Class CallbackQueryHandler

Abstract base class for handlers that process callback query updates. Provides a foundation for creating handlers that respond to user interactions with inline keyboards.

Class CallbackQueryHandlerAttribute

Attribute that marks a handler to process callback query updates. This handler will be triggered when users interact with inline keyboards or other callback mechanisms.

Constructors:

  • CallbackQueryHandlerAttribute(Int32)

    Attribute that marks a handler to process callback query updates. This handler will be triggered when users interact with inline keyboards or other callback mechanisms.

Methods:

  • CanPass(FilterExecutionContext<Update>)

    Always returns true, allowing any callback query update to pass through this filter.

Class CommandHandler

Abstract base class for handlers that process command messages. Provides functionality to extract and parse command arguments.

Class CommandHandlerAttribute

Attribute that marks a handler to process command messages. This handler will be triggered when users send bot commands (messages starting with '/').

Constructors:

  • CommandHandlerAttribute(Int32)

    Attribute that marks a handler to process command messages. This handler will be triggered when users send bot commands (messages starting with '/').

Properties:

  • ReceivedCommand

    Gets the command that was extracted from the message (without the '/' prefix and bot username).

  • Arguments

    Message text splited by space characters

Methods:

  • CanPass(FilterExecutionContext<Update>)

    Checks if the update contains a valid bot command and extracts the command text.

Interface IAbstractHandlerContainer<TUpdate>

Represents a handler container for a specific update type.

Properties:

  • ActualUpdate

    Gets the actual update object of type .

Class InlineQueryHandler

Abstract base class for handlers that process inline queries. IMPORTANT! You can have only ONE instance of this handler.

Methods:

  • Execute(IAbstractHandlerContainer<Update>, CancellationToken)

  • Requested(IAbstractHandlerContainer<InlineQuery>, CancellationToken)

    Executes handler logic if received update is

  • Chosen(IAbstractHandlerContainer<ChosenInlineResult>, CancellationToken)

    Executes handler logic if received update is

Class InlineQueryHandlerAttribute

Attribute that marks a handler to process inline queries. IMPORTANT! You can have only ONE instance of this handler.

Constructors:

  • InlineQueryHandlerAttribute(Int32)

    Attribute that marks a handler to process inline queries. IMPORTANT! You can have only ONE instance of this handler.

Methods:

  • CanPass(FilterExecutionContext<Update>)

Class MessageHandler

Abstract base class for handlers that process message updates. Provides convenient methods for sending replies and responses to messages.

Class MessageHandlerAttribute

Attribute that marks a handler to process message updates. This handler will be triggered when users send messages in chats.

Constructors:

  • MessageHandlerAttribute(Int32)

    Attribute that marks a handler to process message updates. This handler will be triggered when users send messages in chats.

Methods:

  • CanPass(FilterExecutionContext<Update>)

    Checks if the update contains a valid message.

Handlers.Building

Class AwaiterHandlerBuilder<TUpdate>

Builder class for creating awaiter handlers that can wait for specific update types. Provides fluent API for configuring filters, state keepers, and other handler properties.

Constructors:

  • AwaiterHandlerBuilder<TUpdate>(UpdateType, Update, IAwaitingProvider)

    Initializes a new instance of the class.

Methods:

  • Await(CancellationToken)

    Awaits for an update of the specified type using the default sender ID resolver.

  • Await(IStateKeyResolver<Int64>, CancellationToken)

    Awaits for an update of the specified type using a custom state key resolver.

Class HandlerBuilder<TUpdate>

Builder class for creating regular handlers that can process updates. Provides fluent API for configuring filters, state keepers, and other handler properties.

Constructors:

  • HandlerBuilder<TUpdate>(UpdateType, IHandlersCollection)

    Initializes a new instance of the class.

Methods:

  • Build(AbstractHandlerAction<TUpdate>)

    Builds an abstract handler with the specified execution action.

Handlers.Building.Components

Class HandlerBuilderBase

Base class for building handler descriptors and managing handler filters.

Methods:

  • GetImplicitHandlerServiceKey(Type)

    Gets a unique service key for an implicit handler type.

  • SetUpdateValidating(UpdateValidateAction)

    Sets the update validating action for the handler.

  • SetConcurreny(Int32)

    Sets the concurrency level for the handler.

  • SetPriority(Int32)

    Sets the priority for the handler.

  • SetIndexer(Int32, Int32)

    Sets both concurrency and priority for the handler.

  • AddFilter(IFilter<Update>)

    Adds a filter to the handler.

  • AddFilters()

    Adds multiple filters to the handler.

  • SetStateKeeper<TKey, TState, TKeeper>(TState, IStateKeyResolver<TKey>)

    Sets a state keeper for the handler using a specific state and key resolver.

  • SetStateKeeper<TKey, TState, TKeeper>(SpecialState, IStateKeyResolver<TKey>)

    Sets a state keeper for the handler using a special state and key resolver.

  • AddTargetedFilter<TFilterTarget>(Func<Update, TFilterTarget>, IFilter<TFilterTarget>)

    Adds a targeted filter for a specific filter target type.

  • AddTargetedFilters<TFilterTarget>(Func<Update, TFilterTarget>)

    Adds multiple targeted filters for a specific filter target type.

Interface IAwaiterHandlerBuilder<TUpdate>

Defines a builder for awaiting handler logic for a specific update type.

Methods:

  • Await(IStateKeyResolver<Int64>, CancellationToken)

    Awaits an update using the specified key resolver and cancellation token.

Interface IHandlerBuilder

Defines builder actions for configuring handler builders.

Methods:

  • SetUpdateValidating(UpdateValidateAction)

    Sets the update validating action for the handler.

  • SetConcurreny(Int32)

    Sets the concurrency level for the handler.

  • SetPriority(Int32)

    Sets the priority for the handler.

  • SetIndexer(Int32, Int32)

    Sets both concurrency and priority for the handler.

  • AddFilter(IFilter<Update>)

    Adds a filter to the handler.

  • AddFilters()

    Adds multiple filters to the handler.

  • SetStateKeeper<TKey, TState, TKeeper>(TState, IStateKeyResolver<TKey>)

    Sets a state keeper for the handler using a specific state and key resolver.

  • SetStateKeeper<TKey, TState, TKeeper>(SpecialState, IStateKeyResolver<TKey>)

    Sets a state keeper for the handler using a special state and key resolver.

  • AddTargetedFilter<TFilterTarget>(Func<Update, TFilterTarget>, IFilter<TFilterTarget>)

    Adds a targeted filter for a specific filter target type.

  • AddTargetedFilters<TFilterTarget>(Func<Update, TFilterTarget>)

    Adds multiple targeted filters for a specific filter target type.

Interface IRegularHandlerBuilder<TUpdate>

Defines a builder for regular handler logic for a specific update type.

Methods:

  • Build(AbstractHandlerAction<TUpdate>)

    Builds the handler logic using the specified execution delegate.

Class StateKeepFilter<TKey, TState, TKeeper>

Filter for state keeping logic, allowing filtering based on state and special state conditions.

Constructors:

  • StateKeepFilter<TKey, TState, TKeeper>(TState, IStateKeyResolver<TKey>)

    Initializes a new instance of the class with a specific state.

  • StateKeepFilter<TKey, TState, TKeeper>(SpecialState, IStateKeyResolver<TKey>)

    Initializes a new instance of the class with a special state.

Properties:

  • StateKeeper

    Gets or sets the state keeper instance.

  • MyState

    Gets the state value for this filter.

  • SpecialState

    Gets the special state value for this filter.

Methods:

  • CanPass(FilterExecutionContext<Update>)

    Determines whether the filter can pass for the given context based on state logic.

Class UpdateValidateFilter

Filter that uses a delegate to validate updates.

Constructors:

  • UpdateValidateFilter(UpdateValidateAction)

    Initializes a new instance of the class.

Properties:

  • IsCollectible

    Gets a value indicating whether this filter is collectable. Always false for this filter.

Methods:

  • CanPass(FilterExecutionContext<Update>)

    Determines whether the filter can pass for the given context using the validation delegate.

Handlers.Components

Class AbstractUpdateHandler<TUpdate>

Abstract handler for Telegram updates of type .

Methods:

  • CreateContainer(DescribedHandlerInfo)

    Creates a handler container for the specified awaiting provider and handler info.

  • Execute(IAbstractHandlerContainer<TUpdate>, CancellationToken)

    Abstract method to execute the update handling logic.

Class BranchingUpdateHandler<TUpdate>

Abstract base class for handlers that support branching execution based on different methods. Allows multiple handler methods to be defined in a single class, each with its own filters.

Methods:

  • DescribeHandlers()

    Describes all handler branches in this class.

  • CreateContainer(DescribedHandlerInfo)

    Creates a handler container for this branching handler.

  • Execute(IAbstractHandlerContainer<TUpdate>, CancellationToken)

    Executes the current branch method.

Class EmptyHandlerContainer

Represents an empty handler container that throws for all members.

Constructors:

  • EmptyHandlerContainer()

Properties:

  • HandlingUpdate

  • Client

  • ExtraData

  • CompletedFilters

  • AwaitingProvider

Enum FallbackReason

Specifies the reason for a filter fallback.

Values:

  • NullTarget — The filter target was null.
  • FailedFilter — The filter failed to pass.

Class FilterFallbackInfo

Contains information about a filter that failed during execution. Provides details about the filter, its failure status, and any associated exception.

Constructors:

  • FilterFallbackInfo(String, IFilter<Update>, Boolean, Exception)

    Contains information about a filter that failed during execution. Provides details about the filter, its failure status, and any associated exception.

Properties:

  • Name

    Gets the name of the filter.

  • Filter

    Gets the filter instance that failed.

  • Failed

    Gets a value indicating whether the filter failed.

  • Exception

    Gets the exception that occurred during filter execution, if any.

Class FiltersFallbackReport

Represents a report of filter fallback information for debugging and error handling. Contains detailed information about which filters failed and why during handler execution.

Constructors:

  • FiltersFallbackReport(HandlerDescriptor, FilterExecutionContext<Update>)

    Represents a report of filter fallback information for debugging and error handling. Contains detailed information about which filters failed and why during handler execution.

Properties:

  • Descriptor

    Gets the handler descriptor associated with this fallback report.

  • Context

    Gets the filter execution context that generated this report.

  • UpdateValidator

    Gets or sets the fallback information for the update validator filter.

  • StateKeeperValidator

    Gets or sets the fallback information for the state keeper validator filter.

  • UpdateFilters

    Gets the list of fallback information for update filters that failed.

Methods:

  • ExceptAttribute<T>(Int32)

    Checks if the failure is due to a specific attribute type, excluding other failures.

Class HandlerLifetimeToken

Represents a token that tracks the lifetime of a handler instance.

Constructors:

  • HandlerLifetimeToken()

Properties:

  • IsEnded

    Gets a value indicating whether the handler's lifetime has ended.

Methods:

  • LifetimeEnded()

    Marks the handler's lifetime as ended and triggers the event.

Interface IHandlerContainer

Interface for handler containers that provide context and resources for update handlers. Contains all necessary information and services that handlers need during execution.

Properties:

  • HandlingUpdate

    Gets the being handled.

  • Client

    Gets the used for this handler.

  • ExtraData

    Gets the extra data associated with the handler execution.

  • CompletedFilters

    Gets the for this handler.

  • AwaitingProvider

    Gets the for awaiting operations.

Interface IHandlerContainerFactory

Factory interface for creating handler containers. Provides a way to create handler containers with specific providers and handler information.

Methods:

  • CreateContainer(DescribedHandlerInfo)

    Creates a new for the specified awaiting provider and handler info.

Class UpdateHandlerBase

Base class for update handlers, providing execution and lifetime management for Telegram updates.

Properties:

  • HandlingUpdateType

    Gets the that this handler processes.

  • LifetimeToken

    Gets the associated with this handler instance.

Methods:

  • Execute(DescribedHandlerInfo, CancellationToken)

    Executes the handler logic and marks the lifetime as ended after execution.

  • FiltersFallback(FiltersFallbackReport, ITelegramBotClient, CancellationToken)

    Handles failed filters during handler describing. Use to control how router should treat this fail. to silently continue decribing. to stop\break desribing sequence.

  • Dispose()

Logging

Class Alligator

Centralized logging system for Telegrator. Provides static access to logging functionality with adapter support.

Properties:

  • AdaptersCount

    Gets the current adapters count.

  • MinimalLevel

    Minimal level of logging messages. Any messages below thi value will not be writen!

Methods:

  • AddAdapter(ITelegratorLogger)

    Adds a logger adapter to the centralized logging system.

  • RemoveAdapter(ITelegratorLogger)

    Removes a logger adapter from the centralized logging system.

  • ClearAdapters()

    Clears all logger adapters.

  • Log(LogLevel, String, Exception)

    Logs a message to all registered adapters.

  • LogTrace(String)

    Logs a trace message to all registered adapters.

  • LogTrace(String)

    Logs a trace message to all registered adapters.

  • LogDebug(String)

    Logs a debug message to all registered adapters.

  • LogDebug(String)

    Logs a debug message to all registered adapters.

  • LogInformation(String)

    Logs an information message to all registered adapters.

  • LogInformation(String)

    Logs an information message to all registered adapters.

  • LogWarning(String)

    Logs a warning message to all registered adapters.

  • LogWarning(String)

    Logs a warning message to all registered adapters.

  • LogError(String, Exception)

    Logs an error message to all registered adapters.

  • LogError(String)

    Logs an error message to all registered adapters.

  • LogError(Exception)

    Logs an error message with exception only to all registered adapters.

  • LogError(String, Exception)

    Logs an error message to all registered adapters.

Class ConsoleLogger

Console logger implementation that writes to System.Console. This logger is optional and can be used for simple console output.

Constructors:

  • ConsoleLogger(LogLevel, Boolean)

    Initializes a new instance of ConsoleLogger.

Methods:

  • Log(LogLevel, String, Exception)

Interface ITelegratorLogger

Interface for Telegrator logging system. Provides abstraction for logging without external dependencies.

Methods:

  • Log(LogLevel, String, Exception)

    Logs a message with specified level.

Enum LogLevel

Log levels for Telegrator logging system.

Values:

  • Trace — Trace level - most detailed logging.
  • Debug — Debug level - detailed debugging information.
  • Information — Information level - general information.
  • Warning — Warning level - warning messages.
  • Error — Error level - error messages.

Class NullLogger

Null logger implementation that does nothing. Used when logging is not required or disabled.

Methods:

  • Log(LogLevel, String, Exception)

MadiatorCore

Interface IAwaitingProvider

Provider for managing awaiting handlers that can wait for specific update types.

Methods:

  • UseHandler(HandlerDescriptor)

    Registers the usage of a handler and returns a disposable object to manage its lifetime.

Interface ICollectingProvider

Interface for providers that collect and manage handler collections. Provides access to a collection of handlers for various processing operations.

Properties:

  • Handlers

    Gets the collection of handlers managed by this provider.

Interface IHandlersCollection

Collection class for managing handler descriptors organized by update type. Provides functionality for collecting, adding, and organizing handlers.

Properties:

  • AllowedTypes

    Gets the collection of 's allowed by registered handlers

  • Keys

    Gets the collection of keys for the handler lists.

  • Values

    Gets the collection of values.

  • this[]

    Gets the for the specified .

Methods:

  • AddDescriptor(HandlerDescriptor)

    Adds a to the collection and returns the updated collection.

  • AddHandler<THandler>()

    Adds a handler of the specified type to the collection and returns the updated collection.

  • AddHandler(Type)

    Adds a handler of the specified type to the collection and returns the updated collection.

  • GetDescriptorList(HandlerDescriptor)

    Gets the for the specified .

Interface IHandlersProvider

Provides methods to retrieve and describe handler information for updates.

Properties:

  • AllowedTypes

    Gets the collection of 's allowed by registered handlers

Methods:

  • TryGetDescriptorList(UpdateType, HandlerDescriptorList)

  • GetHandlerInstance(HandlerDescriptor, CancellationToken)

    Instantiates a handler for the given descriptor, using the appropriate creation strategy based on descriptor type. Supports singleton, implicit, keyed, and general descriptor types with different instantiation patterns.

  • IsEmpty()

    Determines whether the provider contains any handlers.

Interface IPollingProvider

Interface for polling providers that manage both regular and awaiting handlers. Provides access to handlers for different types of update processing during polling operations.

Properties:

  • HandlersProvider

    Gets the that manages handlers for polling.

  • AwaitingProvider

    Gets the that manages awaiting handlers for polling.

Interface IRouterExceptionHandler

Interface for handling exceptions that occur during update routing operations. Provides a centralized way to handle and log errors that occur during bot operation.

Methods:

  • HandleException(ITelegramBotClient, Exception, HandleErrorSource, CancellationToken)

    Handles exceptions that occur during update routing.

Interface IUpdateHandlersPool

Provides a pool for managing the execution and queuing of update handlers.

Methods:

  • Enqueue(IEnumerable<DescribedHandlerInfo>)

    Enqueues a collection of handlers for execution.

Interface IUpdateRouter

Interface for update routers that handle incoming updates and manage handler execution. Combines update handling capabilities with polling provider functionality and exception handling.

Properties:

  • Options

    Gets the for the router.

  • HandlersPool

    Gets the that manages handler execution.

  • ExceptionHandler

    Gets or sets the for handling exceptions.

  • DefaultContainerFactory

    Default hand;er container factory

MadiatorCore.Descriptors

Class DescribedHandlerInfo

Contains information about a described handler, including its context, client, and execution logic.

Constructors:

  • DescribedHandlerInfo(HandlerDescriptor, IUpdateRouter, IAwaitingProvider, ITelegramBotClient, UpdateHandlerBase, FilterExecutionContext<Update>, String)

    Initializes a new instance of the class.

Properties:

  • HandlerLifetime

    Lifetime token for the handler instance.

  • DisplayString

    Display string for the handler (for debugging or logging).

Methods:

  • ToString()

Class DescriptorAspectsSet

Manages the execution of pre and post-execution aspects for a handler. This class coordinates between self-processing (handler implements interfaces) and typed processing (external processor classes).

Constructors:

  • DescriptorAspectsSet(Boolean, Type, Boolean, Type)

    Initializes a new instance of the class.

Properties:

  • SelfPre

    Gets a value indicating whether the handler implements .

  • SelfPost

    Gets a value indicating whether the handler implements .

  • TypedPre

    Gets the type of the external pre-processor, if specified via .

  • TypedPost

    Gets the type of the external post-processor, if specified via .

Methods:

  • ExecutePre(UpdateHandlerBase, IHandlerContainer, CancellationToken)

    Executes the pre-execution aspect for the handler.

  • ExecutePost(UpdateHandlerBase, IHandlerContainer, CancellationToken)

    Executes the post-execution aspect for the handler.

Class DescriptorFiltersSet

Represents a set of filters for a handler descriptor, including update and state keeper validators.

Constructors:

  • DescriptorFiltersSet(IFilter<Update>, IFilter<Update>, )

    Initializes a new instance of the class.

Properties:

  • UpdateValidator

    Validator for the update object.

  • StateKeeperValidator

    Validator for the state keeper.

  • UpdateFilters

    Array of update filters.

Methods:

  • Validate(FilterExecutionContext<Update>, Boolean, FiltersFallbackReport)

    Validates the filter context using all filters in the set.

Struct DescriptorIndexer

Represents an indexer for handler descriptors, containing importance and priority information.

Constructors:

  • DescriptorIndexer(Int32, Int32, Int32)

    Represents an indexer for handler descriptors, containing importance and priority information.

  • DescriptorIndexer(Int32, UpdateHandlerAttributeBase)

    Initializes a new instance of the struct from a handler attribute.

  • DescriptorIndexer()

Methods:

  • UpdatePriority(Int32)

    Returns a new with updated priority.

  • UpdateImportance(Int32)

    Returns a new with updated importance.

  • UpdateIndex(Int32)

    Returns a new with updated RouterIndex.

  • CompareTo(DescriptorIndexer)

    Compares this instance to another .

  • ToString()

    Returns a string representation of the indexer.

Enum DescriptorType

Specifies the type of handler descriptor.

Values:

  • General — General handler descriptor.
  • Keyed — Keyed handler descriptor (uses a service key).
  • Implicit — Implicit handler descriptor.
  • Singleton — Singleton handler descriptor (single instance).

Class HandlerDescriptor

Describes a handler, its type, filters, and instantiation logic.

Constructors:

  • HandlerDescriptor(DescriptorType, Type, Boolean)

    Initializes a new instance of the class with the specified descriptor type and handler type. Automatically inspects the handler type to extract attributes, filters, and configuration.

  • HandlerDescriptor(Type, Object)

    Initializes a new instance of the class as a keyed handler with the specified service key.

  • HandlerDescriptor(DescriptorType, Type, UpdateType, DescriptorIndexer, DescriptorFiltersSet)

    Initializes a new instance of the class with all basic properties.

  • HandlerDescriptor(DescriptorType, Type, UpdateType, DescriptorIndexer, DescriptorFiltersSet, Object, UpdateHandlerBase)

    Initializes a new instance of the class with singleton instance support.

  • HandlerDescriptor(DescriptorType, Type, UpdateType, DescriptorIndexer, DescriptorFiltersSet, Func<UpdateHandlerBase>)

    Initializes a new instance of the class with instance factory support.

  • HandlerDescriptor(DescriptorType, Type, UpdateType, DescriptorIndexer, DescriptorFiltersSet, Object, Func<UpdateHandlerBase>)

    Initializes a new instance of the class with service key and instance factory support.

  • HandlerDescriptor(DescriptorType, Type, UpdateHandlerAttributeBase, , IFilter<Update>)

    Initializes a new instance of the class with polling handler attribute and filters.

  • HandlerDescriptor(DescriptorType, Type, UpdateHandlerAttributeBase, , IFilter<Update>, Object, UpdateHandlerBase)

    Initializes a new instance of the class with polling handler attribute, filters, and singleton instance.

  • HandlerDescriptor(DescriptorType, Type, UpdateHandlerAttributeBase, , IFilter<Update>, Func<UpdateHandlerBase>)

    Initializes a new instance of the class with polling handler attribute, filters, and instance factory.

  • HandlerDescriptor(DescriptorType, Type, UpdateHandlerAttributeBase, , IFilter<Update>, Object, Func<UpdateHandlerBase>)

    Initializes a new instance of the class with polling handler attribute, filters, service key, and instance factory.

  • HandlerDescriptor(DescriptorType, Type, UpdateType, DescriptorIndexer, IFilter<Update>, , IFilter<Update>)

    Initializes a new instance of the class with validation filter support.

  • HandlerDescriptor(DescriptorType, Type, UpdateType, DescriptorIndexer, IFilter<Update>, , IFilter<Update>, Object, UpdateHandlerBase)

    Initializes a new instance of the class with validation filter and singleton instance support.

  • HandlerDescriptor(DescriptorType, Type, UpdateType, DescriptorIndexer, IFilter<Update>, , IFilter<Update>, Func<UpdateHandlerBase>)

    Initializes a new instance of the class with validation filter and instance factory support.

  • HandlerDescriptor(DescriptorType, Type, UpdateType, DescriptorIndexer, IFilter<Update>, , IFilter<Update>, Object, Func<UpdateHandlerBase>)

    Initializes a new instance of the class with validation filter, service key, and instance factory support.

Properties:

  • Type

    The type of the descriptor.

  • HandlerType

    The type of the handler.

  • UpdateType

    The update type handled by this handler.

  • Indexer

    The indexer for handler concurrency and priority.

  • FormReport

    Gets or sets a value indicating whether to form a fallback report.

  • Filters

    The set of filters associated with this handler.

  • Aspects

    Gets or sets the aspects configuration for this handler. Contains pre and post-execution processors if the handler uses the aspect system.

  • ServiceKey

    The service key for keyed handlers.

  • InstanceFactory

    Factory for creating handler instances.

  • SingletonInstance

    Singleton instance of the handler, if applicable.

  • DisplayString

    Display string for the handler (for debugging or logging).

  • LazyInitialization

    Gets or sets a function for 'lazy' handlers initialization

Methods:

  • SetInstance(UpdateHandlerBase)

    Sets singleton instance of this descriptor Throws exception if instance already set

  • TrySetInstance(UpdateHandlerBase)

    Tries to set singleton instance of this descriptor

  • ToString()

Class HandlerDescriptorList

The collection containing the 's. Used to route 's in

Constructors:

  • HandlerDescriptorList()

    Initializes a new instance of the class without a specific .

  • HandlerDescriptorList(UpdateType, ITelegratorOptions)

    Initializes a new instance of the class.

Properties:

  • IsReadOnly

    Gets a value indicating whether the collection is read-only.

  • HandlingType

    Gets the of handlers in this collection.

  • Count

    Gets count of registered handlers in list

  • this[]

    Gets or sets the at the specified index.

Methods:

  • Add(HandlerDescriptor)

    Adds a new to the collection.

  • ContainsKey(DescriptorIndexer)

    Checks if the collection contains a with the specified .

  • Remove(DescriptorIndexer)

    Removes the with the specified from the collection.

  • Remove(HandlerDescriptor)

    Removes the from the collection.

  • Clear()

    Removes all descriptos from the

  • Freeze()

    Freezes the and prohibits adding new elements to it.

  • GetEnumerator()

Class HandlerInspector

Provides methods for inspecting handler types and retrieving their attributes and filters.

Methods:

  • GetDisplayName(MemberInfo)

    Gets handler's display name

  • GetHandlerAttribute(MemberInfo)

    Gets the handler attribute from the specified member info.

  • GetStateKeeperAttribute(MemberInfo)

    Gets the state keeper attribute from the specified member info, if present.

  • GetFilterAttributes(MemberInfo, UpdateType)

    Gets all filter attributes for the specified handler type and update type.

  • GetAspects(Type)

    Gets the aspects configuration for the specified handler type. Inspects the handler for both self-processing (implements interfaces) and typed processing (uses attributes).

Class MethodHandlerDescriptor<TUpdate>

Descriptor for creating handlers from methods

Constructors:

  • MethodHandlerDescriptor<TUpdate>(AbstractHandlerAction<TUpdate>)

    Initializes new instance of

Markups

Class CallbackButtonAttribute

Constructors:

  • CallbackButtonAttribute(String, String)

Properties:

  • Name

    Name of button

  • Data

    Data that will be send to bot

Class CopyTextButtonAttribute

Constructors:

  • CopyTextButtonAttribute(String, CopyTextButton)

Properties:

  • Name

    Name of button

  • CopyText

    Text to copy

Class GameButtonAttribute

Constructors:

  • GameButtonAttribute(String, String)

Properties:

  • Name

    Name of button

  • Game

    Game to open

Class LoginButtonAttribute

Constructors:

  • LoginButtonAttribute(String, LoginUrl)

Properties:

  • Name

    Name of button

  • Url

    Url of app to login to

Class PayRequestButtonAttribute

Constructors:

  • PayRequestButtonAttribute(String)

Properties:

  • Name

    Name of button

Class QueryCurrentButtonAttribute

Constructors:

  • QueryCurrentButtonAttribute(String, String)

Properties:

  • Name

    Name of button

  • Query

    Query

Class SwitchQueryButtonAttribute

Constructors:

  • SwitchQueryButtonAttribute(String, String)

Properties:

  • Name

    Name of button

  • Query

    Query

Class UrlRedirectButtonAttribute

Constructors:

  • UrlRedirectButtonAttribute(String, String)

Properties:

  • Name

    Name of button

  • Url

    Url to redirect user

Class WebAppButtonAttribute

Constructors:

  • WebAppButtonAttribute(String, WebAppInfo)

Properties:

  • Name

    Name of button

  • AppInfo

    Info about mini app to open

Polling

Class DefaultRouterExceptionHandler

Realizes using function delegate

Constructors:

  • DefaultRouterExceptionHandler(RouterExceptionHandler)

    Realizes using function delegate

Methods:

  • HandleException(ITelegramBotClient, Exception, HandleErrorSource, CancellationToken)

Class LimitedDictionary<TKey, TValue>

Represents a dictionayr with limited number of slots, if trying to overflow, will block calling thread until one of slots will be free

Constructors:

  • LimitedDictionary<TKey, TValue>(Nullable<Int32>)

    Initializes new instance of

Methods:

  • Add(TKey, TValue, CancellationToken)

    Tries to add new element to dictioanry. If all slots are occupied, blocks calling thread.

  • Remove(TKey, TValue)

    Tries to remove element from dictionay. Frees slot on success.

  • GetEnumerator()

  • Dispose()

Class ReactiveUpdateReceiver

Reactive implementation of for polling updates from Telegram. Provides custom update receiving logic with error handling and configuration options.

Constructors:

  • ReactiveUpdateReceiver(ITelegramBotClient, ReceiverOptions)

    Reactive implementation of for polling updates from Telegram. Provides custom update receiving logic with error handling and configuration options.

Methods:

  • ReceiveAsync(IUpdateHandler, CancellationToken)

    Receives updates from Telegram using long polling. Handles update processing, error handling, and cancellation.

Class UpdateHandlersPool

Implementation of that manages the execution of handlers. Provides thread-safe queuing and execution of handlers with configurable concurrency limits.

Constructors:

  • UpdateHandlersPool(TelegratorOptions, CancellationToken)

    Initializes a new instance of the class.

Methods:

  • Enqueue(IEnumerable<DescribedHandlerInfo>)

  • Dispose()

    Disposes of the handlers pool and releases all resources.

Class UpdateRouter

Implementation of that routes updates to appropriate handlers. Manages the distribution of updates between regular handlers and awaiting handlers.

Constructors:

  • UpdateRouter(IHandlersProvider, IAwaitingProvider, TelegratorOptions, ITelegramBotInfo)

    Initializes a new instance of the class.

  • UpdateRouter(IHandlersProvider, IAwaitingProvider, TelegratorOptions, IUpdateHandlersPool, ITelegramBotInfo)

    Initializes a new instance of the class with a custom handlers pool.

Properties:

  • HandlersProvider

  • AwaitingProvider

  • Options

  • HandlersPool

  • ExceptionHandler

  • DefaultContainerFactory

Methods:

  • HandleErrorAsync(ITelegramBotClient, Exception, HandleErrorSource, CancellationToken)

    Handles errors that occur during update processing.

  • HandleUpdateAsync(ITelegramBotClient, Update, CancellationToken)

    Handles incoming updates by routing them to appropriate handlers.

  • DescribeHandler(IHandlersProvider, HandlerDescriptor, ITelegramBotClient, Update, Boolean, CancellationToken)

    Describes a single handler descriptor for a given update context. Validates the handler's filters against the update and creates a handler instance if validation passes.

Providers

Class AwaitingProvider

Provider for managing awaiting handlers that can wait for specific update types. Extends HandlersProvider to provide functionality for creating and managing awaiter handlers.

Constructors:

  • AwaitingProvider(TelegratorOptions)

    Provider for managing awaiting handlers that can wait for specific update types. Extends HandlersProvider to provide functionality for creating and managing awaiter handlers.

Methods:

  • TryGetDescriptorList(UpdateType, HandlerDescriptorList)

  • UseHandler(HandlerDescriptor)

Class HandlersCollection

Collection class for managing handler descriptors organized by update type. Provides functionality for collecting, adding, and organizing handlers.

Constructors:

  • HandlersCollection(ITelegratorOptions)

    Collection class for managing handler descriptors organized by update type. Provides functionality for collecting, adding, and organizing handlers.

Properties:

  • AllowedTypes

  • Keys

  • Values

  • this[]

Methods:

  • AddDescriptor(HandlerDescriptor)

    Adds a handler descriptor to the collection.

  • AddHandler<THandler>()

    Adds a handler type to the collection.

  • AddHandler(Type)

    Adds a handler type to the collection.

  • GetDescriptorList(HandlerDescriptor)

    Gets or creates a descriptor list for the specified update type.

Class HandlersProvider

Provides handler resolution and instantiation logic for Telegram bot updates. Responsible for mapping update types to handler descriptors, filtering handlers based on update context, and creating handler instances with appropriate lifecycle management.

Constructors:

  • HandlersProvider(IHandlersCollection, TelegratorOptions)

    Initializes a new instance of with the specified handler collections and configuration.

  • HandlersProvider(IEnumerable<HandlerDescriptorList>, TelegratorOptions)

    Initializes a new instance of with the specified handler collections and configuration.

Properties:

  • AllowedTypes

Methods:

  • GetHandlerInstance(HandlerDescriptor, CancellationToken)

  • TryGetDescriptorList(UpdateType, HandlerDescriptorList)

  • IsEmpty()

Interface ICustomDescriptorsProvider

Interface for classes that can provide custom handler descriptors. Allows classes to define their own handler description logic beyond the standard reflection-based approach.

Methods:

  • DescribeHandlers()

    Describes the handlers provided by this class.

StateKeeping

Class ChatIdResolver

Resolves chat ID from Telegram updates for state management purposes. Extracts the chat identifier from various types of updates to provide a consistent key for state operations.

Constructors:

  • ChatIdResolver()

Methods:

  • ResolveKey(Update)

    Resolves the chat ID from a Telegram update.

Class EnumStateKeeper<TEnum>

State keeper implementation for enum-based states. Automatically creates an array of all enum values for state navigation.

Constructors:

  • EnumStateKeeper<TEnum>()

    State keeper implementation for enum-based states. Automatically creates an array of all enum values for state navigation.

Properties:

  • DefaultState

    Gets the default state, which is the first value in the enum.

Class NumericStateKeeper

State keeper that manages numeric (integer) states for chat sessions. Inherits from with long keys and int states. Provides automatic increment/decrement functionality for state transitions.

Constructors:

  • NumericStateKeeper()

Properties:

  • DefaultState

    Gets the default state value, which is 1.

Class SenderIdResolver

Resolves sender ID from Telegram updates for state management purposes. Extracts the sender identifier from various types of updates to provide a consistent key for state operations.

Constructors:

  • SenderIdResolver()

Methods:

  • ResolveKey(Update)

    Resolves the sender ID from a Telegram update.

Class StateHandlerContainerExtensions

Provides extension methods for managing numeric states in handler containers.

Methods:

  • NumericStateKeeper(IHandlerContainer)

    Gets the numeric state keeper instance associated with the handler container.

  • CreateNumericState(IHandlerContainer)

    Creates a new numeric state for the current update being handled.

  • DeleteNumericState(IHandlerContainer)

    Deletes the numeric state for the current update being handled.

  • SetNumericState(IHandlerContainer, Nullable<Int32>)

    Sets the numeric state for the current update being handled. If the new state is null, uses the default state from the state keeper.

  • ForwardNumericState(IHandlerContainer)

    Moves the numeric state forward by incrementing the current value.

  • BackwardNumericState(IHandlerContainer)

    Moves the numeric state backward by decrementing the current value.

  • StringStateKeeper(IHandlerContainer)

    Gets the string state keeper instance associated with the handler container.

  • CreateStringState(IHandlerContainer)

    Creates a new string state for the current update being handled.

  • DeleteStringState(IHandlerContainer)

    Deletes the string state for the current update being handled.

  • SetStringState(IHandlerContainer, String)

    Sets the string state for the current update being handled. If the new state is null, uses the default state from the state keeper.

  • EnumStateKeeper<TEnum>(IHandlerContainer)

    Gets the enum state keeper for the specified enum type.

  • CreateEnumState<TEnum>(IHandlerContainer)

    Creates a new enum state for the current update.

  • DeleteEnumState<TEnum>(IHandlerContainer)

    Deletes the enum state for the current update.

  • SetEnumState<TEnum>(IHandlerContainer, TEnum)

    Sets the enum state to a specific value for the current update.

  • ForwardEnumState<TEnum>(IHandlerContainer)

    Moves the enum state forward to the next value in the enum sequence.

  • BackwardEnumState<TEnum>(IHandlerContainer)

    Moves the enum state backward to the previous value in the enum sequence.

Class StateHandlerContainerExtensions

Provides extension methods for managing numeric states in handler containers.

Methods:

  • NumericStateKeeper(IHandlerContainer)

    Gets the numeric state keeper instance associated with the handler container.

  • CreateNumericState(IHandlerContainer)

    Creates a new numeric state for the current update being handled.

  • DeleteNumericState(IHandlerContainer)

    Deletes the numeric state for the current update being handled.

  • SetNumericState(IHandlerContainer, Nullable<Int32>)

    Sets the numeric state for the current update being handled. If the new state is null, uses the default state from the state keeper.

  • ForwardNumericState(IHandlerContainer)

    Moves the numeric state forward by incrementing the current value.

  • BackwardNumericState(IHandlerContainer)

    Moves the numeric state backward by decrementing the current value.

  • StringStateKeeper(IHandlerContainer)

    Gets the string state keeper instance associated with the handler container.

  • CreateStringState(IHandlerContainer)

    Creates a new string state for the current update being handled.

  • DeleteStringState(IHandlerContainer)

    Deletes the string state for the current update being handled.

  • SetStringState(IHandlerContainer, String)

    Sets the string state for the current update being handled. If the new state is null, uses the default state from the state keeper.

  • EnumStateKeeper<TEnum>(IHandlerContainer)

    Gets the enum state keeper for the specified enum type.

  • CreateEnumState<TEnum>(IHandlerContainer)

    Creates a new enum state for the current update.

  • DeleteEnumState<TEnum>(IHandlerContainer)

    Deletes the enum state for the current update.

  • SetEnumState<TEnum>(IHandlerContainer, TEnum)

    Sets the enum state to a specific value for the current update.

  • ForwardEnumState<TEnum>(IHandlerContainer)

    Moves the enum state forward to the next value in the enum sequence.

  • BackwardEnumState<TEnum>(IHandlerContainer)

    Moves the enum state backward to the previous value in the enum sequence.

Class StateHandlerContainerExtensions

Provides extension methods for managing numeric states in handler containers.

Methods:

  • NumericStateKeeper(IHandlerContainer)

    Gets the numeric state keeper instance associated with the handler container.

  • CreateNumericState(IHandlerContainer)

    Creates a new numeric state for the current update being handled.

  • DeleteNumericState(IHandlerContainer)

    Deletes the numeric state for the current update being handled.

  • SetNumericState(IHandlerContainer, Nullable<Int32>)

    Sets the numeric state for the current update being handled. If the new state is null, uses the default state from the state keeper.

  • ForwardNumericState(IHandlerContainer)

    Moves the numeric state forward by incrementing the current value.

  • BackwardNumericState(IHandlerContainer)

    Moves the numeric state backward by decrementing the current value.

  • StringStateKeeper(IHandlerContainer)

    Gets the string state keeper instance associated with the handler container.

  • CreateStringState(IHandlerContainer)

    Creates a new string state for the current update being handled.

  • DeleteStringState(IHandlerContainer)

    Deletes the string state for the current update being handled.

  • SetStringState(IHandlerContainer, String)

    Sets the string state for the current update being handled. If the new state is null, uses the default state from the state keeper.

  • EnumStateKeeper<TEnum>(IHandlerContainer)

    Gets the enum state keeper for the specified enum type.

  • CreateEnumState<TEnum>(IHandlerContainer)

    Creates a new enum state for the current update.

  • DeleteEnumState<TEnum>(IHandlerContainer)

    Deletes the enum state for the current update.

  • SetEnumState<TEnum>(IHandlerContainer, TEnum)

    Sets the enum state to a specific value for the current update.

  • ForwardEnumState<TEnum>(IHandlerContainer)

    Moves the enum state forward to the next value in the enum sequence.

  • BackwardEnumState<TEnum>(IHandlerContainer)

    Moves the enum state backward to the previous value in the enum sequence.

Class StringStateKeeper

State keeper that manages string-based states for chat sessions.

Constructors:

  • StringStateKeeper()

    State keeper that manages string-based states for chat sessions.

Properties:

  • DefaultState

    Gets the default state value, which is an empty string.

StateKeeping.Abstracts

Class ArrayStateKeeper<TKey, TState>

Abstract base class for state keepers that manage state transitions using an array of predefined states. Provides forward and backward navigation through a fixed sequence of states.

Class StateKeeperBase<TKey, TState>

Base class for managing state associated with updates and keys.

Properties:

  • KeyResolver

    Gets or sets the key resolver used to resolve keys from updates.

  • DefaultState

    Gets the default state value.

Methods:

  • SetState(Update, TState)

    Sets the state for the specified update.

  • GetState(Update)

    Gets the state for the specified update.

  • TryGetState(Update, TState)

    Tries to get the state for the specified update.

  • HasState(Update)

    Determines whether a state exists for the specified update.

  • CreateState(Update)

    Creates a state for the specified update using the default state value.

  • DeleteState(Update)

    Deletes the state for the specified update.

  • MoveForward(Update)

    Moves the state forward for the specified update.

  • MoveBackward(Update)

    Moves the state backward for the specified update.

StateKeeping.Components

Interface IStateKeyResolver<TKey>

Defines a resolver for extracting a key from an update for state keeping purposes.

Methods:

  • ResolveKey(Update)

    Resolves a key from the specified .

Clone this wiki locally