3 Commits

Author SHA1 Message Date
Rikitav 0dedd3c0f4 * warnings fixes 2026-03-09 13:40:58 +04:00
Rikitav 79d5df8291 * Syntaxual refactoring 2026-03-09 13:23:21 +04:00
Rikitav 899243c62b * Added default state storage registering
* Added extension method for replacing default state storage
2026-03-09 13:10:49 +04:00
143 changed files with 9760 additions and 9862 deletions
@@ -148,6 +148,7 @@ public class ImplicitHandlerBuilderExtensionsGenerator : IIncrementalGenerator
.AddMembers([.. targetters.Values, .. extensions]);
NamespaceDeclarationSyntax namespaceDeclaration = SyntaxFactory.NamespaceDeclaration(SyntaxFactory.ParseName("Telegrator"))
.WithLeadingTrivia(SyntaxFactory.ParseLeadingTrivia("#pragma warning disable CS1591"))
.WithMembers([extensionsClass]);
CompilationUnitSyntax compilationUnit = SyntaxFactory.CompilationUnit()
+10 -2
View File
@@ -221,7 +221,7 @@
<member name="T:Telegrator.Providers.HostAwaitingProvider">
<inheritdoc/>
</member>
<member name="M:Telegrator.Providers.HostAwaitingProvider.#ctor(Microsoft.Extensions.Options.IOptions{Telegrator.TelegratorOptions},Microsoft.Extensions.Logging.ILogger{Telegrator.Providers.HostAwaitingProvider})">
<member name="M:Telegrator.Providers.HostAwaitingProvider.#ctor(Microsoft.Extensions.Options.IOptions{Telegrator.TelegratorOptions})">
<inheritdoc/>
</member>
<member name="T:Telegrator.Providers.HostHandlersCollection">
@@ -239,7 +239,7 @@
<member name="T:Telegrator.Providers.HostHandlersProvider">
<inheritdoc/>
</member>
<member name="M:Telegrator.Providers.HostHandlersProvider.#ctor(Telegrator.Core.IHandlersCollection,Microsoft.Extensions.Options.IOptions{Telegrator.TelegratorOptions},System.IServiceProvider,Microsoft.Extensions.Logging.ILogger{Telegrator.Providers.HostHandlersProvider})">
<member name="M:Telegrator.Providers.HostHandlersProvider.#ctor(Telegrator.Core.IHandlersCollection,Microsoft.Extensions.Options.IOptions{Telegrator.TelegratorOptions},System.IServiceProvider)">
<inheritdoc/>
</member>
<member name="M:Telegrator.Providers.HostHandlersProvider.GetHandlerInstance(Telegrator.Core.Descriptors.HandlerDescriptor,System.Threading.CancellationToken)">
@@ -274,6 +274,14 @@
Provides method to configure Telegram Bot Host
</summary>
</member>
<member name="M:Telegrator.ServicesCollectionExtensions.AddStateStorage``1(Microsoft.Extensions.DependencyInjection.IServiceCollection)">
<summary>
Registers <see cref="T:Telegrator.Core.States.IStateStorage"/> service
</summary>
<typeparam name="TStorage"></typeparam>
<param name="services"></param>
<returns></returns>
</member>
<member name="M:Telegrator.ServicesCollectionExtensions.AddTelegramBotHostDefaults(Microsoft.Extensions.DependencyInjection.IServiceCollection)">
<summary>
Registers <see cref="T:Telegrator.Hosting.TelegramBotHost"/> default services
+5
View File
@@ -7161,6 +7161,11 @@
Provides extension methods for working with Telegram Update objects.
</summary>
</member>
<member name="M:Telegrator.UpdateExtensions.GetUserLanguageCode(Telegram.Bot.Types.Update)">
<summary>
Extracts the IETF language tag of the user's client from the update.
</summary>
</member>
<member name="M:Telegrator.UpdateExtensions.GetSenderId(Telegram.Bot.Types.Update)">
<summary>
Selects from Update an object from which you can get the sender's ID
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>netstandard2.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
@@ -15,7 +15,7 @@
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
<Title>Telegrator.RedisStateStorage</Title>
<Version>1.16.4</Version>
<Version>1.16.5</Version>
<Authors>Rikitav Tim4ik</Authors>
<Company>Rikitav Tim4ik</Company>
<RepositoryUrl>https://github.com/Rikitav/Telegrator</RepositoryUrl>
@@ -9,3 +9,4 @@ using System.Diagnostics.CodeAnalysis;
[assembly: SuppressMessage("Style", "IDE0090")]
[assembly: SuppressMessage("Usage", "CA2254")]
[assembly: SuppressMessage("Maintainability", "CA1510")]
[assembly: SuppressMessage("Style", "IDE0270")]
@@ -7,8 +7,8 @@ using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Telegrator.Core;
namespace Telegrator.Hosting.Web
{
namespace Telegrator.Hosting.Web;
/// <summary>
/// Represents a web hosted telegram bot
/// </summary>
@@ -157,4 +157,3 @@ namespace Telegrator.Hosting.Web
_disposed = true;
}
}
}
@@ -7,8 +7,8 @@ using Microsoft.Extensions.Logging;
using Telegrator.Core;
#pragma warning disable IDE0001
namespace Telegrator.Hosting.Web
{
namespace Telegrator.Hosting.Web;
/// <summary>
/// Represents a web hosted telegram bots and services builder that helps manage configuration, logging, lifetime, and more.
/// </summary>
@@ -112,4 +112,3 @@ namespace Telegrator.Hosting.Web
((IHostApplicationBuilder)_innerBuilder).ConfigureContainer(factory, configure);
}
}
}
@@ -1,7 +1,7 @@
using System.Diagnostics.CodeAnalysis;
namespace Telegrator.Hosting.Web
{
namespace Telegrator.Hosting.Web;
/// <summary>
/// Configuration options for Telegram bot behavior and execution settings.
/// Controls various aspects of bot operation including concurrency, routing, webhook receiving, and execution policies.
@@ -32,4 +32,3 @@ namespace Telegrator.Hosting.Web
/// </summary>
public bool DropPendingUpdates { get; set; } = false;
}
}
@@ -10,8 +10,8 @@ using Telegram.Bot.Types;
using Telegrator.Core;
using Telegrator.Hosting.Web;
namespace Telegrator.Mediation
{
namespace Telegrator.Mediation;
/// <summary>
/// Service for receiving updates for Hosted telegram bots via Webhooks
/// </summary>
@@ -94,4 +94,3 @@ namespace Telegrator.Mediation
return Results.Ok();
}
}
}
@@ -15,7 +15,7 @@
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
<Title>Telegrator.Hosting.Web</Title>
<Version>1.16.4</Version>
<Version>1.16.5</Version>
<Authors>Rikitav Tim4ik</Authors>
<Company>Rikitav Tim4ik</Company>
<RepositoryUrl>https://github.com/Rikitav/Telegrator</RepositoryUrl>
@@ -9,3 +9,4 @@ using System.Diagnostics.CodeAnalysis;
[assembly: SuppressMessage("Style", "IDE0090")]
[assembly: SuppressMessage("Usage", "CA2254")]
[assembly: SuppressMessage("Maintainability", "CA1510")]
[assembly: SuppressMessage("Style", "IDE0270")]
@@ -3,8 +3,8 @@ using Telegram.Bot;
using Telegram.Bot.Types;
using Telegrator.Core;
namespace Telegrator.Hosting
{
namespace Telegrator.Hosting;
/// <summary>
/// Implementation of <see cref="ITelegramBotInfo"/> that provides bot information.
/// Contains metadata about the Telegram bot including user details and service provider for wider filterring abilities
@@ -27,4 +27,3 @@ namespace Telegrator.Hosting
/// </summary>
public IConfiguration Configuration { get; } = configuration;
}
}
@@ -3,8 +3,8 @@ using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Telegrator.Core;
namespace Telegrator.Hosting
{
namespace Telegrator.Hosting;
/// <summary>
/// Represents a hosted telegram bot
/// </summary>
@@ -112,4 +112,3 @@ namespace Telegrator.Hosting
_disposed = true;
}
}
}
@@ -3,13 +3,11 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.Metrics;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Telegrator.Core;
using Telegrator.Providers;
#pragma warning disable IDE0001
namespace Telegrator.Hosting
{
namespace Telegrator.Hosting;
/// <summary>
/// Represents a hosted telegram bots and services builder that helps manage configuration, logging, lifetime, and more.
/// </summary>
@@ -113,4 +111,3 @@ namespace Telegrator.Hosting
this.ConfigureContainer(factory, configure);
}
}
}
@@ -1,20 +1,18 @@
using Microsoft.Extensions.Logging;
namespace Telegrator.Logging;
namespace Telegrator.Logging
{
/// <summary>
/// Adapter for Microsoft.Extensions.Logging to work with Telegrator logging system.
/// This allows seamless integration with ASP.NET Core logging infrastructure.
/// </summary>
public class MicrosoftLoggingAdapter : ITelegratorLogger
{
private readonly ILogger _logger;
private readonly Microsoft.Extensions.Logging.ILogger _logger;
/// <summary>
/// Initializes a new instance of MicrosoftLoggingAdapter.
/// </summary>
/// <param name="logger">The Microsoft.Extensions.Logging logger instance.</param>
public MicrosoftLoggingAdapter(ILogger logger)
public MicrosoftLoggingAdapter(Microsoft.Extensions.Logging.ILogger logger)
{
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
@@ -24,11 +22,11 @@ namespace Telegrator.Logging
{
var msLogLevel = level switch
{
Telegrator.Logging.LogLevel.Trace => Microsoft.Extensions.Logging.LogLevel.Trace,
Telegrator.Logging.LogLevel.Debug => Microsoft.Extensions.Logging.LogLevel.Debug,
Telegrator.Logging.LogLevel.Information => Microsoft.Extensions.Logging.LogLevel.Information,
Telegrator.Logging.LogLevel.Warning => Microsoft.Extensions.Logging.LogLevel.Warning,
Telegrator.Logging.LogLevel.Error => Microsoft.Extensions.Logging.LogLevel.Error,
LogLevel.Trace => Microsoft.Extensions.Logging.LogLevel.Trace,
LogLevel.Debug => Microsoft.Extensions.Logging.LogLevel.Debug,
LogLevel.Information => Microsoft.Extensions.Logging.LogLevel.Information,
LogLevel.Warning => Microsoft.Extensions.Logging.LogLevel.Warning,
LogLevel.Error => Microsoft.Extensions.Logging.LogLevel.Error,
_ => Microsoft.Extensions.Logging.LogLevel.Information
};
@@ -42,4 +40,3 @@ namespace Telegrator.Logging
}
}
}
}
@@ -7,8 +7,8 @@ using Telegrator.Core;
using Telegrator.Core.States;
using Telegrator.Mediation;
namespace Telegrator.Polling
{
namespace Telegrator.Polling;
/// <inheritdoc/>
public class HostUpdateRouter : UpdateRouter
{
@@ -57,4 +57,3 @@ namespace Telegrator.Polling
Logger.LogError("Exception was thrown during update routing faulted :\n{exception}", exception.ToString());
}
}
}
@@ -6,8 +6,8 @@ using Telegram.Bot.Polling;
using Telegrator.Core;
using Telegrator.Mediation;
namespace Telegrator.Polling
{
namespace Telegrator.Polling;
/// <summary>
/// Service for receiving updates for Hosted telegram bots
/// </summary>
@@ -29,4 +29,3 @@ namespace Telegrator.Polling
await updateReceiver.ReceiveAsync(_updateRouter, stoppingToken).ConfigureAwait(false);
}
}
}
@@ -1,11 +1,9 @@
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.Extensions.Options;
namespace Telegrator.Providers;
namespace Telegrator.Providers
{
/// <inheritdoc/>
public class HostAwaitingProvider(IOptions<TelegratorOptions> options, ILogger<HostAwaitingProvider> logger) : AwaitingProvider(options.Value)
public class HostAwaitingProvider(IOptions<TelegratorOptions> options) : AwaitingProvider(options.Value)
{
private readonly ILogger<HostAwaitingProvider> _logger = logger;
}
}
@@ -2,8 +2,8 @@
using Telegrator.Core;
using Telegrator.Core.Descriptors;
namespace Telegrator.Providers
{
namespace Telegrator.Providers;
/// <inheritdoc/>
public class HostHandlersCollection(IServiceCollection hostServiceColletion, TelegratorOptions options) : HandlersCollection(options)
{
@@ -59,4 +59,3 @@ namespace Telegrator.Providers
return base.AddDescriptor(descriptor);
}
}
}
@@ -1,27 +1,23 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Telegrator.Core;
using Telegrator.Core.Descriptors;
using Telegrator.Core.Handlers;
namespace Telegrator.Providers
{
namespace Telegrator.Providers;
/// <inheritdoc/>
public class HostHandlersProvider : HandlersProvider
{
private readonly IServiceProvider Services;
private readonly ILogger<HostHandlersProvider> Logger;
/// <inheritdoc/>
public HostHandlersProvider(
IHandlersCollection handlers,
IOptions<TelegratorOptions> options,
IServiceProvider serviceProvider,
ILogger<HostHandlersProvider> logger) : base(handlers, options.Value)
IServiceProvider serviceProvider) : base(handlers, options.Value)
{
Services = serviceProvider;
Logger = logger;
}
/// <inheritdoc/>
@@ -42,4 +38,3 @@ namespace Telegrator.Providers
return updateHandler;
}
}
}
@@ -15,7 +15,7 @@
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
<Title>Telegrator.Hosting</Title>
<Version>1.16.4</Version>
<Version>1.16.5</Version>
<Authors>Rikitav Tim4ik</Authors>
<Company>Rikitav Tim4ik</Company>
<RepositoryUrl>https://github.com/Rikitav/Telegrator</RepositoryUrl>
+15
View File
@@ -11,10 +11,12 @@ using Telegram.Bot.Types;
using Telegram.Bot.Types.Enums;
using Telegrator.Core;
using Telegrator.Core.Descriptors;
using Telegrator.Core.States;
using Telegrator.Hosting;
using Telegrator.Logging;
using Telegrator.Polling;
using Telegrator.Providers;
using Telegrator.States;
namespace Telegrator;
@@ -112,6 +114,18 @@ public static class HostBuilderExtensions
/// </summary>
public static class ServicesCollectionExtensions
{
/// <summary>
/// Registers <see cref="IStateStorage"/> service
/// </summary>
/// <typeparam name="TStorage"></typeparam>
/// <param name="services"></param>
/// <returns></returns>
public static IServiceCollection AddStateStorage<TStorage>(this IServiceCollection services) where TStorage : IStateStorage
{
services.Replace(new ServiceDescriptor(typeof(IStateStorage), typeof(TStorage), ServiceLifetime.Singleton));
return services;
}
/// <summary>
/// Registers <see cref="TelegramBotHost"/> default services
/// </summary>
@@ -124,6 +138,7 @@ public static class ServicesCollectionExtensions
services.AddSingleton<IHandlersProvider, HostHandlersProvider>();
services.AddSingleton<IUpdateRouter, HostUpdateRouter>();
services.AddSingleton<ITelegramBotInfo, HostedTelegramBotInfo>();
services.AddSingleton<IStateStorage, DefaultStateStorage>();
return services;
}
@@ -4,8 +4,8 @@ using System.Threading.Tasks;
using Telegram.Bot.Types;
using Telegrator.Handlers;
namespace Telegrator.Localized
{
namespace Telegrator.Localized;
public static class LocalizedMessageHandlerExtensions
{
public static async Task<Message> ResponseLocalized(this ILocalizedHandler<Message> localizedHandler, string localizedReplyIdentifier, params IEnumerable<string> formatArgs)
@@ -14,4 +14,3 @@ namespace Telegrator.Localized
return await localizedHandler.Container.Responce(localizedString.Value);
}
}
}
@@ -4,8 +4,8 @@ using Telegrator.Attributes;
using Telegrator.Core.Filters;
using Telegrator.Filters;
namespace Telegrator.Annotations
{
namespace Telegrator.Annotations;
/// <summary>
/// Abstract base attribute for filtering callback-based updates.
/// Supports various message types including regular messages, edited messages, channel posts, and business messages.
@@ -41,4 +41,3 @@ namespace Telegrator.Annotations
public class CallbackInlineIdAttribute(string inlineMessageId)
: CallbackQueryAttribute(new CallbackInlineIdFilter(inlineMessageId))
{ }
}
@@ -3,8 +3,8 @@ using Telegram.Bot.Types.Enums;
using Telegrator.Filters;
using Telegrator.Attributes;
namespace Telegrator.Annotations
{
namespace Telegrator.Annotations;
/// <summary>
/// Attribute for filtering messages based on command aliases.
/// Allows handlers to respond to multiple command variations using a single attribute.
@@ -57,4 +57,3 @@ namespace Telegrator.Annotations
/// <returns>The message from the update, or null if not present.</returns>
public override Message? GetFilterringTarget(Update update) => update.Message;
}
}
@@ -1,8 +1,8 @@
using System.Text.RegularExpressions;
using Telegrator.Filters;
namespace Telegrator.Annotations
{
namespace Telegrator.Annotations;
/// <summary>
/// Attribute for filtering messages where a command has arguments count >= <paramref name="count"/>.
/// </summary>
@@ -60,4 +60,3 @@ namespace Telegrator.Annotations
public class ArgumentRegexAttribute(string pattern, RegexOptions options = RegexOptions.None, int index = 0)
: MessageFilterAttribute(new ArgumentRegexFilter(pattern, options, index: index))
{ }
}
@@ -1,5 +1,5 @@
namespace Telegrator.Annotations
{
namespace Telegrator.Annotations;
/// <summary>
/// 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.
@@ -9,4 +9,3 @@
{
}
}
@@ -4,8 +4,8 @@ using Telegrator.Filters;
using Telegrator.Attributes;
using Telegrator.Core.Filters;
namespace Telegrator.Annotations
{
namespace Telegrator.Annotations;
/// <summary>
/// Abstract base attribute for filtering updates based on environment conditions.
/// Can process all types of updates and provides environment-specific filtering logic.
@@ -82,4 +82,3 @@ namespace Telegrator.Annotations
public EnvironmentVariableAttribute(string variable, StringComparison comparison)
: base(new EnvironmentVariableFilter(variable, comparison)) { }
}
}
@@ -1,8 +1,8 @@
using Telegram.Bot.Types.Enums;
using Telegrator.Filters;
namespace Telegrator.Annotations
{
namespace Telegrator.Annotations;
/// <summary>
/// Attribute for filtering messages that contain mentions.
/// Allows handlers to respond only to messages that mention the bot or specific users.
@@ -37,4 +37,3 @@ namespace Telegrator.Annotations
public MentionedAttribute(string mention, int offset)
: base(new MessageHasEntityFilter(MessageEntityType.Mention, offset, null), new MentionedFilter(mention)) { }
}
}
@@ -1,8 +1,8 @@
using Telegram.Bot.Types.Enums;
using Telegrator.Filters;
namespace Telegrator.Annotations
{
namespace Telegrator.Annotations;
/// <summary>
/// Attribute for filtering messages sent in forum chats.
/// </summary>
@@ -102,4 +102,3 @@ namespace Telegrator.Annotations
public ChatNameAttribute(string? firstName, string? lastName)
: base(new MessageChatNameFilter(firstName, lastName)) { }
}
}
@@ -5,8 +5,8 @@ using Telegrator.Filters;
using Telegrator.Attributes;
using Telegrator.Core.Filters;
namespace Telegrator.Annotations
{
namespace Telegrator.Annotations;
/// <summary>
/// Abstract base attribute for filtering message-based updates.
/// Supports various message types including regular messages, edited messages, channel posts, and business messages.
@@ -158,4 +158,3 @@ namespace Telegrator.Annotations
public MessageHasEntityAttribute(MessageEntityType type, int offset, int? length, string content, StringComparison stringComparison = StringComparison.CurrentCulture)
: base(new MessageHasEntityFilter(type, offset, length, content, stringComparison)) { }
}
}
@@ -1,7 +1,7 @@
using Telegrator.Filters;
namespace Telegrator.Annotations
{
namespace Telegrator.Annotations;
/// <summary>
/// Attribute for filtering messages with reply to messages of this bot.
/// </summary>
@@ -24,4 +24,3 @@ namespace Telegrator.Annotations
public class FromReplyChainAttribute(int replyDepth = 1)
: MessageFilterAttribute(new FromReplyChainFilter(replyDepth))
{ }
}
@@ -1,7 +1,7 @@
using Telegrator.Filters;
namespace Telegrator.Annotations
{
namespace Telegrator.Annotations;
/// <summary>
/// Attribute for filtering messages based on the sender's username.
/// </summary>
@@ -89,4 +89,3 @@ namespace Telegrator.Annotations
public class FromPremiumUserAttribute()
: MessageFilterAttribute(new FromPremiumUserFilter())
{ }
}
@@ -1,7 +1,7 @@
using Telegrator.Filters;
namespace Telegrator.Annotations
{
namespace Telegrator.Annotations;
/// <summary>
/// Attribute for filtering messages where the text starts with the specified content.
/// </summary>
@@ -55,4 +55,3 @@ namespace Telegrator.Annotations
public class TextContainsWordAttribute(string word, StringComparison comparison = StringComparison.InvariantCulture, int startIndex = 0)
: MessageFilterAttribute(new TextContainsWordFilter(word, comparison, startIndex))
{ }
}
@@ -1,7 +1,7 @@
using Telegram.Bot.Types.Enums;
namespace Telegrator.Annotations
{
namespace Telegrator.Annotations;
/// <summary>
/// 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 <see cref="UpdateType"/>'s.
@@ -24,4 +24,3 @@ namespace Telegrator.Annotations
public MightAwaitAttribute(params UpdateType[] updateTypes)
=> _updateTypes = updateTypes;
}
}
@@ -2,8 +2,8 @@
using Telegram.Bot.Types.Enums;
using Telegrator.Filters;
namespace Telegrator.Annotations
{
namespace Telegrator.Annotations;
/// <summary>
/// Attribute for filtering message with command "start" in bot's private chats.
/// Allows handlers to respond to "welcome" bot commands.
@@ -20,4 +20,3 @@ namespace Telegrator.Annotations
Filter<Message>.If(ctx => !onlyFirst || ctx.Input.Id == 0))
{ }
}
}
@@ -1,5 +1,5 @@
namespace Telegrator.Aspects
{
namespace Telegrator.Aspects;
/// <summary>
/// Attribute that specifies a post-execution processor to be executed after the handler.
/// The processor type must implement <see cref="IPostProcessor"/> interface.
@@ -13,4 +13,3 @@
/// </summary>
public Type ProcessorType => typeof(T);
}
}
@@ -1,5 +1,5 @@
namespace Telegrator.Aspects
{
namespace Telegrator.Aspects;
/// <summary>
/// Attribute that specifies a pre-execution processor to be executed before the handler.
/// The processor type must implement <see cref="IPreProcessor"/> interface.
@@ -13,4 +13,3 @@
/// </summary>
public Type ProcessorType => typeof(T);
}
}
+2 -3
View File
@@ -1,7 +1,7 @@
using Telegrator.Core.Handlers;
namespace Telegrator.Aspects
{
namespace Telegrator.Aspects;
/// <summary>
/// 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.
@@ -16,4 +16,3 @@ namespace Telegrator.Aspects
/// <returns>A <see cref="Result"/> indicating the final execution result.</returns>
public Task<Result> AfterExecution(IHandlerContainer container, CancellationToken cancellationToken);
}
}
+2 -3
View File
@@ -1,7 +1,7 @@
using Telegrator.Core.Handlers;
namespace Telegrator.Aspects
{
namespace Telegrator.Aspects;
/// <summary>
/// Interface for pre-execution processors that are executed before handler execution.
/// Implement this interface to add cross-cutting concerns like validation, logging, or authorization.
@@ -16,4 +16,3 @@ namespace Telegrator.Aspects
/// <returns>A <see cref="Result"/> indicating whether execution should continue or be stopped.</returns>
public Task<Result> BeforeExecution(IHandlerContainer container, CancellationToken cancellationToken = default);
}
}
@@ -3,8 +3,8 @@ using Telegram.Bot.Types.Enums;
using Telegrator.Core.Filters;
using Telegrator.Filters;
namespace Telegrator.Attributes
{
namespace Telegrator.Attributes;
/// <summary>
/// Reactive way to implement a new <see cref="UpdateFilterAttribute{T}"/> of type <typeparamref name="T"/>
/// </summary>
@@ -36,4 +36,3 @@ namespace Telegrator.Attributes
/// <inheritdoc/>
public abstract bool CanPass(FilterExecutionContext<T> context);
}
}
+2 -3
View File
@@ -1,5 +1,5 @@
namespace Telegrator.Attributes
{
namespace Telegrator.Attributes;
/// <summary>
/// Enumeration of filter modifiers that can be applied to update filters.
/// Defines how filters should be combined and applied in filter chains.
@@ -22,4 +22,3 @@
/// </summary>
Not = 4,
}
}
@@ -3,8 +3,8 @@ using Telegrator.Core.Attributes;
using Telegrator.Core.Filters;
using Telegrator.Filters;
namespace Telegrator.Attributes
{
namespace Telegrator.Attributes;
/// <summary>
/// Abstract base attribute for defining update filters for a specific type of update target.
/// Provides logic for filter composition, modifier processing, and target extraction.
@@ -82,4 +82,3 @@ namespace Telegrator.Attributes
/// <returns>The target object to filter, or null if not applicable</returns>
public abstract T? GetFilterringTarget(Update update);
}
}
@@ -2,8 +2,8 @@
using Telegrator.Core.Attributes;
using Telegrator.Core.Handlers;
namespace Telegrator.Attributes
{
namespace Telegrator.Attributes;
/// <summary>
/// Abstract base attribute for marking update handler classes.
/// Provides a type-safe way to associate handler types with specific update types and importance settings.
@@ -43,4 +43,3 @@ namespace Telegrator.Attributes
protected UpdateHandlerAttribute(Type[] types, UpdateType updateType, int importance)
: base([.. types, typeof(T)], updateType, importance) { }
}
}
@@ -5,8 +5,8 @@ using Telegrator.Core.Filters;
using Telegrator.Core.Handlers;
using Telegrator.Filters;
namespace Telegrator.Core.Attributes
{
namespace Telegrator.Core.Attributes;
/// <summary>
/// Defines the <see cref="IFilter{T}"/> to <see cref="Update"/> validation for entry into execution of the <see cref="UpdateHandlerBase"/>
/// </summary>
@@ -44,4 +44,3 @@ namespace Telegrator.Core.Attributes
/// <returns></returns>
public abstract bool ProcessModifiers(UpdateFilterAttributeBase? previous);
}
}
@@ -4,8 +4,8 @@ using Telegrator.Core.Descriptors;
using Telegrator.Core.Filters;
using Telegrator.Core.Handlers;
namespace Telegrator.Core.Attributes
{
namespace Telegrator.Core.Attributes;
/// <summary>
/// Defines the <see cref="UpdateType"/>'s and validator (<see cref="IFilter{T}"/>) of the <see cref="Update"/> that <see cref="UpdateHandlerBase"/> will process
/// </summary>
@@ -79,4 +79,3 @@ namespace Telegrator.Core.Attributes
/// <returns>True if the update passes validation; otherwise, false.</returns>
public abstract bool CanPass(FilterExecutionContext<Update> context);
}
}
@@ -7,8 +7,8 @@ using Telegrator.Core.Handlers;
using Telegrator.Handlers;
using Telegrator.Handlers.Building;
namespace Telegrator.Core.Descriptors
{
namespace Telegrator.Core.Descriptors;
/// <summary>
/// Descriptor for creating handlers from methods
/// </summary>
@@ -67,4 +67,3 @@ namespace Telegrator.Core.Descriptors
}
}
}
}
@@ -4,8 +4,8 @@ using Telegrator.Core.Filters;
using Telegrator.Core.Handlers;
using Telegrator.Core.States;
namespace Telegrator.Core.Descriptors
{
namespace Telegrator.Core.Descriptors;
/// <summary>
/// Contains information about a described handler, including its context, client, and execution logic.
/// </summary>
@@ -134,4 +134,3 @@ namespace Telegrator.Core.Descriptors
public override string ToString()
=> DisplayString ?? From.HandlerType.Name;
}
}
@@ -1,8 +1,8 @@
using Telegrator.Aspects;
using Telegrator.Core.Handlers;
namespace Telegrator.Core.Descriptors
{
namespace Telegrator.Core.Descriptors;
/// <summary>
/// Manages the execution of pre and post-execution aspects for a handler.
/// This class coordinates between self-processing (handler implements interfaces)
@@ -77,4 +77,3 @@ namespace Telegrator.Core.Descriptors
return Result.Ok();
}
}
}
@@ -3,8 +3,8 @@ using Telegrator.Core.Filters;
using Telegrator.Handlers.Diagnostics;
using Telegrator.Logging;
namespace Telegrator.Core.Descriptors
{
namespace Telegrator.Core.Descriptors;
/// <summary>
/// Represents a set of filters for a handler descriptor, including update and state keeper validators.
/// </summary>
@@ -142,4 +142,3 @@ namespace Telegrator.Core.Descriptors
}
}
}
}
@@ -1,7 +1,7 @@
using Telegrator.Core.Attributes;
namespace Telegrator.Core.Descriptors
{
namespace Telegrator.Core.Descriptors;
/// <summary>
/// Represents an indexer for handler descriptors, containing importance and priority information.
/// </summary>
@@ -85,4 +85,3 @@ namespace Telegrator.Core.Descriptors
return string.Format("(Ix: {0,2}, Im: {1,2}, Pr: {2,2})", RouterIndex, Importance, Priority);
}
}
}
@@ -4,8 +4,8 @@ using Telegrator.Core.Attributes;
using Telegrator.Core.Filters;
using Telegrator.Core.Handlers;
namespace Telegrator.Core.Descriptors
{
namespace Telegrator.Core.Descriptors;
/// <summary>
/// Specifies the type of handler descriptor.
/// </summary>
@@ -472,4 +472,3 @@ namespace Telegrator.Core.Descriptors
public override string ToString()
=> DisplayString ?? HandlerType.Name;
}
}
@@ -2,8 +2,8 @@
using Telegram.Bot.Types;
using Telegram.Bot.Types.Enums;
namespace Telegrator.Core.Descriptors
{
namespace Telegrator.Core.Descriptors;
/// <summary>
/// The collection containing the <see cref="HandlerDescriptor"/>'s. Used to route <see cref="Update"/>'s in <see cref="IHandlersProvider"/>
/// </summary>
@@ -156,4 +156,3 @@ namespace Telegrator.Core.Descriptors
return _innerCollection.Values.GetEnumerator();
}
}
}
@@ -7,8 +7,8 @@ using Telegrator.Aspects;
using Telegrator.Core.Attributes;
using Telegrator.Core.Filters;
namespace Telegrator.Core.Descriptors
{
namespace Telegrator.Core.Descriptors;
/// <summary>
/// Provides methods for inspecting handler types and retrieving their attributes and filters.
/// </summary>
@@ -96,4 +96,3 @@ namespace Telegrator.Core.Descriptors
return new DescriptorAspectsSet(typedPre, typedPost);
}
}
}
@@ -2,8 +2,8 @@
using Telegrator.Filters;
using Telegrator.Logging;
namespace Telegrator.Core.Filters
{
namespace Telegrator.Core.Filters;
/// <summary>
/// Represents a compiled filter that applies a set of filters to an anonymous target type.
/// </summary>
@@ -106,4 +106,3 @@ namespace Telegrator.Core.Filters
}
}
}
}
@@ -2,8 +2,8 @@
using Telegrator.Filters;
using Telegrator.Logging;
namespace Telegrator.Core.Filters
{
namespace Telegrator.Core.Filters;
/// <summary>
/// Represents a filter that applies a filter action to an anonymous target type extracted from an update.
/// </summary>
@@ -107,4 +107,3 @@ namespace Telegrator.Core.Filters
}
}
}
}
@@ -1,8 +1,8 @@
using Telegrator.Filters;
using Telegrator.Logging;
namespace Telegrator.Core.Filters
{
namespace Telegrator.Core.Filters;
/// <summary>
/// Represents a filter that composes multiple filters and passes only if all of them pass.
/// </summary>
@@ -61,4 +61,3 @@ namespace Telegrator.Core.Filters
return true;
}
}
}
@@ -1,7 +1,7 @@
using System.Collections;
namespace Telegrator.Core.Filters
{
namespace Telegrator.Core.Filters;
/// <summary>
/// The list containing filters worked out during Polling to further obtain additional filtering information
/// </summary>
@@ -83,4 +83,3 @@ namespace Telegrator.Core.Filters
/// <inheritdoc/>
IEnumerator IEnumerable.GetEnumerator() => CompletedFilters.GetEnumerator();
}
}
@@ -1,8 +1,8 @@
using Telegram.Bot.Types;
using Telegram.Bot.Types.Enums;
namespace Telegrator.Core.Filters
{
namespace Telegrator.Core.Filters;
/// <summary>
/// Represents the context for filter execution, including update, input, and additional data.
/// </summary>
@@ -83,4 +83,3 @@ namespace Telegrator.Core.Filters
public FilterExecutionContext<C> CreateChild<C>(C input) where C : class
=> new FilterExecutionContext<C>(UpdateRouter, BotInfo, Update, input, Data, CompletedFilters);
}
}
+13 -2
View File
@@ -1,5 +1,5 @@
namespace Telegrator.Core.Filters
{
namespace Telegrator.Core.Filters;
/// <summary>
/// Interface for filters that have a name for identification and debugging purposes.
/// </summary>
@@ -36,4 +36,15 @@
/// <returns>True if the filter passes; otherwise, false.</returns>
public bool CanPass(FilterExecutionContext<T> info);
}
/// <summary>
/// Represents a filter that joins multiple filters together.
/// </summary>
/// <typeparam name="T">The type of the input for the filter.</typeparam>
public interface IJoinedFilter<T> : IFilter<T> where T : class
{
/// <summary>
/// Gets the array of joined filters.
/// </summary>
public IFilter<T>[] Filters { get; }
}
@@ -1,14 +0,0 @@
namespace Telegrator.Core.Filters
{
/// <summary>
/// Represents a filter that joins multiple filters together.
/// </summary>
/// <typeparam name="T">The type of the input for the filter.</typeparam>
public interface IJoinedFilter<T> : IFilter<T> where T : class
{
/// <summary>
/// Gets the array of joined filters.
/// </summary>
public IFilter<T>[] Filters { get; }
}
}
@@ -6,8 +6,8 @@ using Telegrator.Core.Filters;
using Telegrator.Core.States;
using Telegrator.Handlers;
namespace Telegrator.Core.Handlers
{
namespace Telegrator.Core.Handlers;
/// <summary>
/// Abstract handler for Telegram updates of type <typeparamref name="TUpdate"/>.
/// </summary>
@@ -93,4 +93,3 @@ namespace Telegrator.Core.Handlers
/// <returns>A task representing the asynchronous operation.</returns>
public abstract Task<Result> Execute(IHandlerContainer<TUpdate> container, CancellationToken cancellation);
}
}
@@ -6,8 +6,8 @@ using Telegrator.Core.Descriptors;
using Telegrator.Core.Filters;
using Telegrator.Handlers;
namespace Telegrator.Core.Handlers
{
namespace Telegrator.Core.Handlers;
/// <summary>
/// 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.
@@ -162,4 +162,3 @@ namespace Telegrator.Core.Handlers
}
}
}
}
@@ -5,8 +5,8 @@ using Telegrator.Core.Filters;
using Telegrator.Core.States;
using Telegrator.Filters;
namespace Telegrator.Core.Handlers.Building
{
namespace Telegrator.Core.Handlers.Building;
/// <summary>
/// Base class for building handler descriptors and managing handler filters.
/// </summary>
@@ -177,4 +177,3 @@ namespace Telegrator.Core.Handlers.Building
Filters.Add(compiledPollingFilter);
}
}
}
@@ -1,7 +1,7 @@
using Telegrator.Core.States;
namespace Telegrator.Core.Handlers.Building
{
namespace Telegrator.Core.Handlers.Building;
/// <summary>
/// Defines a builder for awaiting handler logic for a specific update type.
/// </summary>
@@ -16,4 +16,3 @@ namespace Telegrator.Core.Handlers.Building
/// <returns>A <see cref="Task{TUpdate}"/> representing the awaited update.</returns>
public Task<TUpdate> Await(IStateKeyResolver keyResolver, CancellationToken cancellationToken = default);
}
}
@@ -2,8 +2,8 @@
using Telegrator.Core.Filters;
using Telegrator.Core.States;
namespace Telegrator.Core.Handlers.Building
{
namespace Telegrator.Core.Handlers.Building;
/// <summary>
/// Defines builder actions for configuring handler builders.
/// </summary>
@@ -83,4 +83,3 @@ namespace Telegrator.Core.Handlers.Building
public void AddTargetedFilters<TFilterTarget>(Func<Update, TFilterTarget?> getFilterringTarget, params IFilter<TFilterTarget>[] filters)
where TFilterTarget : class;
}
}
@@ -1,7 +1,7 @@
using Telegrator.Handlers.Building;
namespace Telegrator.Core.Handlers.Building
{
namespace Telegrator.Core.Handlers.Building;
/// <summary>
/// Defines a builder for regular handler logic for a specific update type.
/// </summary>
@@ -14,4 +14,3 @@ namespace Telegrator.Core.Handlers.Building
/// <param name="executeHandler">The delegate to execute the handler logic.</param>
public IHandlersCollection Build(AbstractHandlerAction<TUpdate> executeHandler);
}
}
@@ -1,8 +1,8 @@
using Telegram.Bot.Types;
using Telegrator.Core.Filters;
namespace Telegrator.Core.Handlers.Building
{
namespace Telegrator.Core.Handlers.Building;
/// <summary>
/// Delegate for validating an update in a filter context.
/// </summary>
@@ -38,4 +38,3 @@ namespace Telegrator.Core.Handlers.Building
public bool CanPass(FilterExecutionContext<Update> info)
=> UpdateValidateAction.Invoke(info);
}
}
@@ -3,8 +3,8 @@ using Telegram.Bot.Types;
using Telegrator.Core.Filters;
using Telegrator.Core.States;
namespace Telegrator.Core.Handlers
{
namespace Telegrator.Core.Handlers;
/// <summary>
/// Represents an empty handler container that throws <see cref="NotImplementedException"/> for all members.
/// </summary>
@@ -28,4 +28,3 @@ namespace Telegrator.Core.Handlers
/// <inheritdoc/>
public IStateStorage StateStorage => throw new NotImplementedException();
}
}
@@ -1,5 +1,5 @@
namespace Telegrator.Core.Handlers
{
namespace Telegrator.Core.Handlers;
/// <summary>
/// Represents a token that tracks the lifetime of a handler instance.
/// </summary>
@@ -24,4 +24,3 @@
OnLifetimeEnded?.Invoke(this);
}
}
}
@@ -3,8 +3,8 @@ using Telegram.Bot.Types;
using Telegrator.Core.Filters;
using Telegrator.Core.States;
namespace Telegrator.Core.Handlers
{
namespace Telegrator.Core.Handlers;
/// <summary>
/// Interface for handler containers that provide context and resources for update handlers.
/// Contains all necessary information and services that handlers need during execution.
@@ -41,4 +41,3 @@ namespace Telegrator.Core.Handlers
/// </summary>
public IStateStorage StateStorage { get; }
}
}
@@ -1,7 +1,7 @@
using Telegrator.Core.Descriptors;
namespace Telegrator.Core.Handlers
{
namespace Telegrator.Core.Handlers;
/// <summary>
/// Factory interface for creating handler containers.
/// Provides a way to create handler containers with specific providers and handler information.
@@ -15,4 +15,3 @@ namespace Telegrator.Core.Handlers
/// <returns>A new <see cref="IHandlerContainer"/> instance.</returns>
public IHandlerContainer CreateContainer(DescribedHandlerDescriptor handlerInfo);
}
}
@@ -4,8 +4,8 @@ using Telegram.Bot.Types.Enums;
using Telegrator.Core.Descriptors;
using Telegrator.Handlers.Diagnostics;
namespace Telegrator.Core.Handlers
{
namespace Telegrator.Core.Handlers;
/// <summary>
/// Base class for update handlers, providing execution and lifetime management for Telegram updates.
/// </summary>
@@ -179,4 +179,3 @@ namespace Telegrator.Core.Handlers
GC.SuppressFinalize(this);
}
}
}
+2 -3
View File
@@ -1,7 +1,7 @@
using Telegrator.Core.Descriptors;
namespace Telegrator.Core
{
namespace Telegrator.Core;
/// <summary>
/// Provider for managing awaiting handlers that can wait for specific update types.
/// </summary>
@@ -14,4 +14,3 @@ namespace Telegrator.Core
/// <returns>An <see cref="IDisposable"/> that manages the handler's usage lifetime.</returns>
public IDisposable UseHandler(HandlerDescriptor handlerDescriptor);
}
}
+2 -3
View File
@@ -1,5 +1,5 @@
namespace Telegrator.Core
{
namespace Telegrator.Core;
/// <summary>
/// Interface for providers that collect and manage handler collections.
/// Provides access to a collection of handlers for various processing operations.
@@ -11,4 +11,3 @@
/// </summary>
public IHandlersCollection Handlers { get; }
}
}
@@ -1,7 +1,7 @@
using Telegrator.Core.Descriptors;
namespace Telegrator.Core
{
namespace Telegrator.Core;
/// <summary>
/// Interface for classes that can provide custom handler descriptors.
/// Allows classes to define their own handler description logic beyond the standard reflection-based approach.
@@ -14,4 +14,3 @@ namespace Telegrator.Core
/// <returns>A collection of handler descriptors.</returns>
public IEnumerable<HandlerDescriptor> DescribeHandlers();
}
}
+2 -3
View File
@@ -1,8 +1,8 @@
using Telegram.Bot.Types.Enums;
using Telegrator.Core.Descriptors;
namespace Telegrator.Core
{
namespace Telegrator.Core;
/// <summary>
/// Collection class for managing handler descriptors organized by update type.
/// Provides functionality for collecting, adding, and organizing handlers.
@@ -38,4 +38,3 @@ namespace Telegrator.Core
/// <returns>The updated <see cref="IHandlersCollection"/>.</returns>
public IHandlersCollection AddDescriptor(HandlerDescriptor descriptor);
}
}
+2 -3
View File
@@ -1,5 +1,5 @@
namespace Telegrator.Core
{
namespace Telegrator.Core;
/// <summary>
/// Combines <see cref="IHandlersCollection"/> and <see cref="IHandlersProvider"/>.
/// Provides functionality of collecting, organizing and resolving handlers instances.
@@ -8,4 +8,3 @@
{
}
}
+2 -3
View File
@@ -2,8 +2,8 @@
using Telegrator.Core.Descriptors;
using Telegrator.Core.Handlers;
namespace Telegrator.Core
{
namespace Telegrator.Core;
/// <summary>
/// Provides methods to retrieve and describe handler information for updates.
/// </summary>
@@ -37,4 +37,3 @@ namespace Telegrator.Core
/// <returns>True if the provider is empty; otherwise, false.</returns>
public bool IsEmpty();
}
}
@@ -1,8 +1,8 @@
using Telegram.Bot;
using Telegram.Bot.Polling;
namespace Telegrator.Core
{
namespace Telegrator.Core;
/// <summary>
/// Interface for handling exceptions that occur during update routing operations.
/// Provides a centralized way to handle and log errors that occur during bot operation.
@@ -18,4 +18,3 @@ namespace Telegrator.Core
/// <param name="cancellationToken">The cancellation token.</param>
public void HandleException(ITelegramBotClient botClient, Exception exception, HandleErrorSource source, CancellationToken cancellationToken);
}
}
+2 -3
View File
@@ -1,7 +1,7 @@
using Telegram.Bot.Types;
namespace Telegrator.Core
{
namespace Telegrator.Core;
/// <summary>
/// Interface for providing bot information and metadata.
/// Contains information about the bot user and provides initialization capabilities.
@@ -13,4 +13,3 @@ namespace Telegrator.Core
/// </summary>
public User User { get; }
}
}
+2 -3
View File
@@ -1,7 +1,7 @@
using Telegrator.Core.Descriptors;
namespace Telegrator.Core
{
namespace Telegrator.Core;
/// <summary>
/// Represents a delegate for when a handler is enqueued.
/// </summary>
@@ -35,4 +35,3 @@ namespace Telegrator.Core
/// <param name="handlers">The handlers to enqueue.</param>
public Task Enqueue(params IEnumerable<DescribedHandlerDescriptor> handlers);
}
}
+2 -3
View File
@@ -2,8 +2,8 @@
using Telegrator.Core.Handlers;
using Telegrator.Core.States;
namespace Telegrator.Core
{
namespace Telegrator.Core;
/// <summary>
/// Interface for update routers that handle incoming updates and manage handler execution.
/// Combines update handling capabilities with polling provider functionality and exception handling.
@@ -45,4 +45,3 @@ namespace Telegrator.Core
/// </summary>
public IHandlerContainerFactory? DefaultContainerFactory { get; set; }
}
}
+2 -3
View File
@@ -1,5 +1,5 @@
namespace Telegrator
{
namespace Telegrator;
/// <summary>
/// Enumeration of dice types supported by Telegram.
/// Used for filtering dice messages and determining dice emoji representations.
@@ -131,4 +131,3 @@
HandlersPool = 0x8
}
*/
}
+2 -3
View File
@@ -1,7 +1,7 @@
using Telegrator.Core.Descriptors;
namespace Telegrator
{
namespace Telegrator;
/// <summary>
/// Exception thrown when attempting to modify a frozen collection.
/// </summary>
@@ -49,4 +49,3 @@ namespace Telegrator
HandlerInfo = handlerInfo;
}
}
}
@@ -2,8 +2,8 @@
using Telegram.Bot.Types;
using Telegrator.Core.Filters;
namespace Telegrator.Filters
{
namespace Telegrator.Filters;
/// <summary>
/// Filter thet checks <see cref="CallbackQuery"/>'s data
/// </summary>
@@ -70,4 +70,3 @@ namespace Telegrator.Filters
public CallbackRegexFilter(Regex regex)
: base(clb => clb.Data, regex) { }
}
}
+2 -3
View File
@@ -2,8 +2,8 @@
using Telegrator.Core.Filters;
using Telegrator.Handlers;
namespace Telegrator.Filters
{
namespace Telegrator.Filters;
/// <summary>
/// Filter that checks if a command matches any of the specified aliases.
/// Requires a <see cref="CommandHandlerAttribute"/> to be applied first to extract the command.
@@ -29,4 +29,3 @@ namespace Telegrator.Filters
return alliases.Contains(ReceivedCommand, StringComparer.InvariantCultureIgnoreCase);
}
}
}
@@ -3,8 +3,8 @@ using Telegram.Bot.Types;
using Telegrator.Core.Filters;
using Telegrator.Handlers;
namespace Telegrator.Filters
{
namespace Telegrator.Filters;
/// <summary>
/// Abstract base class for filters that operate on command arguments.
/// Provides functionality to extract and validate command arguments from message text.
@@ -202,4 +202,3 @@ namespace Telegrator.Filters
return Match.Success;
}
}
}
+2 -3
View File
@@ -2,8 +2,8 @@
using Telegram.Bot.Types;
using Telegrator.Core.Filters;
namespace Telegrator.Filters
{
namespace Telegrator.Filters;
/// <summary>
/// Abstract base class for filters that operate based on the current environment.
/// Provides functionality to detect debug vs release environments.
@@ -122,4 +122,3 @@ namespace Telegrator.Filters
return envValue.Equals(_value, _comparison);
}
}
}
+2 -3
View File
@@ -1,7 +1,7 @@
using Telegrator.Core.Filters;
namespace Telegrator.Filters
{
namespace Telegrator.Filters;
/// <summary>
/// Base class for filters, providing logical operations and collectability.
/// </summary>
@@ -132,4 +132,3 @@ namespace Telegrator.Filters
public override bool CanPass(FilterExecutionContext<T> context)
=> context.Input != null && FilterFunc != null && FilterFunc(context);
}
}
+2 -3
View File
@@ -1,7 +1,7 @@
using Telegrator.Core.Filters;
namespace Telegrator.Filters
{
namespace Telegrator.Filters;
/// <summary>
/// Base class for filters that join multiple filters together.
/// </summary>
@@ -51,4 +51,3 @@ namespace Telegrator.Filters
public override bool CanPass(FilterExecutionContext<T> context)
=> Filters[0].CanPass(context) || Filters[1].CanPass(context);
}
}
+2 -3
View File
@@ -2,8 +2,8 @@
using Telegram.Bot.Types.Enums;
using Telegrator.Core.Filters;
namespace Telegrator.Filters
{
namespace Telegrator.Filters;
/// <summary>
/// Filter that checks if a message contains a mention of the bot or a specific user.
/// Requires a <see cref="MessageHasEntityFilter"/> to be applied first to identify mention entities.
@@ -61,4 +61,3 @@ namespace Telegrator.Filters
return false;
}
}
}
+2 -3
View File
@@ -3,8 +3,8 @@ using Telegram.Bot.Types.Enums;
using Telegram.Bot.Types.ReplyMarkups;
using Telegrator.Core.Filters;
namespace Telegrator.Filters
{
namespace Telegrator.Filters;
/// <summary>
/// Base class for filters that operate on the chat of the message being processed.
/// </summary>
@@ -217,4 +217,3 @@ namespace Telegrator.Filters
return true;
}
}
}
+2 -3
View File
@@ -3,8 +3,8 @@ using Telegram.Bot.Types;
using Telegram.Bot.Types.Enums;
using Telegrator.Core.Filters;
namespace Telegrator.Filters
{
namespace Telegrator.Filters;
/// <summary>
/// Base abstract class for all filter of <see cref="Message"/> updates
/// </summary>
@@ -272,4 +272,3 @@ namespace Telegrator.Filters
return true;
}
}
}
@@ -1,8 +1,8 @@
using Telegram.Bot.Types;
using Telegrator.Core.Filters;
namespace Telegrator.Filters
{
namespace Telegrator.Filters;
/// <summary>
/// Filter that checks if message has appropriate reply chain.
/// DOES NOT SHiFT MESSAGE FILTERS TARGET
@@ -99,4 +99,3 @@ namespace Telegrator.Filters
return context.BotInfo.User == repliedFilter.Reply.From;
}
}
}
@@ -1,8 +1,8 @@
using Telegram.Bot.Types;
using Telegrator.Core.Filters;
namespace Telegrator.Filters
{
namespace Telegrator.Filters;
/// <summary>
/// Abstract base class for filters that operate on message senders.
/// Provides functionality to access and validate the user who sent the message.
@@ -179,4 +179,3 @@ namespace Telegrator.Filters
protected override bool CanPassNext(FilterExecutionContext<Message> _)
=> User.IsPremium;
}
}
+2 -4
View File
@@ -1,9 +1,8 @@
using Telegram.Bot.Types;
using Telegrator.Core.Filters;
using static System.Net.Mime.MediaTypeNames;
namespace Telegrator.Filters
{
namespace Telegrator.Filters;
/// <summary>
/// Abstract base class for filters that operate on message text content.
/// Provides common functionality for extracting and validating message text.
@@ -182,4 +181,3 @@ namespace Telegrator.Filters
protected override bool CanPassNext(FilterExecutionContext<Message> context)
=> Text.ContainsWord(Word, Comparison, StartIndex);
}
}
+2 -3
View File
@@ -1,8 +1,8 @@
using System.Text.RegularExpressions;
using Telegrator.Core.Filters;
namespace Telegrator.Filters
{
namespace Telegrator.Filters;
/// <summary>
/// Base class for filters that use regular expressions to match text in updates.
/// </summary>
@@ -55,4 +55,3 @@ namespace Telegrator.Filters
return Matches.Count > 0;
}
}
}
+2 -3
View File
@@ -2,8 +2,8 @@
using Telegrator.Core.Filters;
using Telegrator.Core.States;
namespace Telegrator.Filters
{
namespace Telegrator.Filters;
/// <summary>
/// Filters updates by comparing a resolved state key with a target key.
/// </summary>
@@ -41,4 +41,3 @@ namespace Telegrator.Filters
return TargetKey.Equals(value);
}
}
}
+1
View File
@@ -8,3 +8,4 @@ using System.Diagnostics.CodeAnalysis;
[assembly: SuppressMessage("Style", "IDE0290")]
[assembly: SuppressMessage("Style", "IDE0090")]
[assembly: SuppressMessage("Style", "IDE0057")]
[assembly: SuppressMessage("Style", "IDE0270")]

Some files were not shown because too many files have changed in this diff Show More