From 866129f2ff446a5cb79703d1c1954b0325f6c6ac Mon Sep 17 00:00:00 2001 From: Rikitav Date: Fri, 6 Mar 2026 23:19:24 +0400 Subject: [PATCH] * Architectural rework --- Telegrator.slnx | 12 +-- .../ITelegramBotWebHost.cs | 3 +- .../{ => Hosting.Web}/TelegramBotWebHost.cs | 4 +- .../TelegramBotWebHostBuilder.cs | 7 +- .../TelegramBotWebOptions.cs | 0 .../{ => Hosting.Web}/TelegratorWebOptions.cs | 0 .../HostedUpdateWebhooker.cs | 5 +- .../Telegrator.Hosting.Web.csproj | 1 + src/Telegrator.Hosting.Web/TypesExtensions.cs | 13 ++- .../ConfigureOptionsProxy.cs | 2 +- .../IHostHandlersCollection.cs | 4 +- .../IPreBuildingRoutine.cs | 4 +- .../{ => Hosting}/HostedTelegramBotInfo.cs | 2 +- .../ITelegramBotHost.cs | 3 +- .../ITelegramBotHostBuilder.cs | 4 +- .../{ => Hosting}/TelegramBotHost.cs | 3 +- .../{ => Hosting}/TelegramBotHostBuilder.cs | 3 +- .../TelegramBotHostBuilderSettings.cs | 0 .../Logging/MicrosoftLoggingAdapter.cs | 5 +- .../Polling/HostUpdateHandlersPool.cs | 6 +- .../Polling/HostUpdateRouter.cs | 7 +- .../Polling/HostedUpdateReceiver.cs | 8 +- .../Providers/HostAwaitingProvider.cs | 3 +- .../Providers/HostHandlersCollection.cs | 12 ++- .../Providers/HostHandlersProvider.cs | 9 +- .../TelegramBotClientOptionsProxy.cs | 2 +- .../Telegrator.Hosting.csproj | 1 + src/Telegrator.Hosting/TypesExtensions.cs | 19 ++-- src/Telegrator.Localized/ILocalizedHandler.cs | 2 +- .../Annotations/CallbackQueryAttributes.cs | 2 +- .../EnvironmentFilterAttributes.cs | 2 +- .../Annotations/MessageFilterAttributes.cs | 2 +- .../StateKeeping/EnumStateAttribute.cs | 2 +- .../StateKeeping/NumericStateAttribute.cs | 2 +- .../StateKeeping/StringStateAttribute.cs | 2 +- src/Telegrator/Aspects/IPostProcessor.cs.cs | 2 +- src/Telegrator/Aspects/IPreProcessor.cs | 2 +- src/Telegrator/Attributes/FilterAnnotation.cs | 2 +- .../Attributes/StateKeeperAttribute.cs | 6 +- .../Attributes/UpdateFilterAttribute.cs | 4 +- .../Attributes/UpdateHandlerAttribute.cs | 4 +- .../Configuration/ITelegratorOptions.cs | 29 ------ src/Telegrator/ContinuousAction.cs | 89 +++++++++++++++++++ .../Attributes}/StateKeeperAttributeBase.cs | 8 +- .../Attributes}/UpdateFilterAttributeBase.cs | 7 +- .../Attributes}/UpdateHandlerAttributeBase.cs | 8 +- .../Descriptors/DefaultCustomDescriptors.cs | 8 +- .../Descriptors/DescribedHandlerDescriptor.cs | 7 +- .../Descriptors/DescriptorAspectsSet.cs | 4 +- .../Descriptors/DescriptorFiltersSet.cs | 10 +-- .../Descriptors/DescriptorIndexer.cs | 4 +- .../Descriptors/HandlerDescriptor.cs | 8 +- .../Descriptors/HandlerDescriptorList.cs | 7 +- .../Descriptors/HandlerInspector.cs | 6 +- .../Filters}/AnonymousCompiledFilter.cs | 5 +- .../Filters}/AnonymousTypeFilter.cs | 5 +- .../Filters}/CompiledFilter.cs | 7 +- .../Filters}/CompletedFiltersList.cs | 2 +- .../Filters}/FilterExecutionContext.cs | 3 +- .../Components => Core/Filters}/IFilter.cs | 2 +- .../Filters}/IJoinedFilter.cs | 2 +- .../Handlers}/AbstractUpdateHandler.cs | 8 +- .../Handlers}/BranchingUpdateHandler.cs | 10 +-- .../Handlers/Building}/HandlerBuilderBase.cs | 10 +-- .../Building}/IAwaiterHandlerBuilder.cs | 4 +- .../Handlers/Building}/IHandlerBuilder.cs | 6 +- .../Building}/IRegularHandlerBuilder.cs | 3 +- .../Handlers/Building}/StateKeepFilter.cs | 6 +- .../Building}/UpdateValidateFilter.cs | 4 +- .../Handlers}/EmptyHandlerContainer.cs | 5 +- .../Handlers}/HandlerLifetimeToken.cs | 2 +- .../Handlers}/IAbstractUpdateHandler.cs | 4 +- .../Handlers}/IHandlerContainer.cs | 5 +- .../Handlers}/IHandlerContainerFactory.cs | 6 +- .../Handlers}/IUpdateHandlerBase.cs | 4 +- .../Handlers}/UpdateHandlerBase.cs | 4 +- .../IAwaitingProvider.cs | 4 +- .../ICollectingProvider.cs | 2 +- .../ICustomDescriptorsProvider.cs | 4 +- .../IHandlersCollection.cs | 4 +- .../IHandlersManager.cs | 2 +- .../IHandlersProvider.cs | 6 +- .../IPollingProvider.cs | 2 +- .../IRouterExceptionHandler.cs | 2 +- .../ITelegramBotInfo.cs | 2 +- .../IUpdateHandlersPool.cs | 4 +- .../{Polling => Core}/IUpdateReceiver.cs | 2 +- .../{MadiatorCore => Core}/IUpdateRouter.cs | 4 +- .../StateKeeping}/IStateKeyResolver.cs | 2 +- .../StateKeeping}/StateKeeperBase.cs | 2 +- src/Telegrator/Exceptions.cs | 2 +- .../Filters/CallbackQueryFilters.cs | 2 +- src/Telegrator/Filters/CommandAliasFilter.cs | 2 +- .../Filters/CommandArgumentFilter.cs | 2 +- src/Telegrator/Filters/EnvironmentFilters.cs | 2 +- src/Telegrator/Filters/Filter.cs | 2 +- src/Telegrator/Filters/JoinedFilter.cs | 2 +- src/Telegrator/Filters/MentionedFilter.cs | 2 +- src/Telegrator/Filters/MessageChatFilters.cs | 2 +- src/Telegrator/Filters/MessageFilters.cs | 2 +- .../Filters/MessageRepliedFilters.cs | 2 +- .../Filters/MessageSenderFilters.cs | 2 +- src/Telegrator/Filters/MessageTextFilters.cs | 2 +- src/Telegrator/Filters/RegexFilters.cs | 2 +- src/Telegrator/Filters/StateKeyFilter.cs | 4 +- src/Telegrator/Handlers/AnyUpdateHandler.cs | 4 +- .../Handlers/Building/AwaiterHandler.cs | 4 +- .../Building/AwaiterHandlerBuilder.cs | 8 +- .../Building/BuildedAbstractHandler.cs | 2 +- .../Handlers/Building/HandlerBuilder.cs | 4 +- .../Handlers/Building/TypesExtensions.cs | 6 +- .../Handlers/CallbackQueryHandler.cs | 4 +- src/Telegrator/Handlers/CommandHandler.cs | 2 +- .../Diagnostics/FilterFallbackInfo.cs | 2 +- .../Diagnostics/FiltersFallbackReport.cs | 4 +- .../Handlers/Diagnostics/TypesExtensions.cs | 2 +- src/Telegrator/Handlers/HandlerContainer.cs | 6 +- src/Telegrator/Handlers/IHandlerContainer.cs | 2 +- src/Telegrator/Handlers/InlineQueryHandler.cs | 4 +- src/Telegrator/Handlers/MessageHandler.cs | 4 +- src/Telegrator/ITelegratorBot.cs | 2 +- .../{Alligator.cs => TelegratorLogging.cs} | 2 +- .../DefaultRouterExceptionHandler.cs | 4 +- .../DefaultUpdateReceiver.cs | 3 +- .../UpdateHandlersPool.cs | 12 +-- .../{Polling => Mediation}/UpdateRouter.cs | 41 ++++----- src/Telegrator/Providers/AwaitingProvider.cs | 4 +- .../Providers/HandlersCollection.cs | 9 +- .../Providers/HandlersManagerBase.cs | 11 ++- src/Telegrator/Providers/HandlersProvider.cs | 12 +-- src/Telegrator/Result.cs | 4 +- src/Telegrator/SimpleTypesExtensions.cs | 6 +- .../StateKeeping/ArrayStateKeeper.cs | 2 +- src/Telegrator/StateKeeping/ChatIdResolver.cs | 2 +- .../StateKeeping/EnumStateKeeper.cs | 2 +- .../StateKeeping/NumericStateKeeper.cs | 4 +- .../StateKeeping/SenderIdResolver.cs | 2 +- .../StateKeeping/StringStateKeeper.cs | 4 +- src/Telegrator/TelegramBotInfo.cs | 2 +- src/Telegrator/Telegrator.csproj | 10 +-- src/Telegrator/TelegratorClient.cs | 8 +- src/Telegrator/TelegratorOptions.cs | 10 +-- src/Telegrator/TypesExtensions.cs | 13 ++- .../Collections/CollectionTests.cs | 2 +- 144 files changed, 413 insertions(+), 368 deletions(-) rename src/Telegrator.Hosting.Web/{Components => Hosting.Web}/ITelegramBotWebHost.cs (83%) rename src/Telegrator.Hosting.Web/{ => Hosting.Web}/TelegramBotWebHost.cs (98%) rename src/Telegrator.Hosting.Web/{ => Hosting.Web}/TelegramBotWebHostBuilder.cs (96%) rename src/Telegrator.Hosting.Web/{ => Hosting.Web}/TelegramBotWebOptions.cs (100%) rename src/Telegrator.Hosting.Web/{ => Hosting.Web}/TelegratorWebOptions.cs (100%) rename src/Telegrator.Hosting.Web/{Polling => Mediation}/HostedUpdateWebhooker.cs (97%) rename src/Telegrator.Hosting/{Configuration => }/ConfigureOptionsProxy.cs (98%) rename src/Telegrator.Hosting/{Providers/Components => Core}/IHostHandlersCollection.cs (85%) rename src/Telegrator.Hosting/{Components => Handlers}/IPreBuildingRoutine.cs (90%) rename src/Telegrator.Hosting/{ => Hosting}/HostedTelegramBotInfo.cs (97%) rename src/Telegrator.Hosting/{Components => Hosting}/ITelegramBotHost.cs (83%) rename src/Telegrator.Hosting/{Components => Hosting}/ITelegramBotHostBuilder.cs (93%) rename src/Telegrator.Hosting/{ => Hosting}/TelegramBotHost.cs (98%) rename src/Telegrator.Hosting/{ => Hosting}/TelegramBotHostBuilder.cs (97%) rename src/Telegrator.Hosting/{ => Hosting}/TelegramBotHostBuilderSettings.cs (100%) rename src/Telegrator.Hosting/{Configuration => }/TelegramBotClientOptionsProxy.cs (97%) delete mode 100644 src/Telegrator/Configuration/ITelegratorOptions.cs create mode 100644 src/Telegrator/ContinuousAction.cs rename src/Telegrator/{Attributes/Components => Core/Attributes}/StateKeeperAttributeBase.cs (89%) rename src/Telegrator/{Attributes/Components => Core/Attributes}/UpdateFilterAttributeBase.cs (93%) rename src/Telegrator/{Attributes/Components => Core/Attributes}/UpdateHandlerAttributeBase.cs (96%) rename src/Telegrator/{MadiatorCore => Core}/Descriptors/DefaultCustomDescriptors.cs (94%) rename src/Telegrator/{MadiatorCore => Core}/Descriptors/DescribedHandlerDescriptor.cs (97%) rename src/Telegrator/{MadiatorCore => Core}/Descriptors/DescriptorAspectsSet.cs (97%) rename src/Telegrator/{MadiatorCore => Core}/Descriptors/DescriptorFiltersSet.cs (88%) rename src/Telegrator/{MadiatorCore => Core}/Descriptors/DescriptorIndexer.cs (97%) rename src/Telegrator/{MadiatorCore => Core}/Descriptors/HandlerDescriptor.cs (99%) rename src/Telegrator/{MadiatorCore => Core}/Descriptors/HandlerDescriptorList.cs (96%) rename src/Telegrator/{MadiatorCore => Core}/Descriptors/HandlerInspector.cs (97%) rename src/Telegrator/{Filters/Components => Core/Filters}/AnonymousCompiledFilter.cs (95%) rename src/Telegrator/{Filters/Components => Core/Filters}/AnonymousTypeFilter.cs (96%) rename src/Telegrator/{Filters/Components => Core/Filters}/CompiledFilter.cs (89%) rename src/Telegrator/{Filters/Components => Core/Filters}/CompletedFiltersList.cs (98%) rename src/Telegrator/{Filters/Components => Core/Filters}/FilterExecutionContext.cs (97%) rename src/Telegrator/{Filters/Components => Core/Filters}/IFilter.cs (96%) rename src/Telegrator/{Filters/Components => Core/Filters}/IJoinedFilter.cs (90%) rename src/Telegrator/{Handlers/Components => Core/Handlers}/AbstractUpdateHandler.cs (95%) rename src/Telegrator/{Handlers/Components => Core/Handlers}/BranchingUpdateHandler.cs (97%) rename src/Telegrator/{Handlers/Building/Components => Core/Handlers/Building}/HandlerBuilderBase.cs (97%) rename src/Telegrator/{Handlers/Building/Components => Core/Handlers/Building}/IAwaiterHandlerBuilder.cs (89%) rename src/Telegrator/{Handlers/Building/Components => Core/Handlers/Building}/IHandlerBuilder.cs (97%) rename src/Telegrator/{Handlers/Building/Components => Core/Handlers/Building}/IRegularHandlerBuilder.cs (88%) rename src/Telegrator/{Handlers/Building/Components => Core/Handlers/Building}/StateKeepFilter.cs (95%) rename src/Telegrator/{Handlers/Building/Components => Core/Handlers/Building}/UpdateValidateFilter.cs (94%) rename src/Telegrator/{Handlers/Components => Core/Handlers}/EmptyHandlerContainer.cs (88%) rename src/Telegrator/{Handlers/Components => Core/Handlers}/HandlerLifetimeToken.cs (94%) rename src/Telegrator/{Handlers/Components => Core/Handlers}/IAbstractUpdateHandler.cs (91%) rename src/Telegrator/{Handlers/Components => Core/Handlers}/IHandlerContainer.cs (91%) rename src/Telegrator/{Handlers/Components => Core/Handlers}/IHandlerContainerFactory.cs (85%) rename src/Telegrator/{Handlers/Components => Core/Handlers}/IUpdateHandlerBase.cs (95%) rename src/Telegrator/{Handlers/Components => Core/Handlers}/UpdateHandlerBase.cs (98%) rename src/Telegrator/{MadiatorCore => Core}/IAwaitingProvider.cs (88%) rename src/Telegrator/{MadiatorCore => Core}/ICollectingProvider.cs (92%) rename src/Telegrator/{Providers => Core}/ICustomDescriptorsProvider.cs (87%) rename src/Telegrator/{MadiatorCore => Core}/IHandlersCollection.cs (95%) rename src/Telegrator/{MadiatorCore => Core}/IHandlersManager.cs (89%) rename src/Telegrator/{MadiatorCore => Core}/IHandlersProvider.cs (93%) rename src/Telegrator/{MadiatorCore => Core}/IPollingProvider.cs (94%) rename src/Telegrator/{MadiatorCore => Core}/IRouterExceptionHandler.cs (96%) rename src/Telegrator/{Configuration => Core}/ITelegramBotInfo.cs (92%) rename src/Telegrator/{MadiatorCore => Core}/IUpdateHandlersPool.cs (94%) rename src/Telegrator/{Polling => Core}/IUpdateReceiver.cs (97%) rename src/Telegrator/{MadiatorCore => Core}/IUpdateRouter.cs (93%) rename src/Telegrator/{StateKeeping/Components => Core/StateKeeping}/IStateKeyResolver.cs (92%) rename src/Telegrator/{StateKeeping/Components => Core/StateKeeping}/StateKeeperBase.cs (99%) rename src/Telegrator/Logging/{Alligator.cs => TelegratorLogging.cs} (99%) rename src/Telegrator/{Polling => Mediation}/DefaultRouterExceptionHandler.cs (95%) rename src/Telegrator/{Polling => Mediation}/DefaultUpdateReceiver.cs (98%) rename src/Telegrator/{Polling => Mediation}/UpdateHandlersPool.cs (93%) rename src/Telegrator/{Polling => Mediation}/UpdateRouter.cs (89%) diff --git a/Telegrator.slnx b/Telegrator.slnx index 8c37fcd..8f71ba5 100644 --- a/Telegrator.slnx +++ b/Telegrator.slnx @@ -1,9 +1,9 @@ - - - - - - + + + + + + \ No newline at end of file diff --git a/src/Telegrator.Hosting.Web/Components/ITelegramBotWebHost.cs b/src/Telegrator.Hosting.Web/Hosting.Web/ITelegramBotWebHost.cs similarity index 83% rename from src/Telegrator.Hosting.Web/Components/ITelegramBotWebHost.cs rename to src/Telegrator.Hosting.Web/Hosting.Web/ITelegramBotWebHost.cs index aa286c6..33d2e0f 100644 --- a/src/Telegrator.Hosting.Web/Components/ITelegramBotWebHost.cs +++ b/src/Telegrator.Hosting.Web/Hosting.Web/ITelegramBotWebHost.cs @@ -1,8 +1,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Routing; -using Telegrator.Hosting.Components; -namespace Telegrator.Hosting.Web.Components +namespace Telegrator.Hosting.Web { /// /// Interface for Telegram bot hosts with Webhook update receiving. diff --git a/src/Telegrator.Hosting.Web/TelegramBotWebHost.cs b/src/Telegrator.Hosting.Web/Hosting.Web/TelegramBotWebHost.cs similarity index 98% rename from src/Telegrator.Hosting.Web/TelegramBotWebHost.cs rename to src/Telegrator.Hosting.Web/Hosting.Web/TelegramBotWebHost.cs index f1243f2..79961fe 100644 --- a/src/Telegrator.Hosting.Web/TelegramBotWebHost.cs +++ b/src/Telegrator.Hosting.Web/Hosting.Web/TelegramBotWebHost.cs @@ -5,9 +5,7 @@ using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; -using Telegrator.Hosting.Components; -using Telegrator.Hosting.Web.Components; -using Telegrator.MadiatorCore; +using Telegrator.Core; namespace Telegrator.Hosting.Web { diff --git a/src/Telegrator.Hosting.Web/TelegramBotWebHostBuilder.cs b/src/Telegrator.Hosting.Web/Hosting.Web/TelegramBotWebHostBuilder.cs similarity index 96% rename from src/Telegrator.Hosting.Web/TelegramBotWebHostBuilder.cs rename to src/Telegrator.Hosting.Web/Hosting.Web/TelegramBotWebHostBuilder.cs index 1ba59e9..557cd64 100644 --- a/src/Telegrator.Hosting.Web/TelegramBotWebHostBuilder.cs +++ b/src/Telegrator.Hosting.Web/Hosting.Web/TelegramBotWebHostBuilder.cs @@ -5,11 +5,10 @@ using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Telegram.Bot; -using Telegrator.Hosting.Components; +using Telegrator; +using Telegrator.Core; using Telegrator.Hosting.Configuration; -using Telegrator.Hosting.Providers; -using Telegrator.Hosting.Providers.Components; -using Telegrator.MadiatorCore; +using Telegrator.Providers; #pragma warning disable IDE0001 namespace Telegrator.Hosting.Web diff --git a/src/Telegrator.Hosting.Web/TelegramBotWebOptions.cs b/src/Telegrator.Hosting.Web/Hosting.Web/TelegramBotWebOptions.cs similarity index 100% rename from src/Telegrator.Hosting.Web/TelegramBotWebOptions.cs rename to src/Telegrator.Hosting.Web/Hosting.Web/TelegramBotWebOptions.cs diff --git a/src/Telegrator.Hosting.Web/TelegratorWebOptions.cs b/src/Telegrator.Hosting.Web/Hosting.Web/TelegratorWebOptions.cs similarity index 100% rename from src/Telegrator.Hosting.Web/TelegratorWebOptions.cs rename to src/Telegrator.Hosting.Web/Hosting.Web/TelegratorWebOptions.cs diff --git a/src/Telegrator.Hosting.Web/Polling/HostedUpdateWebhooker.cs b/src/Telegrator.Hosting.Web/Mediation/HostedUpdateWebhooker.cs similarity index 97% rename from src/Telegrator.Hosting.Web/Polling/HostedUpdateWebhooker.cs rename to src/Telegrator.Hosting.Web/Mediation/HostedUpdateWebhooker.cs index b66e142..ebb1a74 100644 --- a/src/Telegrator.Hosting.Web/Polling/HostedUpdateWebhooker.cs +++ b/src/Telegrator.Hosting.Web/Mediation/HostedUpdateWebhooker.cs @@ -7,9 +7,10 @@ using Microsoft.Extensions.Primitives; using System.Text.Json; using Telegram.Bot; using Telegram.Bot.Types; -using Telegrator.MadiatorCore; +using Telegrator.Core; +using Telegrator.Hosting.Web; -namespace Telegrator.Hosting.Web.Polling +namespace Telegrator.Mediation { /// /// Service for receiving updates for Hosted telegram bots via Webhooks diff --git a/src/Telegrator.Hosting.Web/Telegrator.Hosting.Web.csproj b/src/Telegrator.Hosting.Web/Telegrator.Hosting.Web.csproj index d740ee2..ad541fa 100644 --- a/src/Telegrator.Hosting.Web/Telegrator.Hosting.Web.csproj +++ b/src/Telegrator.Hosting.Web/Telegrator.Hosting.Web.csproj @@ -5,6 +5,7 @@ enable enable latest + Telegrator ..\..\bin ..\..\docs\$(AssemblyName).xml diff --git a/src/Telegrator.Hosting.Web/TypesExtensions.cs b/src/Telegrator.Hosting.Web/TypesExtensions.cs index 5b80577..eac0306 100644 --- a/src/Telegrator.Hosting.Web/TypesExtensions.cs +++ b/src/Telegrator.Hosting.Web/TypesExtensions.cs @@ -6,14 +6,13 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using System.Diagnostics; using Telegram.Bot; -using Telegrator.Configuration; -using Telegrator.Hosting.Providers; -using Telegrator.Hosting.Providers.Components; -using Telegrator.Hosting.Web.Components; -using Telegrator.Hosting.Web.Polling; -using Telegrator.MadiatorCore; +using Telegrator; +using Telegrator.Core; +using Telegrator.Hosting.Web; +using Telegrator.Mediation; +using Telegrator.Providers; -namespace Telegrator.Hosting.Web +namespace Telegrator { /// /// Contains extensions for diff --git a/src/Telegrator.Hosting/Configuration/ConfigureOptionsProxy.cs b/src/Telegrator.Hosting/ConfigureOptionsProxy.cs similarity index 98% rename from src/Telegrator.Hosting/Configuration/ConfigureOptionsProxy.cs rename to src/Telegrator.Hosting/ConfigureOptionsProxy.cs index 51022b4..9b67f50 100644 --- a/src/Telegrator.Hosting/Configuration/ConfigureOptionsProxy.cs +++ b/src/Telegrator.Hosting/ConfigureOptionsProxy.cs @@ -2,7 +2,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; -namespace Telegrator.Hosting.Configuration +namespace Telegrator { /// /// Abstract base class for configuring options from configuration sources. diff --git a/src/Telegrator.Hosting/Providers/Components/IHostHandlersCollection.cs b/src/Telegrator.Hosting/Core/IHostHandlersCollection.cs similarity index 85% rename from src/Telegrator.Hosting/Providers/Components/IHostHandlersCollection.cs rename to src/Telegrator.Hosting/Core/IHostHandlersCollection.cs index d57002e..b9ff76a 100644 --- a/src/Telegrator.Hosting/Providers/Components/IHostHandlersCollection.cs +++ b/src/Telegrator.Hosting/Core/IHostHandlersCollection.cs @@ -1,6 +1,6 @@ -using Telegrator.MadiatorCore; +using Telegrator.Providers; -namespace Telegrator.Hosting.Providers.Components +namespace Telegrator.Core { /// /// Collection class for managing handler descriptors organized by update type for host apps. diff --git a/src/Telegrator.Hosting/Components/IPreBuildingRoutine.cs b/src/Telegrator.Hosting/Handlers/IPreBuildingRoutine.cs similarity index 90% rename from src/Telegrator.Hosting/Components/IPreBuildingRoutine.cs rename to src/Telegrator.Hosting/Handlers/IPreBuildingRoutine.cs index c0c7f26..76a2585 100644 --- a/src/Telegrator.Hosting/Components/IPreBuildingRoutine.cs +++ b/src/Telegrator.Hosting/Handlers/IPreBuildingRoutine.cs @@ -1,4 +1,6 @@ -namespace Telegrator.Hosting.Components +using Telegrator.Hosting; + +namespace Telegrator.Handlers { /// /// Interface for pre-building routines that can be executed during host construction. diff --git a/src/Telegrator.Hosting/HostedTelegramBotInfo.cs b/src/Telegrator.Hosting/Hosting/HostedTelegramBotInfo.cs similarity index 97% rename from src/Telegrator.Hosting/HostedTelegramBotInfo.cs rename to src/Telegrator.Hosting/Hosting/HostedTelegramBotInfo.cs index 5c48553..4165803 100644 --- a/src/Telegrator.Hosting/HostedTelegramBotInfo.cs +++ b/src/Telegrator.Hosting/Hosting/HostedTelegramBotInfo.cs @@ -1,7 +1,7 @@ using Microsoft.Extensions.Configuration; using Telegram.Bot; using Telegram.Bot.Types; -using Telegrator.Configuration; +using Telegrator.Core; namespace Telegrator.Hosting { diff --git a/src/Telegrator.Hosting/Components/ITelegramBotHost.cs b/src/Telegrator.Hosting/Hosting/ITelegramBotHost.cs similarity index 83% rename from src/Telegrator.Hosting/Components/ITelegramBotHost.cs rename to src/Telegrator.Hosting/Hosting/ITelegramBotHost.cs index 7f0d6a3..1347fed 100644 --- a/src/Telegrator.Hosting/Components/ITelegramBotHost.cs +++ b/src/Telegrator.Hosting/Hosting/ITelegramBotHost.cs @@ -1,7 +1,6 @@ using Microsoft.Extensions.Hosting; -using Telegrator; -namespace Telegrator.Hosting.Components +namespace Telegrator.Hosting { /// /// Interface for Telegram bot hosts. diff --git a/src/Telegrator.Hosting/Components/ITelegramBotHostBuilder.cs b/src/Telegrator.Hosting/Hosting/ITelegramBotHostBuilder.cs similarity index 93% rename from src/Telegrator.Hosting/Components/ITelegramBotHostBuilder.cs rename to src/Telegrator.Hosting/Hosting/ITelegramBotHostBuilder.cs index 69b40bd..49a4247 100644 --- a/src/Telegrator.Hosting/Components/ITelegramBotHostBuilder.cs +++ b/src/Telegrator.Hosting/Hosting/ITelegramBotHostBuilder.cs @@ -1,9 +1,9 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -using Telegrator.MadiatorCore; +using Telegrator.Core; -namespace Telegrator.Hosting.Components +namespace Telegrator.Hosting { /// /// Interface for building Telegram bot hosts with dependency injection support. diff --git a/src/Telegrator.Hosting/TelegramBotHost.cs b/src/Telegrator.Hosting/Hosting/TelegramBotHost.cs similarity index 98% rename from src/Telegrator.Hosting/TelegramBotHost.cs rename to src/Telegrator.Hosting/Hosting/TelegramBotHost.cs index 0da2423..4d9863f 100644 --- a/src/Telegrator.Hosting/TelegramBotHost.cs +++ b/src/Telegrator.Hosting/Hosting/TelegramBotHost.cs @@ -1,8 +1,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; -using Telegrator.Hosting.Components; -using Telegrator.MadiatorCore; +using Telegrator.Core; namespace Telegrator.Hosting { diff --git a/src/Telegrator.Hosting/TelegramBotHostBuilder.cs b/src/Telegrator.Hosting/Hosting/TelegramBotHostBuilder.cs similarity index 97% rename from src/Telegrator.Hosting/TelegramBotHostBuilder.cs rename to src/Telegrator.Hosting/Hosting/TelegramBotHostBuilder.cs index ee767f2..541a529 100644 --- a/src/Telegrator.Hosting/TelegramBotHostBuilder.cs +++ b/src/Telegrator.Hosting/Hosting/TelegramBotHostBuilder.cs @@ -2,9 +2,8 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; -using Telegrator.Hosting.Components; +using Telegrator.Core; using Telegrator.Hosting.Providers; -using Telegrator.MadiatorCore; #pragma warning disable IDE0001 namespace Telegrator.Hosting diff --git a/src/Telegrator.Hosting/TelegramBotHostBuilderSettings.cs b/src/Telegrator.Hosting/Hosting/TelegramBotHostBuilderSettings.cs similarity index 100% rename from src/Telegrator.Hosting/TelegramBotHostBuilderSettings.cs rename to src/Telegrator.Hosting/Hosting/TelegramBotHostBuilderSettings.cs diff --git a/src/Telegrator.Hosting/Logging/MicrosoftLoggingAdapter.cs b/src/Telegrator.Hosting/Logging/MicrosoftLoggingAdapter.cs index 12e4e6e..0454595 100644 --- a/src/Telegrator.Hosting/Logging/MicrosoftLoggingAdapter.cs +++ b/src/Telegrator.Hosting/Logging/MicrosoftLoggingAdapter.cs @@ -1,7 +1,6 @@ using Microsoft.Extensions.Logging; -using Telegrator.Logging; -namespace Telegrator.Hosting.Logging +namespace Telegrator.Logging { /// /// Adapter for Microsoft.Extensions.Logging to work with Telegrator logging system. @@ -21,7 +20,7 @@ namespace Telegrator.Hosting.Logging } /// - public void Log(Telegrator.Logging.LogLevel level, string message, Exception? exception = null) + public void Log(LogLevel level, string message, Exception? exception = null) { var msLogLevel = level switch { diff --git a/src/Telegrator.Hosting/Polling/HostUpdateHandlersPool.cs b/src/Telegrator.Hosting/Polling/HostUpdateHandlersPool.cs index 14a5bcc..0601a67 100644 --- a/src/Telegrator.Hosting/Polling/HostUpdateHandlersPool.cs +++ b/src/Telegrator.Hosting/Polling/HostUpdateHandlersPool.cs @@ -1,8 +1,8 @@ using Microsoft.Extensions.Options; -using Telegrator.MadiatorCore; -using Telegrator.Polling; +using Telegrator.Core; +using Telegrator.Mediation; -namespace Telegrator.Hosting.Polling +namespace Telegrator.Polling { /// public class HostUpdateHandlersPool(IUpdateRouter router, IOptions options) diff --git a/src/Telegrator.Hosting/Polling/HostUpdateRouter.cs b/src/Telegrator.Hosting/Polling/HostUpdateRouter.cs index aa16728..ae70fa7 100644 --- a/src/Telegrator.Hosting/Polling/HostUpdateRouter.cs +++ b/src/Telegrator.Hosting/Polling/HostUpdateRouter.cs @@ -3,11 +3,10 @@ using Microsoft.Extensions.Options; using Telegram.Bot; using Telegram.Bot.Polling; using Telegram.Bot.Types; -using Telegrator.Configuration; -using Telegrator.MadiatorCore; -using Telegrator.Polling; +using Telegrator.Core; +using Telegrator.Mediation; -namespace Telegrator.Hosting.Polling +namespace Telegrator.Polling { /// public class HostUpdateRouter : UpdateRouter diff --git a/src/Telegrator.Hosting/Polling/HostedUpdateReceiver.cs b/src/Telegrator.Hosting/Polling/HostedUpdateReceiver.cs index 3a5bc52..1e79c3a 100644 --- a/src/Telegrator.Hosting/Polling/HostedUpdateReceiver.cs +++ b/src/Telegrator.Hosting/Polling/HostedUpdateReceiver.cs @@ -3,11 +3,11 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Telegram.Bot; using Telegram.Bot.Polling; -using Telegrator.Hosting.Components; -using Telegrator.MadiatorCore; -using Telegrator.Polling; +using Telegrator.Core; +using Telegrator.Hosting; +using Telegrator.Mediation; -namespace Telegrator.Hosting.Polling +namespace Telegrator.Polling { /// /// Service for receiving updates for Hosted telegram bots diff --git a/src/Telegrator.Hosting/Providers/HostAwaitingProvider.cs b/src/Telegrator.Hosting/Providers/HostAwaitingProvider.cs index e5a9475..b622819 100644 --- a/src/Telegrator.Hosting/Providers/HostAwaitingProvider.cs +++ b/src/Telegrator.Hosting/Providers/HostAwaitingProvider.cs @@ -1,8 +1,7 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -using Telegrator.Providers; -namespace Telegrator.Hosting.Providers +namespace Telegrator.Providers { /// public class HostAwaitingProvider(IOptions options, ILogger logger) : AwaitingProvider(options.Value) diff --git a/src/Telegrator.Hosting/Providers/HostHandlersCollection.cs b/src/Telegrator.Hosting/Providers/HostHandlersCollection.cs index cc76683..e8c8eb1 100644 --- a/src/Telegrator.Hosting/Providers/HostHandlersCollection.cs +++ b/src/Telegrator.Hosting/Providers/HostHandlersCollection.cs @@ -1,13 +1,11 @@ using Microsoft.Extensions.DependencyInjection; using System.Reflection; using Telegrator.Configuration; -using Telegrator.Hosting.Components; -using Telegrator.Hosting.Providers.Components; -using Telegrator.MadiatorCore; -using Telegrator.MadiatorCore.Descriptors; -using Telegrator.Providers; +using Telegrator.Core; +using Telegrator.Core.Descriptors; +using Telegrator.Hosting; -namespace Telegrator.Hosting.Providers +namespace Telegrator.Providers { /// /// Pre host building task @@ -16,7 +14,7 @@ namespace Telegrator.Hosting.Providers public delegate void PreBuildingRoutine(ITelegramBotHostBuilder builder); /// - public class HostHandlersCollection(IServiceCollection hostServiceColletion, ITelegratorOptions options) : HandlersCollection(options), IHostHandlersCollection + public class HostHandlersCollection(IServiceCollection hostServiceColletion, TelegratorOptions options) : HandlersCollection(options), IHostHandlersCollection { private readonly IServiceCollection Services = hostServiceColletion; diff --git a/src/Telegrator.Hosting/Providers/HostHandlersProvider.cs b/src/Telegrator.Hosting/Providers/HostHandlersProvider.cs index 75f7faa..65f3091 100644 --- a/src/Telegrator.Hosting/Providers/HostHandlersProvider.cs +++ b/src/Telegrator.Hosting/Providers/HostHandlersProvider.cs @@ -1,12 +1,11 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -using Telegrator.Handlers.Components; -using Telegrator.MadiatorCore; -using Telegrator.MadiatorCore.Descriptors; -using Telegrator.Providers; +using Telegrator.Core; +using Telegrator.Core.Descriptors; +using Telegrator.Core.Handlers; -namespace Telegrator.Hosting.Providers +namespace Telegrator.Providers { /// public class HostHandlersProvider : HandlersProvider diff --git a/src/Telegrator.Hosting/Configuration/TelegramBotClientOptionsProxy.cs b/src/Telegrator.Hosting/TelegramBotClientOptionsProxy.cs similarity index 97% rename from src/Telegrator.Hosting/Configuration/TelegramBotClientOptionsProxy.cs rename to src/Telegrator.Hosting/TelegramBotClientOptionsProxy.cs index e6786bc..c0e1a63 100644 --- a/src/Telegrator.Hosting/Configuration/TelegramBotClientOptionsProxy.cs +++ b/src/Telegrator.Hosting/TelegramBotClientOptionsProxy.cs @@ -1,6 +1,6 @@ using Telegram.Bot; -namespace Telegrator.Hosting.Configuration +namespace Telegrator { /// /// Internal proxy class for configuring Telegram bot client options from configuration. diff --git a/src/Telegrator.Hosting/Telegrator.Hosting.csproj b/src/Telegrator.Hosting/Telegrator.Hosting.csproj index 23bf376..016cd34 100644 --- a/src/Telegrator.Hosting/Telegrator.Hosting.csproj +++ b/src/Telegrator.Hosting/Telegrator.Hosting.csproj @@ -5,6 +5,7 @@ enable enable latest + Telegrator ..\..\bin ..\..\docs\$(AssemblyName).xml diff --git a/src/Telegrator.Hosting/TypesExtensions.cs b/src/Telegrator.Hosting/TypesExtensions.cs index 2a07986..804689d 100644 --- a/src/Telegrator.Hosting/TypesExtensions.cs +++ b/src/Telegrator.Hosting/TypesExtensions.cs @@ -12,18 +12,17 @@ using Telegram.Bot; using Telegram.Bot.Polling; using Telegram.Bot.Types; using Telegram.Bot.Types.Enums; -using Telegrator.Configuration; -using Telegrator.Hosting.Components; +using Telegrator; +using Telegrator.Core; +using Telegrator.Core.Descriptors; +using Telegrator.Handlers; +using Telegrator.Hosting; using Telegrator.Hosting.Configuration; -using Telegrator.Hosting.Logging; -using Telegrator.Hosting.Polling; -using Telegrator.Hosting.Providers; -using Telegrator.Hosting.Providers.Components; using Telegrator.Logging; -using Telegrator.MadiatorCore; -using Telegrator.MadiatorCore.Descriptors; +using Telegrator.Polling; +using Telegrator.Providers; -namespace Telegrator.Hosting +namespace Telegrator { public static class HostBuilderExtensions { @@ -196,7 +195,7 @@ namespace Telegrator.Hosting ILogger logger = loggerFactory.CreateLogger("Telegrator"); MicrosoftLoggingAdapter adapter = new MicrosoftLoggingAdapter(logger); - Alligator.AddAdapter(adapter); + TelegratorLogging.AddAdapter(adapter); return host; } } diff --git a/src/Telegrator.Localized/ILocalizedHandler.cs b/src/Telegrator.Localized/ILocalizedHandler.cs index 3b47c0f..7a2ba25 100644 --- a/src/Telegrator.Localized/ILocalizedHandler.cs +++ b/src/Telegrator.Localized/ILocalizedHandler.cs @@ -1,6 +1,6 @@ using Microsoft.Extensions.Localization; using Telegram.Bot.Types; -using Telegrator.Handlers.Components; +using Telegrator.Core.Handlers; namespace Telegrator.Localized { diff --git a/src/Telegrator/Annotations/CallbackQueryAttributes.cs b/src/Telegrator/Annotations/CallbackQueryAttributes.cs index fa14245..cc60a71 100644 --- a/src/Telegrator/Annotations/CallbackQueryAttributes.cs +++ b/src/Telegrator/Annotations/CallbackQueryAttributes.cs @@ -1,8 +1,8 @@ using Telegram.Bot.Types; using Telegram.Bot.Types.Enums; using Telegrator.Attributes; +using Telegrator.Core.Filters; using Telegrator.Filters; -using Telegrator.Filters.Components; namespace Telegrator.Annotations { diff --git a/src/Telegrator/Annotations/EnvironmentFilterAttributes.cs b/src/Telegrator/Annotations/EnvironmentFilterAttributes.cs index f583cc5..86f4475 100644 --- a/src/Telegrator/Annotations/EnvironmentFilterAttributes.cs +++ b/src/Telegrator/Annotations/EnvironmentFilterAttributes.cs @@ -2,7 +2,7 @@ using Telegram.Bot.Types.Enums; using Telegrator.Filters; using Telegrator.Attributes; -using Telegrator.Filters.Components; +using Telegrator.Core.Filters; namespace Telegrator.Annotations { diff --git a/src/Telegrator/Annotations/MessageFilterAttributes.cs b/src/Telegrator/Annotations/MessageFilterAttributes.cs index 0b812bb..d9bf293 100644 --- a/src/Telegrator/Annotations/MessageFilterAttributes.cs +++ b/src/Telegrator/Annotations/MessageFilterAttributes.cs @@ -3,7 +3,7 @@ using Telegram.Bot.Types; using Telegram.Bot.Types.Enums; using Telegrator.Filters; using Telegrator.Attributes; -using Telegrator.Filters.Components; +using Telegrator.Core.Filters; namespace Telegrator.Annotations { diff --git a/src/Telegrator/Annotations/StateKeeping/EnumStateAttribute.cs b/src/Telegrator/Annotations/StateKeeping/EnumStateAttribute.cs index 9d84e7b..e7bebed 100644 --- a/src/Telegrator/Annotations/StateKeeping/EnumStateAttribute.cs +++ b/src/Telegrator/Annotations/StateKeeping/EnumStateAttribute.cs @@ -1,6 +1,6 @@ using Telegrator.StateKeeping; using Telegrator.Attributes; -using Telegrator.StateKeeping.Components; +using Telegrator.Core.StateKeeping; namespace Telegrator.Annotations.StateKeeping { diff --git a/src/Telegrator/Annotations/StateKeeping/NumericStateAttribute.cs b/src/Telegrator/Annotations/StateKeeping/NumericStateAttribute.cs index 43efd83..6ae2049 100644 --- a/src/Telegrator/Annotations/StateKeeping/NumericStateAttribute.cs +++ b/src/Telegrator/Annotations/StateKeeping/NumericStateAttribute.cs @@ -1,6 +1,6 @@ using Telegrator.StateKeeping; using Telegrator.Attributes; -using Telegrator.StateKeeping.Components; +using Telegrator.Core.StateKeeping; namespace Telegrator.Annotations.StateKeeping { diff --git a/src/Telegrator/Annotations/StateKeeping/StringStateAttribute.cs b/src/Telegrator/Annotations/StateKeeping/StringStateAttribute.cs index e91a0ac..8d47b54 100644 --- a/src/Telegrator/Annotations/StateKeeping/StringStateAttribute.cs +++ b/src/Telegrator/Annotations/StateKeeping/StringStateAttribute.cs @@ -1,6 +1,6 @@ using Telegrator.StateKeeping; using Telegrator.Attributes; -using Telegrator.StateKeeping.Components; +using Telegrator.Core.StateKeeping; namespace Telegrator.Annotations.StateKeeping { diff --git a/src/Telegrator/Aspects/IPostProcessor.cs.cs b/src/Telegrator/Aspects/IPostProcessor.cs.cs index d478130..2e91e31 100644 --- a/src/Telegrator/Aspects/IPostProcessor.cs.cs +++ b/src/Telegrator/Aspects/IPostProcessor.cs.cs @@ -1,4 +1,4 @@ -using Telegrator.Handlers.Components; +using Telegrator.Core.Handlers; namespace Telegrator.Aspects { diff --git a/src/Telegrator/Aspects/IPreProcessor.cs b/src/Telegrator/Aspects/IPreProcessor.cs index 789d590..73ec197 100644 --- a/src/Telegrator/Aspects/IPreProcessor.cs +++ b/src/Telegrator/Aspects/IPreProcessor.cs @@ -1,4 +1,4 @@ -using Telegrator.Handlers.Components; +using Telegrator.Core.Handlers; namespace Telegrator.Aspects { diff --git a/src/Telegrator/Attributes/FilterAnnotation.cs b/src/Telegrator/Attributes/FilterAnnotation.cs index 4a87767..187ce95 100644 --- a/src/Telegrator/Attributes/FilterAnnotation.cs +++ b/src/Telegrator/Attributes/FilterAnnotation.cs @@ -1,7 +1,7 @@ using Telegram.Bot.Types; using Telegram.Bot.Types.Enums; +using Telegrator.Core.Filters; using Telegrator.Filters; -using Telegrator.Filters.Components; namespace Telegrator.Attributes { diff --git a/src/Telegrator/Attributes/StateKeeperAttribute.cs b/src/Telegrator/Attributes/StateKeeperAttribute.cs index dcf0e02..b284dd1 100644 --- a/src/Telegrator/Attributes/StateKeeperAttribute.cs +++ b/src/Telegrator/Attributes/StateKeeperAttribute.cs @@ -1,8 +1,8 @@ using Telegram.Bot.Types; using Telegrator.Annotations.StateKeeping; -using Telegrator.Attributes.Components; -using Telegrator.Filters.Components; -using Telegrator.StateKeeping.Components; +using Telegrator.Core.Attributes; +using Telegrator.Core.Filters; +using Telegrator.Core.StateKeeping; namespace Telegrator.Attributes { diff --git a/src/Telegrator/Attributes/UpdateFilterAttribute.cs b/src/Telegrator/Attributes/UpdateFilterAttribute.cs index dfda0b0..492f069 100644 --- a/src/Telegrator/Attributes/UpdateFilterAttribute.cs +++ b/src/Telegrator/Attributes/UpdateFilterAttribute.cs @@ -1,7 +1,7 @@ using Telegram.Bot.Types; -using Telegrator.Attributes.Components; +using Telegrator.Core.Attributes; +using Telegrator.Core.Filters; using Telegrator.Filters; -using Telegrator.Filters.Components; namespace Telegrator.Attributes { diff --git a/src/Telegrator/Attributes/UpdateHandlerAttribute.cs b/src/Telegrator/Attributes/UpdateHandlerAttribute.cs index 222f4f7..0a96103 100644 --- a/src/Telegrator/Attributes/UpdateHandlerAttribute.cs +++ b/src/Telegrator/Attributes/UpdateHandlerAttribute.cs @@ -1,6 +1,6 @@ using Telegram.Bot.Types.Enums; -using Telegrator.Attributes.Components; -using Telegrator.Handlers.Components; +using Telegrator.Core.Attributes; +using Telegrator.Core.Handlers; namespace Telegrator.Attributes { diff --git a/src/Telegrator/Configuration/ITelegratorOptions.cs b/src/Telegrator/Configuration/ITelegratorOptions.cs deleted file mode 100644 index fd220e8..0000000 --- a/src/Telegrator/Configuration/ITelegratorOptions.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace Telegrator.Configuration -{ - /// - /// Interface for configuring Telegram bot behavior and execution settings. - /// Controls various aspects of bot operation including concurrency, routing, collecting, and execution policies. - /// - public interface ITelegratorOptions - { - /// - /// Gets or sets the maximum number of parallel working handlers. Null means no limit. - /// - public int? MaximumParallelWorkingHandlers { get; set; } - - /// - /// Gets or sets a value indicating whether awaiting handlers should be routed separately from regular handlers. - /// - public bool ExclusiveAwaitingHandlerRouting { get; set; } - - /// - /// Gets or sets a value indicating whether to exclude intersecting command aliases. - /// - public bool ExceptIntersectingCommandAliases { get; set; } - - /// - /// Gets or sets the global cancellation token for all bot operations. - /// - public CancellationToken GlobalCancellationToken { get; set; } - } -} diff --git a/src/Telegrator/ContinuousAction.cs b/src/Telegrator/ContinuousAction.cs new file mode 100644 index 0000000..c14a195 --- /dev/null +++ b/src/Telegrator/ContinuousAction.cs @@ -0,0 +1,89 @@ +using Telegram.Bot; +using Telegram.Bot.Types; +using Telegram.Bot.Types.Enums; +using Telegrator.Logging; + +namespace Telegrator; + +public class ContinuousAction : IDisposable +{ + private readonly ITelegramBotClient _client; + private readonly ChatAction _action; + private readonly ChatId _chat; + private readonly TimeSpan _delay; + + private readonly CancellationTokenSource _linkedCts; + private readonly Task _workerTask; + + private int _disposed; + + public ContinuousAction(ITelegramBotClient client, ChatId chat, ChatAction action, TimeSpan? delay = null, CancellationToken cancellationToken = default) + { + _client = client; + _chat = chat; + _action = action; + _delay = delay ?? TimeSpan.FromSeconds(4); + + _linkedCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); + _workerTask = StartActorAsync(_linkedCts.Token); + } + + private async Task StartActorAsync(CancellationToken token) + { + try + { + while (!token.IsCancellationRequested) + { + try + { + await _client.SendChatAction(_chat, _action, cancellationToken: token).ConfigureAwait(false); + } + catch (Exception ex) when (ex is not OperationCanceledException) + { + TelegratorLogging.LogTrace("Continuous action throwed an exception.\n{0}", ex); + } + + await Task.Delay(_delay, token); + } + } + catch (OperationCanceledException) + { + TelegratorLogging.LogTrace("Continuous action cancelled"); + } + } + + public void Cancel() + { + if (Interlocked.CompareExchange(ref _disposed, 0, 0) == 0) + { + try + { + _linkedCts.Cancel(); + } + catch (ObjectDisposedException) + { + _ = 0xDEADBEEF; + } + } + } + + public async Task WaitAsync() + { + await _workerTask.ConfigureAwait(false); + } + + public void Dispose() + { + if (Interlocked.Exchange(ref _disposed, 1) == 1) + return; + + try + { + _linkedCts.Cancel(); + } + finally + { + _linkedCts.Dispose(); + } + } +} diff --git a/src/Telegrator/Attributes/Components/StateKeeperAttributeBase.cs b/src/Telegrator/Core/Attributes/StateKeeperAttributeBase.cs similarity index 89% rename from src/Telegrator/Attributes/Components/StateKeeperAttributeBase.cs rename to src/Telegrator/Core/Attributes/StateKeeperAttributeBase.cs index ba69146..c1dfac6 100644 --- a/src/Telegrator/Attributes/Components/StateKeeperAttributeBase.cs +++ b/src/Telegrator/Core/Attributes/StateKeeperAttributeBase.cs @@ -1,9 +1,9 @@ using Telegram.Bot.Types; -using Telegrator.Filters.Components; -using Telegrator.Handlers.Components; -using Telegrator.StateKeeping.Components; +using Telegrator.Core.Filters; +using Telegrator.Core.Handlers; +using Telegrator.Core.StateKeeping; -namespace Telegrator.Attributes.Components +namespace Telegrator.Core.Attributes { /// /// Sets the state in which the can be executed diff --git a/src/Telegrator/Attributes/Components/UpdateFilterAttributeBase.cs b/src/Telegrator/Core/Attributes/UpdateFilterAttributeBase.cs similarity index 93% rename from src/Telegrator/Attributes/Components/UpdateFilterAttributeBase.cs rename to src/Telegrator/Core/Attributes/UpdateFilterAttributeBase.cs index 30c74d1..2e79b38 100644 --- a/src/Telegrator/Attributes/Components/UpdateFilterAttributeBase.cs +++ b/src/Telegrator/Core/Attributes/UpdateFilterAttributeBase.cs @@ -1,10 +1,11 @@ using Telegram.Bot.Types; using Telegram.Bot.Types.Enums; +using Telegrator.Attributes; +using Telegrator.Core.Filters; +using Telegrator.Core.Handlers; using Telegrator.Filters; -using Telegrator.Filters.Components; -using Telegrator.Handlers.Components; -namespace Telegrator.Attributes.Components +namespace Telegrator.Core.Attributes { /// /// Defines the to validation for entry into execution of the diff --git a/src/Telegrator/Attributes/Components/UpdateHandlerAttributeBase.cs b/src/Telegrator/Core/Attributes/UpdateHandlerAttributeBase.cs similarity index 96% rename from src/Telegrator/Attributes/Components/UpdateHandlerAttributeBase.cs rename to src/Telegrator/Core/Attributes/UpdateHandlerAttributeBase.cs index 9f596c6..851a314 100644 --- a/src/Telegrator/Attributes/Components/UpdateHandlerAttributeBase.cs +++ b/src/Telegrator/Core/Attributes/UpdateHandlerAttributeBase.cs @@ -1,10 +1,10 @@ using Telegram.Bot.Types; using Telegram.Bot.Types.Enums; -using Telegrator.Filters.Components; -using Telegrator.Handlers.Components; -using Telegrator.MadiatorCore.Descriptors; +using Telegrator.Core.Descriptors; +using Telegrator.Core.Filters; +using Telegrator.Core.Handlers; -namespace Telegrator.Attributes.Components +namespace Telegrator.Core.Attributes { /// /// Defines the 's and validator () of the that will process diff --git a/src/Telegrator/MadiatorCore/Descriptors/DefaultCustomDescriptors.cs b/src/Telegrator/Core/Descriptors/DefaultCustomDescriptors.cs similarity index 94% rename from src/Telegrator/MadiatorCore/Descriptors/DefaultCustomDescriptors.cs rename to src/Telegrator/Core/Descriptors/DefaultCustomDescriptors.cs index c2d7896..5c244b1 100644 --- a/src/Telegrator/MadiatorCore/Descriptors/DefaultCustomDescriptors.cs +++ b/src/Telegrator/Core/Descriptors/DefaultCustomDescriptors.cs @@ -1,13 +1,13 @@ using System.Reflection; using Telegram.Bot.Types; using Telegram.Bot.Types.Enums; -using Telegrator.Attributes.Components; -using Telegrator.Filters.Components; +using Telegrator.Core.Attributes; +using Telegrator.Core.Filters; +using Telegrator.Core.Handlers; using Telegrator.Handlers; using Telegrator.Handlers.Building; -using Telegrator.Handlers.Components; -namespace Telegrator.MadiatorCore.Descriptors +namespace Telegrator.Core.Descriptors { /// /// Descriptor for creating handlers from methods diff --git a/src/Telegrator/MadiatorCore/Descriptors/DescribedHandlerDescriptor.cs b/src/Telegrator/Core/Descriptors/DescribedHandlerDescriptor.cs similarity index 97% rename from src/Telegrator/MadiatorCore/Descriptors/DescribedHandlerDescriptor.cs rename to src/Telegrator/Core/Descriptors/DescribedHandlerDescriptor.cs index d5eb717..d05660b 100644 --- a/src/Telegrator/MadiatorCore/Descriptors/DescribedHandlerDescriptor.cs +++ b/src/Telegrator/Core/Descriptors/DescribedHandlerDescriptor.cs @@ -1,9 +1,10 @@ using Telegram.Bot; using Telegram.Bot.Types; -using Telegrator.Filters.Components; -using Telegrator.Handlers.Components; +using Telegrator.Core; +using Telegrator.Core.Filters; +using Telegrator.Core.Handlers; -namespace Telegrator.MadiatorCore.Descriptors +namespace Telegrator.Core.Descriptors { /// /// Contains information about a described handler, including its context, client, and execution logic. diff --git a/src/Telegrator/MadiatorCore/Descriptors/DescriptorAspectsSet.cs b/src/Telegrator/Core/Descriptors/DescriptorAspectsSet.cs similarity index 97% rename from src/Telegrator/MadiatorCore/Descriptors/DescriptorAspectsSet.cs rename to src/Telegrator/Core/Descriptors/DescriptorAspectsSet.cs index ac2aabe..31629ff 100644 --- a/src/Telegrator/MadiatorCore/Descriptors/DescriptorAspectsSet.cs +++ b/src/Telegrator/Core/Descriptors/DescriptorAspectsSet.cs @@ -1,7 +1,7 @@ using Telegrator.Aspects; -using Telegrator.Handlers.Components; +using Telegrator.Core.Handlers; -namespace Telegrator.MadiatorCore.Descriptors +namespace Telegrator.Core.Descriptors { /// /// Manages the execution of pre and post-execution aspects for a handler. diff --git a/src/Telegrator/MadiatorCore/Descriptors/DescriptorFiltersSet.cs b/src/Telegrator/Core/Descriptors/DescriptorFiltersSet.cs similarity index 88% rename from src/Telegrator/MadiatorCore/Descriptors/DescriptorFiltersSet.cs rename to src/Telegrator/Core/Descriptors/DescriptorFiltersSet.cs index 9da76af..c08f0bb 100644 --- a/src/Telegrator/MadiatorCore/Descriptors/DescriptorFiltersSet.cs +++ b/src/Telegrator/Core/Descriptors/DescriptorFiltersSet.cs @@ -1,9 +1,9 @@ using Telegram.Bot.Types; -using Telegrator.Filters.Components; +using Telegrator.Core.Filters; using Telegrator.Handlers.Diagnostics; using Telegrator.Logging; -namespace Telegrator.MadiatorCore.Descriptors +namespace Telegrator.Core.Descriptors { /// /// Represents a set of filters for a handler descriptor, including update and state keeper validators. @@ -61,7 +61,7 @@ namespace Telegrator.MadiatorCore.Descriptors if (!result) { anyErrors = true; - Alligator.LogTrace("(E) UpdateValidator filter of '{0}' for Update ({1}) didnt pass!", filterContext.Data["handler_name"], filterContext.Update.Id); + TelegratorLogging.LogTrace("(E) UpdateValidator filter of '{0}' for Update ({1}) didnt pass!", filterContext.Data["handler_name"], filterContext.Update.Id); if (!formReport) return Result.Fault(); @@ -84,7 +84,7 @@ namespace Telegrator.MadiatorCore.Descriptors if (!result) { anyErrors = true; - Alligator.LogTrace("(E) StateKeeperValidator filter of '{0}' for Update ({1}) didnt pass!", filterContext.Data["handler_name"], filterContext.Update.Id); + TelegratorLogging.LogTrace("(E) StateKeeperValidator filter of '{0}' for Update ({1}) didnt pass!", filterContext.Data["handler_name"], filterContext.Update.Id); if (!formReport) return Result.Fault(); @@ -110,7 +110,7 @@ namespace Telegrator.MadiatorCore.Descriptors if (!result) { anyErrors = true; - Alligator.LogTrace("(E) '{0}' filter of '{1}' for Update ({2}) didnt pass!", filterName, filterContext.Data["handler_name"], filterContext.Update.Id); + TelegratorLogging.LogTrace("(E) '{0}' filter of '{1}' for Update ({2}) didnt pass!", filterName, filterContext.Data["handler_name"], filterContext.Update.Id); if (!formReport) return Result.Fault(); diff --git a/src/Telegrator/MadiatorCore/Descriptors/DescriptorIndexer.cs b/src/Telegrator/Core/Descriptors/DescriptorIndexer.cs similarity index 97% rename from src/Telegrator/MadiatorCore/Descriptors/DescriptorIndexer.cs rename to src/Telegrator/Core/Descriptors/DescriptorIndexer.cs index 23b1add..eab8e86 100644 --- a/src/Telegrator/MadiatorCore/Descriptors/DescriptorIndexer.cs +++ b/src/Telegrator/Core/Descriptors/DescriptorIndexer.cs @@ -1,6 +1,6 @@ -using Telegrator.Attributes.Components; +using Telegrator.Core.Attributes; -namespace Telegrator.MadiatorCore.Descriptors +namespace Telegrator.Core.Descriptors { /// /// Represents an indexer for handler descriptors, containing importance and priority information. diff --git a/src/Telegrator/MadiatorCore/Descriptors/HandlerDescriptor.cs b/src/Telegrator/Core/Descriptors/HandlerDescriptor.cs similarity index 99% rename from src/Telegrator/MadiatorCore/Descriptors/HandlerDescriptor.cs rename to src/Telegrator/Core/Descriptors/HandlerDescriptor.cs index c2cf494..14e870f 100644 --- a/src/Telegrator/MadiatorCore/Descriptors/HandlerDescriptor.cs +++ b/src/Telegrator/Core/Descriptors/HandlerDescriptor.cs @@ -1,10 +1,10 @@ using Telegram.Bot.Types; using Telegram.Bot.Types.Enums; -using Telegrator.Attributes.Components; -using Telegrator.Filters.Components; -using Telegrator.Handlers.Components; +using Telegrator.Core.Attributes; +using Telegrator.Core.Filters; +using Telegrator.Core.Handlers; -namespace Telegrator.MadiatorCore.Descriptors +namespace Telegrator.Core.Descriptors { /// /// Specifies the type of handler descriptor. diff --git a/src/Telegrator/MadiatorCore/Descriptors/HandlerDescriptorList.cs b/src/Telegrator/Core/Descriptors/HandlerDescriptorList.cs similarity index 96% rename from src/Telegrator/MadiatorCore/Descriptors/HandlerDescriptorList.cs rename to src/Telegrator/Core/Descriptors/HandlerDescriptorList.cs index 103965e..0975118 100644 --- a/src/Telegrator/MadiatorCore/Descriptors/HandlerDescriptorList.cs +++ b/src/Telegrator/Core/Descriptors/HandlerDescriptorList.cs @@ -2,8 +2,9 @@ using Telegram.Bot.Types; using Telegram.Bot.Types.Enums; using Telegrator.Configuration; +using Telegrator.Core; -namespace Telegrator.MadiatorCore.Descriptors +namespace Telegrator.Core.Descriptors { /// /// The collection containing the 's. Used to route 's in @@ -12,7 +13,7 @@ namespace Telegrator.MadiatorCore.Descriptors { private readonly object _lock = new object(); private readonly SortedList _innerCollection; - private readonly ITelegratorOptions? _options; + private readonly TelegratorOptions? _options; private readonly UpdateType _handlingType; private int count; @@ -54,7 +55,7 @@ namespace Telegrator.MadiatorCore.Descriptors /// /// The update type for the handlers. /// The collecting options. - public HandlerDescriptorList(UpdateType updateType, ITelegratorOptions? options) + public HandlerDescriptorList(UpdateType updateType, TelegratorOptions? options) { _innerCollection = []; _handlingType = updateType; diff --git a/src/Telegrator/MadiatorCore/Descriptors/HandlerInspector.cs b/src/Telegrator/Core/Descriptors/HandlerInspector.cs similarity index 97% rename from src/Telegrator/MadiatorCore/Descriptors/HandlerInspector.cs rename to src/Telegrator/Core/Descriptors/HandlerInspector.cs index 3829db7..155f845 100644 --- a/src/Telegrator/MadiatorCore/Descriptors/HandlerInspector.cs +++ b/src/Telegrator/Core/Descriptors/HandlerInspector.cs @@ -3,10 +3,10 @@ using System.Reflection; using Telegram.Bot.Types; using Telegram.Bot.Types.Enums; using Telegrator.Aspects; -using Telegrator.Attributes.Components; -using Telegrator.Filters.Components; +using Telegrator.Core.Attributes; +using Telegrator.Core.Filters; -namespace Telegrator.MadiatorCore.Descriptors +namespace Telegrator.Core.Descriptors { /// /// Provides methods for inspecting handler types and retrieving their attributes and filters. diff --git a/src/Telegrator/Filters/Components/AnonymousCompiledFilter.cs b/src/Telegrator/Core/Filters/AnonymousCompiledFilter.cs similarity index 95% rename from src/Telegrator/Filters/Components/AnonymousCompiledFilter.cs rename to src/Telegrator/Core/Filters/AnonymousCompiledFilter.cs index 7f4727a..5069444 100644 --- a/src/Telegrator/Filters/Components/AnonymousCompiledFilter.cs +++ b/src/Telegrator/Core/Filters/AnonymousCompiledFilter.cs @@ -1,7 +1,8 @@ using Telegram.Bot.Types; +using Telegrator.Filters; using Telegrator.Logging; -namespace Telegrator.Filters.Components +namespace Telegrator.Core.Filters { /// /// Represents a compiled filter that applies a set of filters to an anonymous target type. @@ -77,7 +78,7 @@ namespace Telegrator.Filters.Components if (!filter.CanPass(context)) { if (filter is not AnonymousCompiledFilter && filter is not AnonymousTypeFilter) - Alligator.LogDebug("{0} filter of {1} didnt pass! (Compiled anonymous)", filter.GetType().Name, context.Data["handler_name"]); + TelegratorLogging.LogDebug("{0} filter of {1} didnt pass! (Compiled anonymous)", filter.GetType().Name, context.Data["handler_name"]); return false; } diff --git a/src/Telegrator/Filters/Components/AnonymousTypeFilter.cs b/src/Telegrator/Core/Filters/AnonymousTypeFilter.cs similarity index 96% rename from src/Telegrator/Filters/Components/AnonymousTypeFilter.cs rename to src/Telegrator/Core/Filters/AnonymousTypeFilter.cs index 7b194ba..c25b562 100644 --- a/src/Telegrator/Filters/Components/AnonymousTypeFilter.cs +++ b/src/Telegrator/Core/Filters/AnonymousTypeFilter.cs @@ -1,7 +1,8 @@ using Telegram.Bot.Types; +using Telegrator.Filters; using Telegrator.Logging; -namespace Telegrator.Filters.Components +namespace Telegrator.Core.Filters { /// /// Represents a filter that applies a filter action to an anonymous target type extracted from an update. @@ -76,7 +77,7 @@ namespace Telegrator.Filters.Components if (!filter.CanPass(context)) { if (IgnoreLog.Contains(filter.GetType().MakeGenericType())) - Alligator.LogDebug("{0} filter of {1} didnt pass!", filter.GetType().Name, context.Data["handler_name"]); + TelegratorLogging.LogDebug("{0} filter of {1} didnt pass!", filter.GetType().Name, context.Data["handler_name"]); return false; } diff --git a/src/Telegrator/Filters/Components/CompiledFilter.cs b/src/Telegrator/Core/Filters/CompiledFilter.cs similarity index 89% rename from src/Telegrator/Filters/Components/CompiledFilter.cs rename to src/Telegrator/Core/Filters/CompiledFilter.cs index f95969a..198c8f0 100644 --- a/src/Telegrator/Filters/Components/CompiledFilter.cs +++ b/src/Telegrator/Core/Filters/CompiledFilter.cs @@ -1,6 +1,7 @@ -using Telegrator.Logging; +using Telegrator.Filters; +using Telegrator.Logging; -namespace Telegrator.Filters.Components +namespace Telegrator.Core.Filters { /// /// Represents a filter that composes multiple filters and passes only if all of them pass. @@ -49,7 +50,7 @@ namespace Telegrator.Filters.Components if (!filter.CanPass(context)) { if (filter is not AnonymousCompiledFilter && filter is not AnonymousTypeFilter) - Alligator.LogTrace("{0} filter of {1} didnt pass! (Compiled)", filter.GetType().Name, context.Data["handler_name"]); + TelegratorLogging.LogTrace("{0} filter of {1} didnt pass! (Compiled)", filter.GetType().Name, context.Data["handler_name"]); return false; } diff --git a/src/Telegrator/Filters/Components/CompletedFiltersList.cs b/src/Telegrator/Core/Filters/CompletedFiltersList.cs similarity index 98% rename from src/Telegrator/Filters/Components/CompletedFiltersList.cs rename to src/Telegrator/Core/Filters/CompletedFiltersList.cs index 64f904e..6a39ccb 100644 --- a/src/Telegrator/Filters/Components/CompletedFiltersList.cs +++ b/src/Telegrator/Core/Filters/CompletedFiltersList.cs @@ -1,6 +1,6 @@ using System.Collections; -namespace Telegrator.Filters.Components +namespace Telegrator.Core.Filters { /// /// The list containing filters worked out during Polling to further obtain additional filtering information diff --git a/src/Telegrator/Filters/Components/FilterExecutionContext.cs b/src/Telegrator/Core/Filters/FilterExecutionContext.cs similarity index 97% rename from src/Telegrator/Filters/Components/FilterExecutionContext.cs rename to src/Telegrator/Core/Filters/FilterExecutionContext.cs index 23c2fb7..1d12539 100644 --- a/src/Telegrator/Filters/Components/FilterExecutionContext.cs +++ b/src/Telegrator/Core/Filters/FilterExecutionContext.cs @@ -1,8 +1,7 @@ using Telegram.Bot.Types; using Telegram.Bot.Types.Enums; -using Telegrator.Configuration; -namespace Telegrator.Filters.Components +namespace Telegrator.Core.Filters { /// /// Represents the context for filter execution, including update, input, and additional data. diff --git a/src/Telegrator/Filters/Components/IFilter.cs b/src/Telegrator/Core/Filters/IFilter.cs similarity index 96% rename from src/Telegrator/Filters/Components/IFilter.cs rename to src/Telegrator/Core/Filters/IFilter.cs index 4f6f430..10c3b0f 100644 --- a/src/Telegrator/Filters/Components/IFilter.cs +++ b/src/Telegrator/Core/Filters/IFilter.cs @@ -1,4 +1,4 @@ -namespace Telegrator.Filters.Components +namespace Telegrator.Core.Filters { /// /// Interface for filters that have a name for identification and debugging purposes. diff --git a/src/Telegrator/Filters/Components/IJoinedFilter.cs b/src/Telegrator/Core/Filters/IJoinedFilter.cs similarity index 90% rename from src/Telegrator/Filters/Components/IJoinedFilter.cs rename to src/Telegrator/Core/Filters/IJoinedFilter.cs index 371d07c..341d8d3 100644 --- a/src/Telegrator/Filters/Components/IJoinedFilter.cs +++ b/src/Telegrator/Core/Filters/IJoinedFilter.cs @@ -1,4 +1,4 @@ -namespace Telegrator.Filters.Components +namespace Telegrator.Core.Filters { /// /// Represents a filter that joins multiple filters together. diff --git a/src/Telegrator/Handlers/Components/AbstractUpdateHandler.cs b/src/Telegrator/Core/Handlers/AbstractUpdateHandler.cs similarity index 95% rename from src/Telegrator/Handlers/Components/AbstractUpdateHandler.cs rename to src/Telegrator/Core/Handlers/AbstractUpdateHandler.cs index 075cdcd..85eef46 100644 --- a/src/Telegrator/Handlers/Components/AbstractUpdateHandler.cs +++ b/src/Telegrator/Core/Handlers/AbstractUpdateHandler.cs @@ -1,11 +1,11 @@ using Telegram.Bot; using Telegram.Bot.Types; using Telegram.Bot.Types.Enums; -using Telegrator.Filters.Components; -using Telegrator.MadiatorCore; -using Telegrator.MadiatorCore.Descriptors; +using Telegrator.Core.Descriptors; +using Telegrator.Core.Filters; +using Telegrator.Handlers; -namespace Telegrator.Handlers.Components +namespace Telegrator.Core.Handlers { /// /// Abstract handler for Telegram updates of type . diff --git a/src/Telegrator/Handlers/Components/BranchingUpdateHandler.cs b/src/Telegrator/Core/Handlers/BranchingUpdateHandler.cs similarity index 97% rename from src/Telegrator/Handlers/Components/BranchingUpdateHandler.cs rename to src/Telegrator/Core/Handlers/BranchingUpdateHandler.cs index 87484d2..f5448aa 100644 --- a/src/Telegrator/Handlers/Components/BranchingUpdateHandler.cs +++ b/src/Telegrator/Core/Handlers/BranchingUpdateHandler.cs @@ -1,13 +1,13 @@ using System.Reflection; using Telegram.Bot.Types; using Telegram.Bot.Types.Enums; -using Telegrator.Attributes.Components; -using Telegrator.Filters.Components; +using Telegrator.Core.Attributes; +using Telegrator.Core.Descriptors; +using Telegrator.Core.Filters; +using Telegrator.Handlers; using Telegrator.MadiatorCore; -using Telegrator.MadiatorCore.Descriptors; -using Telegrator.Providers; -namespace Telegrator.Handlers.Components +namespace Telegrator.Core.Handlers { /// /// Abstract base class for handlers that support branching execution based on different methods. diff --git a/src/Telegrator/Handlers/Building/Components/HandlerBuilderBase.cs b/src/Telegrator/Core/Handlers/Building/HandlerBuilderBase.cs similarity index 97% rename from src/Telegrator/Handlers/Building/Components/HandlerBuilderBase.cs rename to src/Telegrator/Core/Handlers/Building/HandlerBuilderBase.cs index eb2d360..561bd25 100644 --- a/src/Telegrator/Handlers/Building/Components/HandlerBuilderBase.cs +++ b/src/Telegrator/Core/Handlers/Building/HandlerBuilderBase.cs @@ -1,13 +1,11 @@ using Telegram.Bot.Types; using Telegram.Bot.Types.Enums; using Telegrator.Annotations.StateKeeping; -using Telegrator.Filters.Components; -using Telegrator.Handlers.Components; -using Telegrator.MadiatorCore; -using Telegrator.MadiatorCore.Descriptors; -using Telegrator.StateKeeping.Components; +using Telegrator.Core.Descriptors; +using Telegrator.Core.Filters; +using Telegrator.Core.StateKeeping; -namespace Telegrator.Handlers.Building.Components +namespace Telegrator.Core.Handlers.Building { /// /// Base class for building handler descriptors and managing handler filters. diff --git a/src/Telegrator/Handlers/Building/Components/IAwaiterHandlerBuilder.cs b/src/Telegrator/Core/Handlers/Building/IAwaiterHandlerBuilder.cs similarity index 89% rename from src/Telegrator/Handlers/Building/Components/IAwaiterHandlerBuilder.cs rename to src/Telegrator/Core/Handlers/Building/IAwaiterHandlerBuilder.cs index a2bba04..78819b1 100644 --- a/src/Telegrator/Handlers/Building/Components/IAwaiterHandlerBuilder.cs +++ b/src/Telegrator/Core/Handlers/Building/IAwaiterHandlerBuilder.cs @@ -1,6 +1,6 @@ -using Telegrator.StateKeeping.Components; +using Telegrator.Core.StateKeeping; -namespace Telegrator.Handlers.Building.Components +namespace Telegrator.Core.Handlers.Building { /// /// Defines a builder for awaiting handler logic for a specific update type. diff --git a/src/Telegrator/Handlers/Building/Components/IHandlerBuilder.cs b/src/Telegrator/Core/Handlers/Building/IHandlerBuilder.cs similarity index 97% rename from src/Telegrator/Handlers/Building/Components/IHandlerBuilder.cs rename to src/Telegrator/Core/Handlers/Building/IHandlerBuilder.cs index f280f4d..d2a40d3 100644 --- a/src/Telegrator/Handlers/Building/Components/IHandlerBuilder.cs +++ b/src/Telegrator/Core/Handlers/Building/IHandlerBuilder.cs @@ -1,9 +1,9 @@ using Telegram.Bot.Types; using Telegrator.Annotations.StateKeeping; -using Telegrator.Filters.Components; -using Telegrator.StateKeeping.Components; +using Telegrator.Core.Filters; +using Telegrator.Core.StateKeeping; -namespace Telegrator.Handlers.Building.Components +namespace Telegrator.Core.Handlers.Building { /// /// Defines builder actions for configuring handler builders. diff --git a/src/Telegrator/Handlers/Building/Components/IRegularHandlerBuilder.cs b/src/Telegrator/Core/Handlers/Building/IRegularHandlerBuilder.cs similarity index 88% rename from src/Telegrator/Handlers/Building/Components/IRegularHandlerBuilder.cs rename to src/Telegrator/Core/Handlers/Building/IRegularHandlerBuilder.cs index 10e7065..517d9d1 100644 --- a/src/Telegrator/Handlers/Building/Components/IRegularHandlerBuilder.cs +++ b/src/Telegrator/Core/Handlers/Building/IRegularHandlerBuilder.cs @@ -1,7 +1,6 @@ using Telegrator.Handlers.Building; -using Telegrator.MadiatorCore; -namespace Telegrator.Handlers.Building.Components +namespace Telegrator.Core.Handlers.Building { /// /// Defines a builder for regular handler logic for a specific update type. diff --git a/src/Telegrator/Handlers/Building/Components/StateKeepFilter.cs b/src/Telegrator/Core/Handlers/Building/StateKeepFilter.cs similarity index 95% rename from src/Telegrator/Handlers/Building/Components/StateKeepFilter.cs rename to src/Telegrator/Core/Handlers/Building/StateKeepFilter.cs index 41534e4..d0b0bf5 100644 --- a/src/Telegrator/Handlers/Building/Components/StateKeepFilter.cs +++ b/src/Telegrator/Core/Handlers/Building/StateKeepFilter.cs @@ -1,10 +1,10 @@ using Telegram.Bot.Types; using Telegrator.Annotations.StateKeeping; +using Telegrator.Core.Filters; +using Telegrator.Core.StateKeeping; using Telegrator.Filters; -using Telegrator.Filters.Components; -using Telegrator.StateKeeping.Components; -namespace Telegrator.Handlers.Building.Components +namespace Telegrator.Core.Handlers.Building { /// /// Filter for state keeping logic, allowing filtering based on state and special state conditions. diff --git a/src/Telegrator/Handlers/Building/Components/UpdateValidateFilter.cs b/src/Telegrator/Core/Handlers/Building/UpdateValidateFilter.cs similarity index 94% rename from src/Telegrator/Handlers/Building/Components/UpdateValidateFilter.cs rename to src/Telegrator/Core/Handlers/Building/UpdateValidateFilter.cs index c721ecb..c903d52 100644 --- a/src/Telegrator/Handlers/Building/Components/UpdateValidateFilter.cs +++ b/src/Telegrator/Core/Handlers/Building/UpdateValidateFilter.cs @@ -1,7 +1,7 @@ using Telegram.Bot.Types; -using Telegrator.Filters.Components; +using Telegrator.Core.Filters; -namespace Telegrator.Handlers.Building.Components +namespace Telegrator.Core.Handlers.Building { /// /// Delegate for validating an update in a filter context. diff --git a/src/Telegrator/Handlers/Components/EmptyHandlerContainer.cs b/src/Telegrator/Core/Handlers/EmptyHandlerContainer.cs similarity index 88% rename from src/Telegrator/Handlers/Components/EmptyHandlerContainer.cs rename to src/Telegrator/Core/Handlers/EmptyHandlerContainer.cs index 61e8874..4004140 100644 --- a/src/Telegrator/Handlers/Components/EmptyHandlerContainer.cs +++ b/src/Telegrator/Core/Handlers/EmptyHandlerContainer.cs @@ -1,9 +1,8 @@ using Telegram.Bot; using Telegram.Bot.Types; -using Telegrator.Filters.Components; -using Telegrator.MadiatorCore; +using Telegrator.Core.Filters; -namespace Telegrator.Handlers.Components +namespace Telegrator.Core.Handlers { /// /// Represents an empty handler container that throws for all members. diff --git a/src/Telegrator/Handlers/Components/HandlerLifetimeToken.cs b/src/Telegrator/Core/Handlers/HandlerLifetimeToken.cs similarity index 94% rename from src/Telegrator/Handlers/Components/HandlerLifetimeToken.cs rename to src/Telegrator/Core/Handlers/HandlerLifetimeToken.cs index 8c9777e..27af6ab 100644 --- a/src/Telegrator/Handlers/Components/HandlerLifetimeToken.cs +++ b/src/Telegrator/Core/Handlers/HandlerLifetimeToken.cs @@ -1,4 +1,4 @@ -namespace Telegrator.Handlers.Components +namespace Telegrator.Core.Handlers { /// /// Represents a token that tracks the lifetime of a handler instance. diff --git a/src/Telegrator/Handlers/Components/IAbstractUpdateHandler.cs b/src/Telegrator/Core/Handlers/IAbstractUpdateHandler.cs similarity index 91% rename from src/Telegrator/Handlers/Components/IAbstractUpdateHandler.cs rename to src/Telegrator/Core/Handlers/IAbstractUpdateHandler.cs index 9c0d3e8..69db19e 100644 --- a/src/Telegrator/Handlers/Components/IAbstractUpdateHandler.cs +++ b/src/Telegrator/Core/Handlers/IAbstractUpdateHandler.cs @@ -1,4 +1,6 @@ -namespace Telegrator.Handlers.Components; +using Telegrator.Handlers; + +namespace Telegrator.Core.Handlers; /// /// Abstract handler for Telegram updates of type . diff --git a/src/Telegrator/Handlers/Components/IHandlerContainer.cs b/src/Telegrator/Core/Handlers/IHandlerContainer.cs similarity index 91% rename from src/Telegrator/Handlers/Components/IHandlerContainer.cs rename to src/Telegrator/Core/Handlers/IHandlerContainer.cs index 9948b34..2a47e48 100644 --- a/src/Telegrator/Handlers/Components/IHandlerContainer.cs +++ b/src/Telegrator/Core/Handlers/IHandlerContainer.cs @@ -1,9 +1,8 @@ using Telegram.Bot; using Telegram.Bot.Types; -using Telegrator.Filters.Components; -using Telegrator.MadiatorCore; +using Telegrator.Core.Filters; -namespace Telegrator.Handlers.Components +namespace Telegrator.Core.Handlers { /// /// Interface for handler containers that provide context and resources for update handlers. diff --git a/src/Telegrator/Handlers/Components/IHandlerContainerFactory.cs b/src/Telegrator/Core/Handlers/IHandlerContainerFactory.cs similarity index 85% rename from src/Telegrator/Handlers/Components/IHandlerContainerFactory.cs rename to src/Telegrator/Core/Handlers/IHandlerContainerFactory.cs index c6f91b1..908beaf 100644 --- a/src/Telegrator/Handlers/Components/IHandlerContainerFactory.cs +++ b/src/Telegrator/Core/Handlers/IHandlerContainerFactory.cs @@ -1,7 +1,7 @@ -using Telegrator.MadiatorCore; -using Telegrator.MadiatorCore.Descriptors; +using Telegrator.Core.Descriptors; +using Telegrator.MadiatorCore; -namespace Telegrator.Handlers.Components +namespace Telegrator.Core.Handlers { /// /// Factory interface for creating handler containers. diff --git a/src/Telegrator/Handlers/Components/IUpdateHandlerBase.cs b/src/Telegrator/Core/Handlers/IUpdateHandlerBase.cs similarity index 95% rename from src/Telegrator/Handlers/Components/IUpdateHandlerBase.cs rename to src/Telegrator/Core/Handlers/IUpdateHandlerBase.cs index 77f0c73..224606a 100644 --- a/src/Telegrator/Handlers/Components/IUpdateHandlerBase.cs +++ b/src/Telegrator/Core/Handlers/IUpdateHandlerBase.cs @@ -1,9 +1,9 @@ using Telegram.Bot; using Telegram.Bot.Types.Enums; +using Telegrator.Core.Descriptors; using Telegrator.Handlers.Diagnostics; -using Telegrator.MadiatorCore.Descriptors; -namespace Telegrator.Handlers.Components; +namespace Telegrator.Core.Handlers; /// /// Abstraction for update handlers, providing execution and lifetime management for Telegram updates. diff --git a/src/Telegrator/Handlers/Components/UpdateHandlerBase.cs b/src/Telegrator/Core/Handlers/UpdateHandlerBase.cs similarity index 98% rename from src/Telegrator/Handlers/Components/UpdateHandlerBase.cs rename to src/Telegrator/Core/Handlers/UpdateHandlerBase.cs index e672577..2ac2f78 100644 --- a/src/Telegrator/Handlers/Components/UpdateHandlerBase.cs +++ b/src/Telegrator/Core/Handlers/UpdateHandlerBase.cs @@ -1,10 +1,10 @@ using Telegram.Bot; using Telegram.Bot.Polling; using Telegram.Bot.Types.Enums; +using Telegrator.Core.Descriptors; using Telegrator.Handlers.Diagnostics; -using Telegrator.MadiatorCore.Descriptors; -namespace Telegrator.Handlers.Components +namespace Telegrator.Core.Handlers { /// /// Base class for update handlers, providing execution and lifetime management for Telegram updates. diff --git a/src/Telegrator/MadiatorCore/IAwaitingProvider.cs b/src/Telegrator/Core/IAwaitingProvider.cs similarity index 88% rename from src/Telegrator/MadiatorCore/IAwaitingProvider.cs rename to src/Telegrator/Core/IAwaitingProvider.cs index 8890f14..ef4cfe9 100644 --- a/src/Telegrator/MadiatorCore/IAwaitingProvider.cs +++ b/src/Telegrator/Core/IAwaitingProvider.cs @@ -1,6 +1,6 @@ -using Telegrator.MadiatorCore.Descriptors; +using Telegrator.Core.Descriptors; -namespace Telegrator.MadiatorCore +namespace Telegrator.Core { /// /// Provider for managing awaiting handlers that can wait for specific update types. diff --git a/src/Telegrator/MadiatorCore/ICollectingProvider.cs b/src/Telegrator/Core/ICollectingProvider.cs similarity index 92% rename from src/Telegrator/MadiatorCore/ICollectingProvider.cs rename to src/Telegrator/Core/ICollectingProvider.cs index af96c7c..9f58160 100644 --- a/src/Telegrator/MadiatorCore/ICollectingProvider.cs +++ b/src/Telegrator/Core/ICollectingProvider.cs @@ -1,4 +1,4 @@ -namespace Telegrator.MadiatorCore +namespace Telegrator.Core { /// /// Interface for providers that collect and manage handler collections. diff --git a/src/Telegrator/Providers/ICustomDescriptorsProvider.cs b/src/Telegrator/Core/ICustomDescriptorsProvider.cs similarity index 87% rename from src/Telegrator/Providers/ICustomDescriptorsProvider.cs rename to src/Telegrator/Core/ICustomDescriptorsProvider.cs index 9e3e4bd..22d9461 100644 --- a/src/Telegrator/Providers/ICustomDescriptorsProvider.cs +++ b/src/Telegrator/Core/ICustomDescriptorsProvider.cs @@ -1,6 +1,6 @@ -using Telegrator.MadiatorCore.Descriptors; +using Telegrator.Core.Descriptors; -namespace Telegrator.Providers +namespace Telegrator.Core { /// /// Interface for classes that can provide custom handler descriptors. diff --git a/src/Telegrator/MadiatorCore/IHandlersCollection.cs b/src/Telegrator/Core/IHandlersCollection.cs similarity index 95% rename from src/Telegrator/MadiatorCore/IHandlersCollection.cs rename to src/Telegrator/Core/IHandlersCollection.cs index 5352c2c..8b8efea 100644 --- a/src/Telegrator/MadiatorCore/IHandlersCollection.cs +++ b/src/Telegrator/Core/IHandlersCollection.cs @@ -1,7 +1,7 @@ using Telegram.Bot.Types.Enums; -using Telegrator.MadiatorCore.Descriptors; +using Telegrator.Core.Descriptors; -namespace Telegrator.MadiatorCore +namespace Telegrator.Core { /// /// Collection class for managing handler descriptors organized by update type. diff --git a/src/Telegrator/MadiatorCore/IHandlersManager.cs b/src/Telegrator/Core/IHandlersManager.cs similarity index 89% rename from src/Telegrator/MadiatorCore/IHandlersManager.cs rename to src/Telegrator/Core/IHandlersManager.cs index b026053..036af35 100644 --- a/src/Telegrator/MadiatorCore/IHandlersManager.cs +++ b/src/Telegrator/Core/IHandlersManager.cs @@ -1,4 +1,4 @@ -namespace Telegrator.MadiatorCore +namespace Telegrator.Core { /// /// Combines and . diff --git a/src/Telegrator/MadiatorCore/IHandlersProvider.cs b/src/Telegrator/Core/IHandlersProvider.cs similarity index 93% rename from src/Telegrator/MadiatorCore/IHandlersProvider.cs rename to src/Telegrator/Core/IHandlersProvider.cs index 3fc5675..d51bd2b 100644 --- a/src/Telegrator/MadiatorCore/IHandlersProvider.cs +++ b/src/Telegrator/Core/IHandlersProvider.cs @@ -1,8 +1,8 @@ using Telegram.Bot.Types.Enums; -using Telegrator.Handlers.Components; -using Telegrator.MadiatorCore.Descriptors; +using Telegrator.Core.Descriptors; +using Telegrator.Core.Handlers; -namespace Telegrator.MadiatorCore +namespace Telegrator.Core { /// /// Provides methods to retrieve and describe handler information for updates. diff --git a/src/Telegrator/MadiatorCore/IPollingProvider.cs b/src/Telegrator/Core/IPollingProvider.cs similarity index 94% rename from src/Telegrator/MadiatorCore/IPollingProvider.cs rename to src/Telegrator/Core/IPollingProvider.cs index a96f954..75ddcc7 100644 --- a/src/Telegrator/MadiatorCore/IPollingProvider.cs +++ b/src/Telegrator/Core/IPollingProvider.cs @@ -1,4 +1,4 @@ -namespace Telegrator.MadiatorCore +namespace Telegrator.Core { /// /// Interface for polling providers that manage both regular and awaiting handlers. diff --git a/src/Telegrator/MadiatorCore/IRouterExceptionHandler.cs b/src/Telegrator/Core/IRouterExceptionHandler.cs similarity index 96% rename from src/Telegrator/MadiatorCore/IRouterExceptionHandler.cs rename to src/Telegrator/Core/IRouterExceptionHandler.cs index f421523..2277919 100644 --- a/src/Telegrator/MadiatorCore/IRouterExceptionHandler.cs +++ b/src/Telegrator/Core/IRouterExceptionHandler.cs @@ -1,7 +1,7 @@ using Telegram.Bot; using Telegram.Bot.Polling; -namespace Telegrator.MadiatorCore +namespace Telegrator.Core { /// /// Interface for handling exceptions that occur during update routing operations. diff --git a/src/Telegrator/Configuration/ITelegramBotInfo.cs b/src/Telegrator/Core/ITelegramBotInfo.cs similarity index 92% rename from src/Telegrator/Configuration/ITelegramBotInfo.cs rename to src/Telegrator/Core/ITelegramBotInfo.cs index 9c1aa2c..72f2d06 100644 --- a/src/Telegrator/Configuration/ITelegramBotInfo.cs +++ b/src/Telegrator/Core/ITelegramBotInfo.cs @@ -1,6 +1,6 @@ using Telegram.Bot.Types; -namespace Telegrator.Configuration +namespace Telegrator.Core { /// /// Interface for providing bot information and metadata. diff --git a/src/Telegrator/MadiatorCore/IUpdateHandlersPool.cs b/src/Telegrator/Core/IUpdateHandlersPool.cs similarity index 94% rename from src/Telegrator/MadiatorCore/IUpdateHandlersPool.cs rename to src/Telegrator/Core/IUpdateHandlersPool.cs index e5d4d2e..c19f229 100644 --- a/src/Telegrator/MadiatorCore/IUpdateHandlersPool.cs +++ b/src/Telegrator/Core/IUpdateHandlersPool.cs @@ -1,6 +1,6 @@ -using Telegrator.MadiatorCore.Descriptors; +using Telegrator.Core.Descriptors; -namespace Telegrator.MadiatorCore +namespace Telegrator.Core { /// /// Represents a delegate for when a handler is enqueued. diff --git a/src/Telegrator/Polling/IUpdateReceiver.cs b/src/Telegrator/Core/IUpdateReceiver.cs similarity index 97% rename from src/Telegrator/Polling/IUpdateReceiver.cs rename to src/Telegrator/Core/IUpdateReceiver.cs index b81f73d..2a3a2d0 100644 --- a/src/Telegrator/Polling/IUpdateReceiver.cs +++ b/src/Telegrator/Core/IUpdateReceiver.cs @@ -1,7 +1,7 @@ using Telegram.Bot.Polling; using Telegram.Bot.Types; -namespace Telegrator.Polling; +namespace Telegrator.Core; /// /// Requests new s and processes them using provided instance< diff --git a/src/Telegrator/MadiatorCore/IUpdateRouter.cs b/src/Telegrator/Core/IUpdateRouter.cs similarity index 93% rename from src/Telegrator/MadiatorCore/IUpdateRouter.cs rename to src/Telegrator/Core/IUpdateRouter.cs index 53fbe87..82252b0 100644 --- a/src/Telegrator/MadiatorCore/IUpdateRouter.cs +++ b/src/Telegrator/Core/IUpdateRouter.cs @@ -1,7 +1,7 @@ using Telegram.Bot.Polling; -using Telegrator.Handlers.Components; +using Telegrator.Core.Handlers; -namespace Telegrator.MadiatorCore +namespace Telegrator.Core { /// /// Interface for update routers that handle incoming updates and manage handler execution. diff --git a/src/Telegrator/StateKeeping/Components/IStateKeyResolver.cs b/src/Telegrator/Core/StateKeeping/IStateKeyResolver.cs similarity index 92% rename from src/Telegrator/StateKeeping/Components/IStateKeyResolver.cs rename to src/Telegrator/Core/StateKeeping/IStateKeyResolver.cs index e78395c..f8d3404 100644 --- a/src/Telegrator/StateKeeping/Components/IStateKeyResolver.cs +++ b/src/Telegrator/Core/StateKeeping/IStateKeyResolver.cs @@ -1,6 +1,6 @@ using Telegram.Bot.Types; -namespace Telegrator.StateKeeping.Components +namespace Telegrator.Core.StateKeeping { /// /// Defines a resolver for extracting a key from an update for state keeping purposes. diff --git a/src/Telegrator/StateKeeping/Components/StateKeeperBase.cs b/src/Telegrator/Core/StateKeeping/StateKeeperBase.cs similarity index 99% rename from src/Telegrator/StateKeeping/Components/StateKeeperBase.cs rename to src/Telegrator/Core/StateKeeping/StateKeeperBase.cs index e2e0193..98c51d3 100644 --- a/src/Telegrator/StateKeeping/Components/StateKeeperBase.cs +++ b/src/Telegrator/Core/StateKeeping/StateKeeperBase.cs @@ -1,6 +1,6 @@ using Telegram.Bot.Types; -namespace Telegrator.StateKeeping.Components +namespace Telegrator.Core.StateKeeping { /// /// Base class for managing state associated with updates and keys. diff --git a/src/Telegrator/Exceptions.cs b/src/Telegrator/Exceptions.cs index 6bc5ec4..1b0f270 100644 --- a/src/Telegrator/Exceptions.cs +++ b/src/Telegrator/Exceptions.cs @@ -1,4 +1,4 @@ -using Telegrator.MadiatorCore.Descriptors; +using Telegrator.Core.Descriptors; namespace Telegrator { diff --git a/src/Telegrator/Filters/CallbackQueryFilters.cs b/src/Telegrator/Filters/CallbackQueryFilters.cs index 9b22a74..e92eead 100644 --- a/src/Telegrator/Filters/CallbackQueryFilters.cs +++ b/src/Telegrator/Filters/CallbackQueryFilters.cs @@ -1,6 +1,6 @@ using System.Text.RegularExpressions; using Telegram.Bot.Types; -using Telegrator.Filters.Components; +using Telegrator.Core.Filters; namespace Telegrator.Filters { diff --git a/src/Telegrator/Filters/CommandAliasFilter.cs b/src/Telegrator/Filters/CommandAliasFilter.cs index a84c50f..7ae0af3 100644 --- a/src/Telegrator/Filters/CommandAliasFilter.cs +++ b/src/Telegrator/Filters/CommandAliasFilter.cs @@ -1,5 +1,5 @@ using Telegram.Bot.Types; -using Telegrator.Filters.Components; +using Telegrator.Core.Filters; using Telegrator.Handlers; namespace Telegrator.Filters diff --git a/src/Telegrator/Filters/CommandArgumentFilter.cs b/src/Telegrator/Filters/CommandArgumentFilter.cs index 10bbe03..762af62 100644 --- a/src/Telegrator/Filters/CommandArgumentFilter.cs +++ b/src/Telegrator/Filters/CommandArgumentFilter.cs @@ -1,6 +1,6 @@ using System.Text.RegularExpressions; using Telegram.Bot.Types; -using Telegrator.Filters.Components; +using Telegrator.Core.Filters; using Telegrator.Handlers; namespace Telegrator.Filters diff --git a/src/Telegrator/Filters/EnvironmentFilters.cs b/src/Telegrator/Filters/EnvironmentFilters.cs index d4c4439..e07c445 100644 --- a/src/Telegrator/Filters/EnvironmentFilters.cs +++ b/src/Telegrator/Filters/EnvironmentFilters.cs @@ -1,6 +1,6 @@ using System.Diagnostics; using Telegram.Bot.Types; -using Telegrator.Filters.Components; +using Telegrator.Core.Filters; namespace Telegrator.Filters { diff --git a/src/Telegrator/Filters/Filter.cs b/src/Telegrator/Filters/Filter.cs index 56a6cbf..e9f9845 100644 --- a/src/Telegrator/Filters/Filter.cs +++ b/src/Telegrator/Filters/Filter.cs @@ -1,4 +1,4 @@ -using Telegrator.Filters.Components; +using Telegrator.Core.Filters; namespace Telegrator.Filters { diff --git a/src/Telegrator/Filters/JoinedFilter.cs b/src/Telegrator/Filters/JoinedFilter.cs index b0bdba0..0602def 100644 --- a/src/Telegrator/Filters/JoinedFilter.cs +++ b/src/Telegrator/Filters/JoinedFilter.cs @@ -1,4 +1,4 @@ -using Telegrator.Filters.Components; +using Telegrator.Core.Filters; namespace Telegrator.Filters { diff --git a/src/Telegrator/Filters/MentionedFilter.cs b/src/Telegrator/Filters/MentionedFilter.cs index bd761ce..2cf6425 100644 --- a/src/Telegrator/Filters/MentionedFilter.cs +++ b/src/Telegrator/Filters/MentionedFilter.cs @@ -1,6 +1,6 @@ using Telegram.Bot.Types; using Telegram.Bot.Types.Enums; -using Telegrator.Filters.Components; +using Telegrator.Core.Filters; namespace Telegrator.Filters { diff --git a/src/Telegrator/Filters/MessageChatFilters.cs b/src/Telegrator/Filters/MessageChatFilters.cs index 6d0407b..9bb8d81 100644 --- a/src/Telegrator/Filters/MessageChatFilters.cs +++ b/src/Telegrator/Filters/MessageChatFilters.cs @@ -1,7 +1,7 @@ using Telegram.Bot.Types; using Telegram.Bot.Types.Enums; using Telegram.Bot.Types.ReplyMarkups; -using Telegrator.Filters.Components; +using Telegrator.Core.Filters; namespace Telegrator.Filters { diff --git a/src/Telegrator/Filters/MessageFilters.cs b/src/Telegrator/Filters/MessageFilters.cs index 5fcffd7..3cb06c8 100644 --- a/src/Telegrator/Filters/MessageFilters.cs +++ b/src/Telegrator/Filters/MessageFilters.cs @@ -1,7 +1,7 @@ using System.Text.RegularExpressions; using Telegram.Bot.Types; using Telegram.Bot.Types.Enums; -using Telegrator.Filters.Components; +using Telegrator.Core.Filters; namespace Telegrator.Filters { diff --git a/src/Telegrator/Filters/MessageRepliedFilters.cs b/src/Telegrator/Filters/MessageRepliedFilters.cs index a1752a0..b24b6bb 100644 --- a/src/Telegrator/Filters/MessageRepliedFilters.cs +++ b/src/Telegrator/Filters/MessageRepliedFilters.cs @@ -1,5 +1,5 @@ using Telegram.Bot.Types; -using Telegrator.Filters.Components; +using Telegrator.Core.Filters; namespace Telegrator.Filters { diff --git a/src/Telegrator/Filters/MessageSenderFilters.cs b/src/Telegrator/Filters/MessageSenderFilters.cs index 9769154..1380fed 100644 --- a/src/Telegrator/Filters/MessageSenderFilters.cs +++ b/src/Telegrator/Filters/MessageSenderFilters.cs @@ -1,5 +1,5 @@ using Telegram.Bot.Types; -using Telegrator.Filters.Components; +using Telegrator.Core.Filters; namespace Telegrator.Filters { diff --git a/src/Telegrator/Filters/MessageTextFilters.cs b/src/Telegrator/Filters/MessageTextFilters.cs index 7241136..10c90da 100644 --- a/src/Telegrator/Filters/MessageTextFilters.cs +++ b/src/Telegrator/Filters/MessageTextFilters.cs @@ -1,5 +1,5 @@ using Telegram.Bot.Types; -using Telegrator.Filters.Components; +using Telegrator.Core.Filters; using static System.Net.Mime.MediaTypeNames; namespace Telegrator.Filters diff --git a/src/Telegrator/Filters/RegexFilters.cs b/src/Telegrator/Filters/RegexFilters.cs index 343c824..04aa083 100644 --- a/src/Telegrator/Filters/RegexFilters.cs +++ b/src/Telegrator/Filters/RegexFilters.cs @@ -1,5 +1,5 @@ using System.Text.RegularExpressions; -using Telegrator.Filters.Components; +using Telegrator.Core.Filters; namespace Telegrator.Filters { diff --git a/src/Telegrator/Filters/StateKeyFilter.cs b/src/Telegrator/Filters/StateKeyFilter.cs index 3b64322..8e9fc4a 100644 --- a/src/Telegrator/Filters/StateKeyFilter.cs +++ b/src/Telegrator/Filters/StateKeyFilter.cs @@ -1,6 +1,6 @@ using Telegram.Bot.Types; -using Telegrator.Filters.Components; -using Telegrator.StateKeeping.Components; +using Telegrator.Core.Filters; +using Telegrator.Core.StateKeeping; namespace Telegrator.Filters { diff --git a/src/Telegrator/Handlers/AnyUpdateHandler.cs b/src/Telegrator/Handlers/AnyUpdateHandler.cs index 199e6bc..1c39182 100644 --- a/src/Telegrator/Handlers/AnyUpdateHandler.cs +++ b/src/Telegrator/Handlers/AnyUpdateHandler.cs @@ -1,8 +1,8 @@ using Telegram.Bot.Types; using Telegram.Bot.Types.Enums; using Telegrator.Attributes; -using Telegrator.Filters.Components; -using Telegrator.Handlers.Components; +using Telegrator.Core.Filters; +using Telegrator.Core.Handlers; namespace Telegrator.Handlers { diff --git a/src/Telegrator/Handlers/Building/AwaiterHandler.cs b/src/Telegrator/Handlers/Building/AwaiterHandler.cs index ef21c80..9a562eb 100644 --- a/src/Telegrator/Handlers/Building/AwaiterHandler.cs +++ b/src/Telegrator/Handlers/Building/AwaiterHandler.cs @@ -1,7 +1,7 @@ using Telegram.Bot.Types; using Telegram.Bot.Types.Enums; -using Telegrator.Handlers.Components; -using Telegrator.MadiatorCore.Descriptors; +using Telegrator.Core.Descriptors; +using Telegrator.Core.Handlers; namespace Telegrator.Handlers.Building { diff --git a/src/Telegrator/Handlers/Building/AwaiterHandlerBuilder.cs b/src/Telegrator/Handlers/Building/AwaiterHandlerBuilder.cs index 7789fe8..c21b94f 100644 --- a/src/Telegrator/Handlers/Building/AwaiterHandlerBuilder.cs +++ b/src/Telegrator/Handlers/Building/AwaiterHandlerBuilder.cs @@ -2,10 +2,10 @@ using Telegram.Bot.Types.Enums; using Telegrator.Filters; using Telegrator.StateKeeping; -using Telegrator.Handlers.Building.Components; -using Telegrator.MadiatorCore; -using Telegrator.MadiatorCore.Descriptors; -using Telegrator.StateKeeping.Components; +using Telegrator.Core; +using Telegrator.Core.Handlers.Building; +using Telegrator.Core.Descriptors; +using Telegrator.Core.StateKeeping; namespace Telegrator.Handlers.Building { diff --git a/src/Telegrator/Handlers/Building/BuildedAbstractHandler.cs b/src/Telegrator/Handlers/Building/BuildedAbstractHandler.cs index 2db7f32..d700f66 100644 --- a/src/Telegrator/Handlers/Building/BuildedAbstractHandler.cs +++ b/src/Telegrator/Handlers/Building/BuildedAbstractHandler.cs @@ -1,5 +1,5 @@ using Telegram.Bot.Types.Enums; -using Telegrator.Handlers.Components; +using Telegrator.Core.Handlers; namespace Telegrator.Handlers.Building { diff --git a/src/Telegrator/Handlers/Building/HandlerBuilder.cs b/src/Telegrator/Handlers/Building/HandlerBuilder.cs index fd9c129..24d6ad9 100644 --- a/src/Telegrator/Handlers/Building/HandlerBuilder.cs +++ b/src/Telegrator/Handlers/Building/HandlerBuilder.cs @@ -1,6 +1,6 @@ using Telegram.Bot.Types.Enums; -using Telegrator.Handlers.Building.Components; -using Telegrator.MadiatorCore; +using Telegrator.Core; +using Telegrator.Core.Handlers.Building; namespace Telegrator.Handlers.Building { diff --git a/src/Telegrator/Handlers/Building/TypesExtensions.cs b/src/Telegrator/Handlers/Building/TypesExtensions.cs index 4963eb6..74573d1 100644 --- a/src/Telegrator/Handlers/Building/TypesExtensions.cs +++ b/src/Telegrator/Handlers/Building/TypesExtensions.cs @@ -1,9 +1,9 @@ using Telegram.Bot.Types; using Telegrator.Annotations.StateKeeping; -using Telegrator.Filters.Components; -using Telegrator.Handlers.Building.Components; +using Telegrator.Core.Filters; +using Telegrator.Core.Handlers.Building; +using Telegrator.Core.StateKeeping; using Telegrator.StateKeeping; -using Telegrator.StateKeeping.Components; namespace Telegrator.Handlers.Building { diff --git a/src/Telegrator/Handlers/CallbackQueryHandler.cs b/src/Telegrator/Handlers/CallbackQueryHandler.cs index 22f2310..e129bf7 100644 --- a/src/Telegrator/Handlers/CallbackQueryHandler.cs +++ b/src/Telegrator/Handlers/CallbackQueryHandler.cs @@ -2,8 +2,8 @@ using Telegram.Bot.Types.Enums; using Telegram.Bot.Types.ReplyMarkups; using Telegrator.Attributes; -using Telegrator.Filters.Components; -using Telegrator.Handlers.Components; +using Telegrator.Core.Filters; +using Telegrator.Core.Handlers; namespace Telegrator.Handlers { diff --git a/src/Telegrator/Handlers/CommandHandler.cs b/src/Telegrator/Handlers/CommandHandler.cs index 4d130b0..d9d1708 100644 --- a/src/Telegrator/Handlers/CommandHandler.cs +++ b/src/Telegrator/Handlers/CommandHandler.cs @@ -1,7 +1,7 @@ using Telegram.Bot.Types; using Telegram.Bot.Types.Enums; using Telegrator.Attributes; -using Telegrator.Filters.Components; +using Telegrator.Core.Filters; namespace Telegrator.Handlers { diff --git a/src/Telegrator/Handlers/Diagnostics/FilterFallbackInfo.cs b/src/Telegrator/Handlers/Diagnostics/FilterFallbackInfo.cs index 73b874d..976efa6 100644 --- a/src/Telegrator/Handlers/Diagnostics/FilterFallbackInfo.cs +++ b/src/Telegrator/Handlers/Diagnostics/FilterFallbackInfo.cs @@ -1,5 +1,5 @@ using Telegram.Bot.Types; -using Telegrator.Filters.Components; +using Telegrator.Core.Filters; namespace Telegrator.Handlers.Diagnostics { diff --git a/src/Telegrator/Handlers/Diagnostics/FiltersFallbackReport.cs b/src/Telegrator/Handlers/Diagnostics/FiltersFallbackReport.cs index 8a4e3c1..87a8a35 100644 --- a/src/Telegrator/Handlers/Diagnostics/FiltersFallbackReport.cs +++ b/src/Telegrator/Handlers/Diagnostics/FiltersFallbackReport.cs @@ -1,6 +1,6 @@ using Telegram.Bot.Types; -using Telegrator.Filters.Components; -using Telegrator.MadiatorCore.Descriptors; +using Telegrator.Core.Descriptors; +using Telegrator.Core.Filters; namespace Telegrator.Handlers.Diagnostics { diff --git a/src/Telegrator/Handlers/Diagnostics/TypesExtensions.cs b/src/Telegrator/Handlers/Diagnostics/TypesExtensions.cs index eb6ee0e..5bc6f07 100644 --- a/src/Telegrator/Handlers/Diagnostics/TypesExtensions.cs +++ b/src/Telegrator/Handlers/Diagnostics/TypesExtensions.cs @@ -1,4 +1,4 @@ -using Telegrator.Attributes.Components; +using Telegrator.Core.Attributes; namespace Telegrator.Handlers.Diagnostics { diff --git a/src/Telegrator/Handlers/HandlerContainer.cs b/src/Telegrator/Handlers/HandlerContainer.cs index 5046870..0f0d011 100644 --- a/src/Telegrator/Handlers/HandlerContainer.cs +++ b/src/Telegrator/Handlers/HandlerContainer.cs @@ -1,8 +1,8 @@ using Telegram.Bot; using Telegram.Bot.Types; -using Telegrator.Filters.Components; -using Telegrator.MadiatorCore; -using Telegrator.MadiatorCore.Descriptors; +using Telegrator.Core; +using Telegrator.Core.Descriptors; +using Telegrator.Core.Filters; namespace Telegrator.Handlers { diff --git a/src/Telegrator/Handlers/IHandlerContainer.cs b/src/Telegrator/Handlers/IHandlerContainer.cs index c4cc4df..e220eae 100644 --- a/src/Telegrator/Handlers/IHandlerContainer.cs +++ b/src/Telegrator/Handlers/IHandlerContainer.cs @@ -1,4 +1,4 @@ -using Telegrator.Handlers.Components; +using Telegrator.Core.Handlers; namespace Telegrator.Handlers { diff --git a/src/Telegrator/Handlers/InlineQueryHandler.cs b/src/Telegrator/Handlers/InlineQueryHandler.cs index d843f5d..d6e0a7e 100644 --- a/src/Telegrator/Handlers/InlineQueryHandler.cs +++ b/src/Telegrator/Handlers/InlineQueryHandler.cs @@ -2,8 +2,8 @@ using Telegram.Bot.Types.Enums; using Telegram.Bot.Types.InlineQueryResults; using Telegrator.Attributes; -using Telegrator.Filters.Components; -using Telegrator.Handlers.Components; +using Telegrator.Core.Filters; +using Telegrator.Core.Handlers; namespace Telegrator.Handlers { diff --git a/src/Telegrator/Handlers/MessageHandler.cs b/src/Telegrator/Handlers/MessageHandler.cs index cf823b3..800727c 100644 --- a/src/Telegrator/Handlers/MessageHandler.cs +++ b/src/Telegrator/Handlers/MessageHandler.cs @@ -2,8 +2,8 @@ using Telegram.Bot.Types.Enums; using Telegram.Bot.Types.ReplyMarkups; using Telegrator.Attributes; -using Telegrator.Filters.Components; -using Telegrator.Handlers.Components; +using Telegrator.Core.Filters; +using Telegrator.Core.Handlers; namespace Telegrator.Handlers { diff --git a/src/Telegrator/ITelegratorBot.cs b/src/Telegrator/ITelegratorBot.cs index 95b262b..f6dd4ea 100644 --- a/src/Telegrator/ITelegratorBot.cs +++ b/src/Telegrator/ITelegratorBot.cs @@ -1,4 +1,4 @@ -using Telegrator.MadiatorCore; +using Telegrator.Core; namespace Telegrator { diff --git a/src/Telegrator/Logging/Alligator.cs b/src/Telegrator/Logging/TelegratorLogging.cs similarity index 99% rename from src/Telegrator/Logging/Alligator.cs rename to src/Telegrator/Logging/TelegratorLogging.cs index b63b776..844b4c9 100644 --- a/src/Telegrator/Logging/Alligator.cs +++ b/src/Telegrator/Logging/TelegratorLogging.cs @@ -6,7 +6,7 @@ namespace Telegrator.Logging /// Centralized logging system for Telegrator. /// Provides static access to logging functionality with adapter support. /// - public static class Alligator + public static class TelegratorLogging { private static readonly List _adapters = new(); private static readonly object _lock = new(); diff --git a/src/Telegrator/Polling/DefaultRouterExceptionHandler.cs b/src/Telegrator/Mediation/DefaultRouterExceptionHandler.cs similarity index 95% rename from src/Telegrator/Polling/DefaultRouterExceptionHandler.cs rename to src/Telegrator/Mediation/DefaultRouterExceptionHandler.cs index 10033ac..ef0c581 100644 --- a/src/Telegrator/Polling/DefaultRouterExceptionHandler.cs +++ b/src/Telegrator/Mediation/DefaultRouterExceptionHandler.cs @@ -1,8 +1,8 @@ using Telegram.Bot; using Telegram.Bot.Polling; -using Telegrator.MadiatorCore; +using Telegrator.Core; -namespace Telegrator.Polling +namespace Telegrator.Mediation { /// /// Delegate used to handle exception diff --git a/src/Telegrator/Polling/DefaultUpdateReceiver.cs b/src/Telegrator/Mediation/DefaultUpdateReceiver.cs similarity index 98% rename from src/Telegrator/Polling/DefaultUpdateReceiver.cs rename to src/Telegrator/Mediation/DefaultUpdateReceiver.cs index 4edbd8e..f216d95 100644 --- a/src/Telegrator/Polling/DefaultUpdateReceiver.cs +++ b/src/Telegrator/Mediation/DefaultUpdateReceiver.cs @@ -2,8 +2,9 @@ using Telegram.Bot.Polling; using Telegram.Bot.Requests; using Telegram.Bot.Types; +using Telegrator.Core; -namespace Telegrator.Polling +namespace Telegrator.Mediation { /// /// Reactive implementation of for polling updates from Telegram. diff --git a/src/Telegrator/Polling/UpdateHandlersPool.cs b/src/Telegrator/Mediation/UpdateHandlersPool.cs similarity index 93% rename from src/Telegrator/Polling/UpdateHandlersPool.cs rename to src/Telegrator/Mediation/UpdateHandlersPool.cs index 9ee262f..baa4160 100644 --- a/src/Telegrator/Polling/UpdateHandlersPool.cs +++ b/src/Telegrator/Mediation/UpdateHandlersPool.cs @@ -1,11 +1,11 @@ using System.Security.Authentication.ExtendedProtection; using System.Threading.Channels; -using Telegrator.Handlers.Components; +using Telegrator.Core; +using Telegrator.Core.Descriptors; +using Telegrator.Core.Handlers; using Telegrator.Logging; -using Telegrator.MadiatorCore; -using Telegrator.MadiatorCore.Descriptors; -namespace Telegrator.Polling +namespace Telegrator.Mediation { /// /// Implementation of that manages the execution of handlers. @@ -119,7 +119,7 @@ namespace Telegrator.Polling { try { - Alligator.LogDebug("Described handler '{0}' (Update {1})", handlerInfo.DisplayString, handlerInfo.HandlingUpdate.Id); + TelegratorLogging.LogDebug("Described handler '{0}' (Update {1})", handlerInfo.DisplayString, handlerInfo.HandlingUpdate.Id); HandlerExecuting?.Invoke(handlerInfo); using UpdateHandlerBase instance = handlerInfo.HandlerInstance; @@ -144,7 +144,7 @@ namespace Telegrator.Polling } catch (Exception ex) { - Alligator.LogError("Failed to process handler '{0}' (Update {1})", exception: ex, handlerInfo.DisplayString, handlerInfo.HandlingUpdate.Id); + TelegratorLogging.LogError("Failed to process handler '{0}' (Update {1})", exception: ex, handlerInfo.DisplayString, handlerInfo.HandlingUpdate.Id); handlerInfo.ReportResult(null); } } diff --git a/src/Telegrator/Polling/UpdateRouter.cs b/src/Telegrator/Mediation/UpdateRouter.cs similarity index 89% rename from src/Telegrator/Polling/UpdateRouter.cs rename to src/Telegrator/Mediation/UpdateRouter.cs index 111a8df..2bd33b9 100644 --- a/src/Telegrator/Polling/UpdateRouter.cs +++ b/src/Telegrator/Mediation/UpdateRouter.cs @@ -4,15 +4,15 @@ using Telegram.Bot; using Telegram.Bot.Polling; using Telegram.Bot.Types; using Telegram.Bot.Types.Enums; -using Telegrator.Configuration; -using Telegrator.Filters.Components; -using Telegrator.Handlers.Components; +using Telegrator.Core; +using Telegrator.Core.Descriptors; +using Telegrator.Core.Filters; +using Telegrator.Core.Handlers; using Telegrator.Handlers.Diagnostics; using Telegrator.Logging; -using Telegrator.MadiatorCore; -using Telegrator.MadiatorCore.Descriptors; +using Telegrator.Polling; -namespace Telegrator.Polling +namespace Telegrator.Mediation { /// /// Implementation of that routes updates to appropriate handlers. @@ -25,7 +25,6 @@ namespace Telegrator.Polling private readonly IAwaitingProvider _awaitingProvider; private readonly IUpdateHandlersPool _HandlersPool; private readonly ITelegramBotInfo _botInfo; - private readonly HandlerDescriptorList _handlingRoutes; /// public IHandlersProvider HandlersProvider => _handlersProvider; @@ -59,7 +58,6 @@ namespace Telegrator.Polling _awaitingProvider = awaitingProvider; _HandlersPool = new UpdateHandlersPool(this, _options, _options.GlobalCancellationToken); _botInfo = botInfo; - _handlingRoutes = new HandlerDescriptorList(); } /// @@ -77,7 +75,6 @@ namespace Telegrator.Polling _awaitingProvider = awaitingProvider; _HandlersPool = handlersPool; _botInfo = botInfo; - _handlingRoutes = new HandlerDescriptorList(); } /// @@ -90,7 +87,7 @@ namespace Telegrator.Polling /// A task representing the asynchronous error handling operation. public virtual Task HandleErrorAsync(ITelegramBotClient botClient, Exception exception, HandleErrorSource source, CancellationToken cancellationToken) { - Alligator.LogDebug("Handling exception {0}", exception.GetType().Name); + TelegratorLogging.LogDebug("Handling exception {0}", exception.GetType().Name); ExceptionHandler?.HandleException(botClient, exception, source, cancellationToken); return Task.CompletedTask; } @@ -129,27 +126,27 @@ namespace Telegrator.Polling if (lastResult != null && !lastResult.RouteNext) break; - Alligator.LogTrace("Handler '{0}' requested route continuation (Update {1})", handlerInfo.DisplayString, handlerInfo.HandlingUpdate.Id); + TelegratorLogging.LogTrace("Handler '{0}' requested route continuation (Update {1})", handlerInfo.DisplayString, handlerInfo.HandlingUpdate.Id); } // Checking if awaiting handlers has exclusive routing if (Options.ExclusiveAwaitingHandlerRouting) { - Alligator.LogTrace("Receiving Update ({0}) completed with only awaiting handlers", update.Id); + TelegratorLogging.LogTrace("Receiving Update ({0}) completed with only awaiting handlers", update.Id); return; } // Queuing reagular handlers for execution await HandlersPool.Enqueue(GetHandlers(HandlersProvider, botClient, update, cancellationToken)); - Alligator.LogTrace("Receiving Update ({0}) finished", update.Id); + TelegratorLogging.LogTrace("Receiving Update ({0}) finished", update.Id); } catch (OperationCanceledException) { - Alligator.LogTrace("Receiving Update ({0}) cancelled", update.Id); + TelegratorLogging.LogTrace("Receiving Update ({0}) cancelled", update.Id); } catch (Exception ex) { - Alligator.LogDebug("Receiving Update ({0}) finished with exception {1}", update.Id, ex.Message); + TelegratorLogging.LogDebug("Receiving Update ({0}) finished with exception {1}", update.Id, ex.Message); ExceptionHandler?.HandleException(botClient, ex, HandleErrorSource.PollingError, cancellationToken); } } @@ -165,16 +162,16 @@ namespace Telegrator.Polling /// A collection of described handler information for the update protected virtual IEnumerable GetHandlers(IHandlersProvider provider, ITelegramBotClient client, Update update, CancellationToken cancellationToken = default) { - Alligator.LogTrace("Requested handlers for UpdateType.{0}", update.Type); + TelegratorLogging.LogTrace("Requested handlers for UpdateType.{0}", update.Type); if (!provider.TryGetDescriptorList(update.Type, out HandlerDescriptorList? descriptors)) { - Alligator.LogTrace("No registered, providing Any"); + TelegratorLogging.LogTrace("No registered, providing Any"); provider.TryGetDescriptorList(UpdateType.Unknown, out descriptors); } if (descriptors == null || descriptors.Count == 0) { - Alligator.LogTrace("No handlers provided"); + TelegratorLogging.LogTrace("No handlers provided"); return []; } @@ -193,7 +190,7 @@ namespace Telegrator.Polling /// A collection of described handler information protected virtual IEnumerable DescribeDescriptors(IHandlersProvider provider, HandlerDescriptorList descriptors, ITelegramBotClient client, Update update, CancellationToken cancellationToken = default) { - Alligator.LogTrace("Describing descriptors of descriptorsList.HandlingType.{0} for Update ({1})", descriptors.HandlingType, update.Id); + TelegratorLogging.LogTrace("Describing descriptors of descriptorsList.HandlingType.{0} for Update ({1})", descriptors.HandlingType, update.Id); foreach (HandlerDescriptor descriptor in descriptors.Reverse()) { cancellationToken.ThrowIfCancellationRequested(); @@ -207,7 +204,7 @@ namespace Telegrator.Polling yield return describedHandler; } - Alligator.LogTrace("Describing for Update ({0}) finished", update.Id); + TelegratorLogging.LogTrace("Describing for Update ({0}) finished", update.Id); } /// @@ -260,7 +257,7 @@ namespace Telegrator.Polling /// protected static void LogUpdate(Update update) { - if (Alligator.MinimalLevel > LogLevel.Trace) + if (TelegratorLogging.MinimalLevel > LogLevel.Trace) return; StringBuilder sb = new StringBuilder(); @@ -294,7 +291,7 @@ namespace Telegrator.Polling } } - Alligator.LogTrace(sb.ToString()); + TelegratorLogging.LogTrace(sb.ToString()); } private class BreakDescribingException : Exception { } diff --git a/src/Telegrator/Providers/AwaitingProvider.cs b/src/Telegrator/Providers/AwaitingProvider.cs index 356e35e..f98cf8e 100644 --- a/src/Telegrator/Providers/AwaitingProvider.cs +++ b/src/Telegrator/Providers/AwaitingProvider.cs @@ -1,6 +1,6 @@ using Telegram.Bot.Types.Enums; -using Telegrator.MadiatorCore; -using Telegrator.MadiatorCore.Descriptors; +using Telegrator.Core; +using Telegrator.Core.Descriptors; namespace Telegrator.Providers { diff --git a/src/Telegrator/Providers/HandlersCollection.cs b/src/Telegrator/Providers/HandlersCollection.cs index 2c41656..8d26df4 100644 --- a/src/Telegrator/Providers/HandlersCollection.cs +++ b/src/Telegrator/Providers/HandlersCollection.cs @@ -1,9 +1,8 @@ using System.Reflection; using Telegram.Bot.Types.Enums; using Telegrator.Annotations; -using Telegrator.Configuration; -using Telegrator.MadiatorCore; -using Telegrator.MadiatorCore.Descriptors; +using Telegrator.Core; +using Telegrator.Core.Descriptors; namespace Telegrator.Providers { @@ -12,7 +11,7 @@ namespace Telegrator.Providers /// Provides functionality for collecting, adding, and organizing handlers. /// /// Optional configuration options for handler collecting. - public class HandlersCollection(ITelegratorOptions? options) : IHandlersCollection + public class HandlersCollection(TelegratorOptions? options) : IHandlersCollection { /// /// Gets the collection of 's allowed by registered handlers @@ -27,7 +26,7 @@ namespace Telegrator.Providers /// /// Configuration options for handler collecting. /// - protected readonly ITelegratorOptions? Options = options; + protected readonly TelegratorOptions? Options = options; /// /// Gets whether handlers must have a parameterless constructor. diff --git a/src/Telegrator/Providers/HandlersManagerBase.cs b/src/Telegrator/Providers/HandlersManagerBase.cs index 1883cf1..b39f3f0 100644 --- a/src/Telegrator/Providers/HandlersManagerBase.cs +++ b/src/Telegrator/Providers/HandlersManagerBase.cs @@ -1,10 +1,9 @@ using System.Reflection; using Telegram.Bot.Types.Enums; using Telegrator.Annotations; -using Telegrator.Configuration; -using Telegrator.Handlers.Components; -using Telegrator.MadiatorCore; -using Telegrator.MadiatorCore.Descriptors; +using Telegrator.Core; +using Telegrator.Core.Descriptors; +using Telegrator.Core.Handlers; namespace Telegrator.Providers { @@ -13,7 +12,7 @@ namespace Telegrator.Providers /// Minimum implementation of . Abstract class, still requires handler instance resolving. /// /// - public abstract class HandlersManagerBase(ITelegratorOptions options) : IHandlersManager + public abstract class HandlersManagerBase(TelegratorOptions options) : IHandlersManager { /// /// Dictionary that organizes handler descriptors by update type. @@ -28,7 +27,7 @@ namespace Telegrator.Providers /// /// Configuration options for handler collecting. /// - protected readonly ITelegratorOptions? Options = options; + protected readonly TelegratorOptions? Options = options; /// /// Gets whether handlers must have a parameterless constructor. diff --git a/src/Telegrator/Providers/HandlersProvider.cs b/src/Telegrator/Providers/HandlersProvider.cs index f4d1f82..8f18d52 100644 --- a/src/Telegrator/Providers/HandlersProvider.cs +++ b/src/Telegrator/Providers/HandlersProvider.cs @@ -1,10 +1,10 @@ using System.Collections.ObjectModel; using Telegram.Bot.Types; using Telegram.Bot.Types.Enums; -using Telegrator.Handlers.Components; +using Telegrator.Core; +using Telegrator.Core.Descriptors; +using Telegrator.Core.Handlers; using Telegrator.Logging; -using Telegrator.MadiatorCore; -using Telegrator.MadiatorCore.Descriptors; namespace Telegrator.Providers { @@ -40,7 +40,7 @@ namespace Telegrator.Providers AllowedTypes = handlers.AllowedTypes; HandlersDictionary = handlers.Values.ForEach(list => list.Freeze()).ToReadOnlyDictionary(list => list.HandlingType); Options = options ?? throw new ArgumentNullException(nameof(options)); - Alligator.LogTrace("{0} created!", GetType().Name); + TelegratorLogging.LogTrace("{0} created!", GetType().Name); } /// @@ -54,7 +54,7 @@ namespace Telegrator.Providers AllowedTypes = Update.AllTypes; HandlersDictionary = handlers.ForEach(list => list.Freeze()).ToReadOnlyDictionary(list => list.HandlingType); Options = options ?? throw new ArgumentNullException(nameof(options)); - Alligator.LogTrace("{0} created!", GetType().Name); + TelegratorLogging.LogTrace("{0} created!", GetType().Name); } /// @@ -82,7 +82,7 @@ namespace Telegrator.Providers } catch (Exception ex) { - Alligator.LogError("Failed to create instance of '{0}'", exception: ex, descriptor.ToString()); + TelegratorLogging.LogError("Failed to create instance of '{0}'", exception: ex, descriptor.ToString()); throw; } } diff --git a/src/Telegrator/Result.cs b/src/Telegrator/Result.cs index b195b43..060b28b 100644 --- a/src/Telegrator/Result.cs +++ b/src/Telegrator/Result.cs @@ -1,7 +1,7 @@ using Telegrator.Aspects; -using Telegrator.Handlers.Components; +using Telegrator.Core; +using Telegrator.Core.Handlers; using Telegrator.Handlers.Diagnostics; -using Telegrator.MadiatorCore; namespace Telegrator { diff --git a/src/Telegrator/SimpleTypesExtensions.cs b/src/Telegrator/SimpleTypesExtensions.cs index 30bbdcd..b3e2963 100644 --- a/src/Telegrator/SimpleTypesExtensions.cs +++ b/src/Telegrator/SimpleTypesExtensions.cs @@ -1,8 +1,8 @@ using System.Collections.ObjectModel; using System.Reflection; -using Telegrator.Filters.Components; -using Telegrator.Handlers.Components; -using Telegrator.Providers; +using Telegrator.Core; +using Telegrator.Core.Filters; +using Telegrator.Core.Handlers; namespace Telegrator { diff --git a/src/Telegrator/StateKeeping/ArrayStateKeeper.cs b/src/Telegrator/StateKeeping/ArrayStateKeeper.cs index 120cf01..2294e86 100644 --- a/src/Telegrator/StateKeeping/ArrayStateKeeper.cs +++ b/src/Telegrator/StateKeeping/ArrayStateKeeper.cs @@ -1,4 +1,4 @@ -using Telegrator.StateKeeping.Components; +using Telegrator.Core.StateKeeping; namespace Telegrator.StateKeeping { diff --git a/src/Telegrator/StateKeeping/ChatIdResolver.cs b/src/Telegrator/StateKeeping/ChatIdResolver.cs index 07d8e8e..d8d34bd 100644 --- a/src/Telegrator/StateKeeping/ChatIdResolver.cs +++ b/src/Telegrator/StateKeeping/ChatIdResolver.cs @@ -1,5 +1,5 @@ using Telegram.Bot.Types; -using Telegrator.StateKeeping.Components; +using Telegrator.Core.StateKeeping; namespace Telegrator.StateKeeping { diff --git a/src/Telegrator/StateKeeping/EnumStateKeeper.cs b/src/Telegrator/StateKeeping/EnumStateKeeper.cs index ba9a8d8..68c0579 100644 --- a/src/Telegrator/StateKeeping/EnumStateKeeper.cs +++ b/src/Telegrator/StateKeeping/EnumStateKeeper.cs @@ -1,5 +1,5 @@ using Telegrator.Annotations.StateKeeping; -using Telegrator.Handlers.Components; +using Telegrator.Core.Handlers; namespace Telegrator.StateKeeping { diff --git a/src/Telegrator/StateKeeping/NumericStateKeeper.cs b/src/Telegrator/StateKeeping/NumericStateKeeper.cs index b8ea824..3c54557 100644 --- a/src/Telegrator/StateKeeping/NumericStateKeeper.cs +++ b/src/Telegrator/StateKeeping/NumericStateKeeper.cs @@ -1,6 +1,6 @@ using Telegrator.Annotations.StateKeeping; -using Telegrator.Handlers.Components; -using Telegrator.StateKeeping.Components; +using Telegrator.Core.Handlers; +using Telegrator.Core.StateKeeping; namespace Telegrator.StateKeeping { diff --git a/src/Telegrator/StateKeeping/SenderIdResolver.cs b/src/Telegrator/StateKeeping/SenderIdResolver.cs index ebc7af6..af53c82 100644 --- a/src/Telegrator/StateKeeping/SenderIdResolver.cs +++ b/src/Telegrator/StateKeeping/SenderIdResolver.cs @@ -1,5 +1,5 @@ using Telegram.Bot.Types; -using Telegrator.StateKeeping.Components; +using Telegrator.Core.StateKeeping; namespace Telegrator.StateKeeping { diff --git a/src/Telegrator/StateKeeping/StringStateKeeper.cs b/src/Telegrator/StateKeeping/StringStateKeeper.cs index cbf8f7b..13832ed 100644 --- a/src/Telegrator/StateKeeping/StringStateKeeper.cs +++ b/src/Telegrator/StateKeeping/StringStateKeeper.cs @@ -1,6 +1,6 @@ using Telegrator.Annotations.StateKeeping; -using Telegrator.Handlers.Components; -using Telegrator.StateKeeping.Components; +using Telegrator.Core.Handlers; +using Telegrator.Core.StateKeeping; namespace Telegrator.StateKeeping { diff --git a/src/Telegrator/TelegramBotInfo.cs b/src/Telegrator/TelegramBotInfo.cs index eaaf633..7fb2dd3 100644 --- a/src/Telegrator/TelegramBotInfo.cs +++ b/src/Telegrator/TelegramBotInfo.cs @@ -1,5 +1,5 @@ using Telegram.Bot.Types; -using Telegrator.Configuration; +using Telegrator.Core; namespace Telegrator { diff --git a/src/Telegrator/Telegrator.csproj b/src/Telegrator/Telegrator.csproj index 4624757..7f6c051 100644 --- a/src/Telegrator/Telegrator.csproj +++ b/src/Telegrator/Telegrator.csproj @@ -4,9 +4,9 @@ netstandard2.0 enable enable - latest - ..\..\bin - ..\..\docs\$(AssemblyName).xml + latest + ..\..\bin + ..\..\docs\$(AssemblyName).xml True True @@ -15,8 +15,8 @@ Telegrator : Telegram.Bot mediator framework 1.16.0 - Rikitav Tim4ik - Rikitav Tim4ik + Rikitav Tim4ik + Rikitav Tim4ik https://github.com/Rikitav/Telegrator telegram;bot;mediator;attributes;aspect;hosting;host;framework;easy;simple;handlers diff --git a/src/Telegrator/TelegratorClient.cs b/src/Telegrator/TelegratorClient.cs index ce7057b..f9c2312 100644 --- a/src/Telegrator/TelegratorClient.cs +++ b/src/Telegrator/TelegratorClient.cs @@ -1,8 +1,8 @@ using Telegram.Bot; using Telegram.Bot.Polling; -using Telegrator.Configuration; +using Telegrator.Core; using Telegrator.Logging; -using Telegrator.MadiatorCore; +using Telegrator.Mediation; using Telegrator.Polling; using Telegrator.Providers; @@ -80,7 +80,7 @@ namespace Telegrator updateRouter = new UpdateRouter(handlerProvider, awaitingProvider, Options, BotInfo); // Log startup - Alligator.LogInformation($"Telegrator bot starting up - BotId: {BotInfo.User.Id}, Username: {BotInfo.User.Username}, MaxParallelHandlers: {Options.MaximumParallelWorkingHandlers ?? -1}"); + TelegratorLogging.LogInformation($"Telegrator bot starting up - BotId: {BotInfo.User.Id}, Username: {BotInfo.User.Username}, MaxParallelHandlers: {Options.MaximumParallelWorkingHandlers ?? -1}"); StartReceivingInternal(receiverOptions, cancellationToken); } @@ -111,7 +111,7 @@ namespace Telegrator catch (OperationCanceledException) { // Cancelled - Alligator.LogInformation("Telegrator bot stopped (cancelled)"); + TelegratorLogging.LogInformation("Telegrator bot stopped (cancelled)"); } } diff --git a/src/Telegrator/TelegratorOptions.cs b/src/Telegrator/TelegratorOptions.cs index e50b927..574a628 100644 --- a/src/Telegrator/TelegratorOptions.cs +++ b/src/Telegrator/TelegratorOptions.cs @@ -1,18 +1,16 @@ -using Telegrator.Configuration; - -namespace Telegrator +namespace Telegrator { /// /// Configuration options for Telegram bot behavior and execution settings. /// Controls various aspects of bot operation including concurrency, routing, and execution policies. /// - public class TelegratorOptions : ITelegratorOptions + public class TelegratorOptions { /// - public int? MaximumParallelWorkingHandlers { get; set; } + public int? MaximumParallelWorkingHandlers { get; set; } = null; /// - public bool ExclusiveAwaitingHandlerRouting { get; set; } + public bool ExclusiveAwaitingHandlerRouting { get; set; } = false; /// public bool ExceptIntersectingCommandAliases { get; set; } = true; diff --git a/src/Telegrator/TypesExtensions.cs b/src/Telegrator/TypesExtensions.cs index 5c40cd9..56efd1f 100644 --- a/src/Telegrator/TypesExtensions.cs +++ b/src/Telegrator/TypesExtensions.cs @@ -4,14 +4,13 @@ using Telegram.Bot.Types.Enums; using Telegram.Bot.Types.Payments; using Telegrator.Annotations; using Telegrator.Attributes; +using Telegrator.Core; +using Telegrator.Core.Descriptors; +using Telegrator.Core.Handlers; +using Telegrator.Core.Handlers.Building; +using Telegrator.Core.StateKeeping; using Telegrator.Handlers.Building; -using Telegrator.Handlers.Building.Components; -using Telegrator.Handlers.Components; -using Telegrator.MadiatorCore; -using Telegrator.MadiatorCore.Descriptors; -using Telegrator.Providers; using Telegrator.StateKeeping; -using Telegrator.StateKeeping.Components; namespace Telegrator { @@ -121,7 +120,7 @@ namespace Telegrator if (!message.IsCommand(out _, out string? argsStr)) throw new InvalidDataException("Message does not contain a command"); - return argsStr.Split([' '], StringSplitOptions.RemoveEmptyEntries); + return argsStr?.Split([' '], StringSplitOptions.RemoveEmptyEntries) ?? []; } /// diff --git a/tests/Telegrator.Tests/Collections/CollectionTests.cs b/tests/Telegrator.Tests/Collections/CollectionTests.cs index 21d661e..086cc2a 100644 --- a/tests/Telegrator.Tests/Collections/CollectionTests.cs +++ b/tests/Telegrator.Tests/Collections/CollectionTests.cs @@ -1,7 +1,7 @@ using FluentAssertions; using Telegram.Bot.Types.Enums; +using Telegrator.Core.Descriptors; using Telegrator.Filters.Components; -using Telegrator.MadiatorCore.Descriptors; using Xunit; namespace Telegrator.Tests.Collections