diff --git a/Telegrator.Localized/ILocalizedHandler.cs b/Telegrator.Localized/ILocalizedHandler.cs new file mode 100644 index 0000000..3b47c0f --- /dev/null +++ b/Telegrator.Localized/ILocalizedHandler.cs @@ -0,0 +1,11 @@ +using Microsoft.Extensions.Localization; +using Telegram.Bot.Types; +using Telegrator.Handlers.Components; + +namespace Telegrator.Localized +{ + public interface ILocalizedHandler : IAbstractUpdateHandler where T : class + { + public IStringLocalizer LocalizationProvider { get; } + } +} diff --git a/Telegrator.Localized/ILocalizedMessageHandler.cs b/Telegrator.Localized/ILocalizedMessageHandler.cs new file mode 100644 index 0000000..6e739e7 --- /dev/null +++ b/Telegrator.Localized/ILocalizedMessageHandler.cs @@ -0,0 +1,10 @@ +using Telegram.Bot.Types; +using Telegrator.Handlers.Components; + +namespace Telegrator.Localized +{ + public interface ILocalizedMessageHandler : ILocalizedHandler + { + + } +} diff --git a/Telegrator.Localized/LocalizedMessageHandlerExtensions.cs b/Telegrator.Localized/LocalizedMessageHandlerExtensions.cs new file mode 100644 index 0000000..7957cd7 --- /dev/null +++ b/Telegrator.Localized/LocalizedMessageHandlerExtensions.cs @@ -0,0 +1,17 @@ +using Microsoft.Extensions.Localization; +using System.Collections.Generic; +using System.Threading.Tasks; +using Telegram.Bot.Types; +using Telegrator.Handlers; + +namespace Telegrator.Localized +{ + public static class LocalizedMessageHandlerExtensions + { + public static async Task ResponseLocalized(this ILocalizedHandler localizedHandler, string localizedReplyIdentifier, params IEnumerable formatArgs) + { + LocalizedString localizedString = localizedHandler.LocalizationProvider[localizedReplyIdentifier]; + localizedHandler.Container.Response(); + } + } +} diff --git a/Telegrator.Localized/Telegrator.Localized.csproj b/Telegrator.Localized/Telegrator.Localized.csproj new file mode 100644 index 0000000..2c1a84a --- /dev/null +++ b/Telegrator.Localized/Telegrator.Localized.csproj @@ -0,0 +1,16 @@ + + + + netstandard2.0 + latest + + + + + + + + + + + diff --git a/Telegrator.Tests/Handlers/HandlerTests.cs b/Telegrator.Tests/Handlers/HandlerTests.cs index 1b9b85c..7ee4b9d 100644 --- a/Telegrator.Tests/Handlers/HandlerTests.cs +++ b/Telegrator.Tests/Handlers/HandlerTests.cs @@ -70,7 +70,7 @@ namespace Telegrator.Tests.Handlers public async Task UpdateHandlerBase_ShouldHandleCancellation() { // Arrange - var mockContainer = new Mock>(); + var mockContainer = new Mock>(); var testHandler = new TestUpdateHandler(); var cancellationTokenSource = new CancellationTokenSource(); cancellationTokenSource.Cancel(); // Отменяем сразу diff --git a/Telegrator.Tests/TestUpdateHandler.cs b/Telegrator.Tests/TestUpdateHandler.cs index 341fcb5..e897e9d 100644 --- a/Telegrator.Tests/TestUpdateHandler.cs +++ b/Telegrator.Tests/TestUpdateHandler.cs @@ -13,7 +13,7 @@ namespace Telegrator.Tests { public bool WasExecuted { get; private set; } - public override Task Execute(IAbstractHandlerContainer container, CancellationToken cancellationToken) + public override Task Execute(IHandlerContainer container, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); WasExecuted = true; diff --git a/Telegrator.sln b/Telegrator.sln index dec83f8..4b1564c 100644 --- a/Telegrator.sln +++ b/Telegrator.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.14.36119.2 +# Visual Studio Version 18 +VisualStudioVersion = 18.2.11408.102 d18.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Telegrator", "Telegrator\Telegrator.csproj", "{12D1D209-6473-4F58-BD66-846F0D85F6FD}" EndProject @@ -20,6 +20,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Telegrator.Hosting.Web", "T EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Telegrator.RoslynGenerators", "dev\Telegrator.RoslynGenerators\Telegrator.RoslynGenerators.csproj", "{93658B7F-C651-4C78-2CB1-2C0AE00C45B5}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Telegrator.Localized", "Telegrator.Localized\Telegrator.Localized.csproj", "{0B5D9465-B5E4-4B37-92D2-6AF1D682DAD9}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution AnalyzersDebug|Any CPU = AnalyzersDebug|Any CPU @@ -63,6 +65,12 @@ Global {93658B7F-C651-4C78-2CB1-2C0AE00C45B5}.Debug|Any CPU.Build.0 = Debug|Any CPU {93658B7F-C651-4C78-2CB1-2C0AE00C45B5}.Release|Any CPU.ActiveCfg = Release|Any CPU {93658B7F-C651-4C78-2CB1-2C0AE00C45B5}.Release|Any CPU.Build.0 = Release|Any CPU + {0B5D9465-B5E4-4B37-92D2-6AF1D682DAD9}.AnalyzersDebug|Any CPU.ActiveCfg = Release|Any CPU + {0B5D9465-B5E4-4B37-92D2-6AF1D682DAD9}.AnalyzersDebug|Any CPU.Build.0 = Release|Any CPU + {0B5D9465-B5E4-4B37-92D2-6AF1D682DAD9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0B5D9465-B5E4-4B37-92D2-6AF1D682DAD9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0B5D9465-B5E4-4B37-92D2-6AF1D682DAD9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0B5D9465-B5E4-4B37-92D2-6AF1D682DAD9}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Telegrator/Handlers/Building/BuildedAbstractHandler.cs b/Telegrator/Handlers/Building/BuildedAbstractHandler.cs index 14c215b..2db7f32 100644 --- a/Telegrator/Handlers/Building/BuildedAbstractHandler.cs +++ b/Telegrator/Handlers/Building/BuildedAbstractHandler.cs @@ -31,7 +31,7 @@ namespace Telegrator.Handlers.Building /// The handler container with execution context. /// The cancellation token. /// A task representing the asynchronous execution. - public override Task Execute(IAbstractHandlerContainer container, CancellationToken cancellation) + public override Task Execute(IHandlerContainer container, CancellationToken cancellation) => HandlerAction.Invoke(container, cancellation); } } diff --git a/Telegrator/Handlers/Building/HandlerBuilder.cs b/Telegrator/Handlers/Building/HandlerBuilder.cs index 5a00776..fd9c129 100644 --- a/Telegrator/Handlers/Building/HandlerBuilder.cs +++ b/Telegrator/Handlers/Building/HandlerBuilder.cs @@ -11,7 +11,7 @@ namespace Telegrator.Handlers.Building /// The handler container with execution context. /// The cancellation token. /// A task representing the asynchronous execution. - public delegate Task AbstractHandlerAction(IAbstractHandlerContainer container, CancellationToken cancellation) where TUpdate : class; + public delegate Task AbstractHandlerAction(IHandlerContainer container, CancellationToken cancellation) where TUpdate : class; /// /// Builder class for creating regular handlers that can process updates. diff --git a/Telegrator/Handlers/CallbackQueryHandler.cs b/Telegrator/Handlers/CallbackQueryHandler.cs index 22f2310..d0134e2 100644 --- a/Telegrator/Handlers/CallbackQueryHandler.cs +++ b/Telegrator/Handlers/CallbackQueryHandler.cs @@ -77,7 +77,7 @@ namespace Telegrator.Handlers int? directMessageTopicId = null, SuggestedPostParameters? suggestedPostParameters = null, CancellationToken cancellationToken = default) - => await Container.Responce( + => await Container.Response( text, parseMode, replyParameters, replyMarkup, linkPreviewOptions, messageThreadId, entities, diff --git a/Telegrator/Handlers/Components/AbstractUpdateHandler.cs b/Telegrator/Handlers/Components/AbstractUpdateHandler.cs index fbc7e08..f0b8d2e 100644 --- a/Telegrator/Handlers/Components/AbstractUpdateHandler.cs +++ b/Telegrator/Handlers/Components/AbstractUpdateHandler.cs @@ -10,12 +10,12 @@ namespace Telegrator.Handlers.Components /// /// Abstract handler for Telegram updates of type . /// - public abstract class AbstractUpdateHandler : UpdateHandlerBase, IHandlerContainerFactory where TUpdate : class + public abstract class AbstractUpdateHandler : UpdateHandlerBase, IHandlerContainerFactory, IAbstractUpdateHandler where TUpdate : class { /// /// Handler container for the current update. /// - protected IAbstractHandlerContainer Container { get; private set; } = default!; + public IHandlerContainer Container { get; private set; } = default!; /// /// Telegram Bot client associated with the current container. @@ -64,7 +64,7 @@ namespace Telegrator.Handlers.Components /// The created handler container. public virtual IHandlerContainer CreateContainer(DescribedHandlerInfo handlerInfo) { - return new AbstractHandlerContainer(handlerInfo); + return new HandlerContainer(handlerInfo); } /// @@ -75,7 +75,7 @@ namespace Telegrator.Handlers.Components /// A task representing the asynchronous operation. protected override sealed async Task ExecuteInternal(IHandlerContainer container, CancellationToken cancellationToken) { - Container = (IAbstractHandlerContainer)container; + Container = (IHandlerContainer)container; return await Execute(Container, cancellationToken); } @@ -85,6 +85,6 @@ namespace Telegrator.Handlers.Components /// The handler container. /// Cancellation token. /// A task representing the asynchronous operation. - public abstract Task Execute(IAbstractHandlerContainer container, CancellationToken cancellation); + public abstract Task Execute(IHandlerContainer container, CancellationToken cancellation); } } diff --git a/Telegrator/Handlers/Components/BranchingUpdateHandler.cs b/Telegrator/Handlers/Components/BranchingUpdateHandler.cs index 338627c..ab8061d 100644 --- a/Telegrator/Handlers/Components/BranchingUpdateHandler.cs +++ b/Telegrator/Handlers/Components/BranchingUpdateHandler.cs @@ -108,7 +108,7 @@ namespace Telegrator.Handlers.Components /// Thrown when the awaiting provider is not of the expected type. public override IHandlerContainer CreateContainer(DescribedHandlerInfo handlerInfo) { - return new AbstractHandlerContainer(handlerInfo); + return new HandlerContainer(handlerInfo); } /// @@ -117,7 +117,7 @@ namespace Telegrator.Handlers.Components /// The handler container. /// The cancellation token. /// Thrown when no branch method is set. - public override async Task Execute(IAbstractHandlerContainer container, CancellationToken cancellation) + public override async Task Execute(IHandlerContainer container, CancellationToken cancellation) { if (branchMethodInfo is null) throw new Exception(); @@ -131,7 +131,7 @@ namespace Telegrator.Handlers.Components /// /// The handler container. /// The method to execute. - protected virtual async Task BranchExecuteWrapper(IAbstractHandlerContainer container, MethodInfo methodInfo) + protected virtual async Task BranchExecuteWrapper(IHandlerContainer container, MethodInfo methodInfo) { if (methodInfo.ReturnType == typeof(void)) { diff --git a/Telegrator/Handlers/Components/IAbstractUpdateHandler.cs b/Telegrator/Handlers/Components/IAbstractUpdateHandler.cs new file mode 100644 index 0000000..9c0d3e8 --- /dev/null +++ b/Telegrator/Handlers/Components/IAbstractUpdateHandler.cs @@ -0,0 +1,20 @@ +namespace Telegrator.Handlers.Components; + +/// +/// Abstract handler for Telegram updates of type . +/// +public interface IAbstractUpdateHandler where TUpdate : class +{ + /// + /// Handler container for the current update. + /// + public IHandlerContainer Container { get; } + + /// + /// Abstract method to execute the update handling logic. + /// + /// The handler container. + /// Cancellation token. + /// A task representing the asynchronous operation. + public Task Execute(IHandlerContainer container, CancellationToken cancellation); +} \ No newline at end of file diff --git a/Telegrator/Handlers/Components/IUpdateHandlerBase.cs b/Telegrator/Handlers/Components/IUpdateHandlerBase.cs new file mode 100644 index 0000000..a19085f --- /dev/null +++ b/Telegrator/Handlers/Components/IUpdateHandlerBase.cs @@ -0,0 +1,42 @@ +using Telegram.Bot; +using Telegram.Bot.Types.Enums; +using Telegrator.Handlers.Diagnostics; +using Telegrator.MadiatorCore.Descriptors; + +namespace Telegrator.Handlers.Components; + +/// +/// Abstraction for update handlers, providing execution and lifetime management for Telegram updates. +/// +public interface IUpdateHandlerBase : IDisposable +{ + /// + /// Gets the that this handler processes. + /// + UpdateType HandlingUpdateType { get; } + + /// + /// Gets the associated with this handler instance. + /// + HandlerLifetimeToken LifetimeToken { get; } + + /// + /// Executes the handler logic and marks the lifetime as ended after execution. + /// + /// + /// The cancellation token. + /// A representing the asynchronous operation. + Task Execute(DescribedHandlerInfo described, CancellationToken cancellationToken = default); + + /// + /// Handles failed filters during handler describing. + /// Use to control how router should treat this fail. + /// to silently continue decribing. + /// to stop\break desribing sequence. + /// + /// + /// + /// + /// + Task FiltersFallback(FiltersFallbackReport report, ITelegramBotClient client, CancellationToken cancellationToken = default); +} \ No newline at end of file diff --git a/Telegrator/Handlers/Components/UpdateHandlerBase.cs b/Telegrator/Handlers/Components/UpdateHandlerBase.cs index 9cb79b9..8f8affd 100644 --- a/Telegrator/Handlers/Components/UpdateHandlerBase.cs +++ b/Telegrator/Handlers/Components/UpdateHandlerBase.cs @@ -1,9 +1,6 @@ -using System.ComponentModel; -using Telegram.Bot; +using Telegram.Bot; using Telegram.Bot.Polling; -using Telegram.Bot.Types; using Telegram.Bot.Types.Enums; -using Telegrator.Filters.Components; using Telegrator.Handlers.Diagnostics; using Telegrator.MadiatorCore.Descriptors; @@ -12,7 +9,7 @@ namespace Telegrator.Handlers.Components /// /// Base class for update handlers, providing execution and lifetime management for Telegram updates. /// - public abstract class UpdateHandlerBase(UpdateType handlingUpdateType) : IDisposable + public abstract class UpdateHandlerBase(UpdateType handlingUpdateType) : IUpdateHandlerBase { /// /// Gets the that this handler processes. diff --git a/Telegrator/Handlers/AbstractHandlerContainer.cs b/Telegrator/Handlers/HandlerContainer.cs similarity index 76% rename from Telegrator/Handlers/AbstractHandlerContainer.cs rename to Telegrator/Handlers/HandlerContainer.cs index 88ed8dc..ffbdd89 100644 --- a/Telegrator/Handlers/AbstractHandlerContainer.cs +++ b/Telegrator/Handlers/HandlerContainer.cs @@ -11,7 +11,7 @@ namespace Telegrator.Handlers /// Provides access to the update, client, filters, and other execution context. /// /// The type of update being handled. - public class AbstractHandlerContainer : IAbstractHandlerContainer where TUpdate : class + public class HandlerContainer : IHandlerContainer where TUpdate : class { /// /// Gets the actual update object of type TUpdate. @@ -34,10 +34,10 @@ namespace Telegrator.Handlers public IAwaitingProvider AwaitingProvider { get; } /// - /// Initializes new instance of + /// Initializes new instance of /// /// - public AbstractHandlerContainer(DescribedHandlerInfo handlerInfo) + public HandlerContainer(DescribedHandlerInfo handlerInfo) { ActualUpdate = handlerInfo.HandlingUpdate.GetActualUpdateObject(); HandlingUpdate = handlerInfo.HandlingUpdate; @@ -48,7 +48,7 @@ namespace Telegrator.Handlers } /// - /// Initializes new instance of + /// Initializes new instance of /// /// /// @@ -56,7 +56,7 @@ namespace Telegrator.Handlers /// /// /// - public AbstractHandlerContainer(TUpdate actualUpdate, Update handlingUpdate, ITelegramBotClient client, Dictionary extraData, CompletedFiltersList filters, IAwaitingProvider awaitingProvider) + public HandlerContainer(TUpdate actualUpdate, Update handlingUpdate, ITelegramBotClient client, Dictionary extraData, CompletedFiltersList filters, IAwaitingProvider awaitingProvider) { ActualUpdate = actualUpdate; HandlingUpdate = handlingUpdate; @@ -71,9 +71,9 @@ namespace Telegrator.Handlers /// /// /// - public AbstractHandlerContainer CreateChild() where QUpdate : class + public HandlerContainer CreateChild() where QUpdate : class { - return new AbstractHandlerContainer( + return new HandlerContainer( HandlingUpdate.GetActualUpdateObject(), HandlingUpdate, Client, ExtraData, CompletedFilters, AwaitingProvider); @@ -85,9 +85,9 @@ namespace Telegrator.Handlers /// /// /// - public static AbstractHandlerContainer From(IAbstractHandlerContainer other) where QUpdate : class + public static HandlerContainer From(IHandlerContainer other) where QUpdate : class { - return new AbstractHandlerContainer( + return new HandlerContainer( other.HandlingUpdate.GetActualUpdateObject(), other.HandlingUpdate, other.Client, other.ExtraData, other.CompletedFilters, other.AwaitingProvider); diff --git a/Telegrator/Handlers/IAbstractHandlerContainer.cs b/Telegrator/Handlers/IHandlerContainer.cs similarity index 82% rename from Telegrator/Handlers/IAbstractHandlerContainer.cs rename to Telegrator/Handlers/IHandlerContainer.cs index 0cd91c6..c4cc4df 100644 --- a/Telegrator/Handlers/IAbstractHandlerContainer.cs +++ b/Telegrator/Handlers/IHandlerContainer.cs @@ -6,7 +6,7 @@ namespace Telegrator.Handlers /// Represents a handler container for a specific update type. /// /// The type of update handled by the container. - public interface IAbstractHandlerContainer : IHandlerContainer where TUpdate : class + public interface IHandlerContainer : IHandlerContainer where TUpdate : class { /// /// Gets the actual update object of type . diff --git a/Telegrator/Handlers/InlineQueryHandler.cs b/Telegrator/Handlers/InlineQueryHandler.cs index 1e65e56..d843f5d 100644 --- a/Telegrator/Handlers/InlineQueryHandler.cs +++ b/Telegrator/Handlers/InlineQueryHandler.cs @@ -26,12 +26,12 @@ namespace Telegrator.Handlers /// /// Handler container for the current update. /// - protected IAbstractHandlerContainer QueryContainer { get; private set; } = null!; + protected IHandlerContainer QueryContainer { get; private set; } = null!; /// /// Handler container for the current update. /// - protected IAbstractHandlerContainer ChosenContainer { get; private set; } = null!; + protected IHandlerContainer ChosenContainer { get; private set; } = null!; /// /// Incoming update of type . @@ -44,20 +44,20 @@ namespace Telegrator.Handlers protected ChosenInlineResult InputChosen { get; private set; } = null!; /// - public override async Task Execute(IAbstractHandlerContainer container, CancellationToken cancellation) + public override async Task Execute(IHandlerContainer container, CancellationToken cancellation) { switch (container.HandlingUpdate.Type) { case UpdateType.InlineQuery: { - QueryContainer = AbstractHandlerContainer.From(container); + QueryContainer = HandlerContainer.From(container); InputQuery = QueryContainer.ActualUpdate; return await Requested(QueryContainer, cancellation).ConfigureAwait(false); } case UpdateType.ChosenInlineResult: { - ChosenContainer = AbstractHandlerContainer.From(container); + ChosenContainer = HandlerContainer.From(container); InputChosen = ChosenContainer.ActualUpdate; return await Chosen(ChosenContainer, cancellation).ConfigureAwait(false); } @@ -73,7 +73,7 @@ namespace Telegrator.Handlers /// /// /// - public abstract Task Requested(IAbstractHandlerContainer container, CancellationToken cancellation); + public abstract Task Requested(IHandlerContainer container, CancellationToken cancellation); /// /// Executes handler logic if received update is @@ -81,7 +81,7 @@ namespace Telegrator.Handlers /// /// /// - public abstract Task Chosen(IAbstractHandlerContainer container, CancellationToken cancellation); + public abstract Task Chosen(IHandlerContainer container, CancellationToken cancellation); /// /// Answers inline query diff --git a/Telegrator/Handlers/MessageHandler.cs b/Telegrator/Handlers/MessageHandler.cs index 753feb5..6d1176e 100644 --- a/Telegrator/Handlers/MessageHandler.cs +++ b/Telegrator/Handlers/MessageHandler.cs @@ -88,7 +88,7 @@ namespace Telegrator.Handlers /// /// The cancellation token. /// The sent message. - protected async Task Responce( + protected async Task Response( string text, ParseMode parseMode = ParseMode.None, ReplyParameters? replyParameters = null, @@ -104,7 +104,7 @@ namespace Telegrator.Handlers int? directMessageTopicId = null, SuggestedPostParameters? suggestedPostParameters = null, CancellationToken cancellationToken = default) - => await Container.Responce( + => await Container.Response( text, parseMode, replyParameters, replyMarkup, linkPreviewOptions, messageThreadId, entities, @@ -197,7 +197,7 @@ namespace Telegrator.Handlers int? directMessageTopicId = null, SuggestedPostParameters? suggestedPostParameters = null, CancellationToken cancellationToken = default) - => await Container.Responce( + => await Container.Response( text, parseMode, replyParameters, replyMarkup, linkPreviewOptions, messageThreadId, entities, diff --git a/Telegrator/Handlers/TypesExtensions.cs b/Telegrator/Handlers/TypesExtensions.cs index 9d1ba9f..f473b02 100644 --- a/Telegrator/Handlers/TypesExtensions.cs +++ b/Telegrator/Handlers/TypesExtensions.cs @@ -20,7 +20,7 @@ namespace Telegrator.Handlers /// /// public static async Task React( - this IAbstractHandlerContainer container, + this IHandlerContainer container, ReactionType reaction, bool isBig = false, CancellationToken cancellationToken = default) @@ -38,7 +38,7 @@ namespace Telegrator.Handlers /// /// public static async Task React( - this IAbstractHandlerContainer container, + this IHandlerContainer container, IEnumerable reactions, bool isBig = false, CancellationToken cancellationToken = default) @@ -67,7 +67,7 @@ namespace Telegrator.Handlers /// The cancellation token. /// The sent message. public static async Task Reply( - this IAbstractHandlerContainer container, + this IHandlerContainer container, string text, ParseMode parseMode = ParseMode.None, ReplyMarkup? replyMarkup = null, @@ -111,8 +111,8 @@ namespace Telegrator.Handlers /// /// The cancellation token. /// The sent message. - public static async Task Responce( - this IAbstractHandlerContainer container, + public static async Task Response( + this IHandlerContainer container, string text, ParseMode parseMode = ParseMode.None, ReplyParameters? replyParameters = null, @@ -158,8 +158,8 @@ namespace Telegrator.Handlers /// /// /// - public static async Task Responce( - this IAbstractHandlerContainer container, + public static async Task Response( + this IHandlerContainer container, string text, ParseMode parseMode = ParseMode.None, ReplyParameters? replyParameters = null, @@ -203,7 +203,7 @@ namespace Telegrator.Handlers /// /// public static async Task EditMessage( - this IAbstractHandlerContainer container, + this IHandlerContainer container, string text, ParseMode parseMode = ParseMode.None, InlineKeyboardMarkup? replyMarkup = null, @@ -243,7 +243,7 @@ namespace Telegrator.Handlers /// /// public static async Task AnswerCallbackQuery( - this IAbstractHandlerContainer container, + this IHandlerContainer container, string? text = null, bool showAlert = false, string? url = null, @@ -269,7 +269,7 @@ namespace Telegrator.Handlers /// /// public static async Task AnswerInlineQuery( - this IAbstractHandlerContainer container, + this IHandlerContainer container, IEnumerable results, int? cacheTime = null, bool isPersonal = false, diff --git a/Telegrator/MadiatorCore/Descriptors/DefaultCustomDescriptors.cs b/Telegrator/MadiatorCore/Descriptors/DefaultCustomDescriptors.cs index b34f4b4..c2d7896 100644 --- a/Telegrator/MadiatorCore/Descriptors/DefaultCustomDescriptors.cs +++ b/Telegrator/MadiatorCore/Descriptors/DefaultCustomDescriptors.cs @@ -46,7 +46,7 @@ namespace Telegrator.MadiatorCore.Descriptors { internal MethodInfo Method = null!; - public override async Task Execute(IAbstractHandlerContainer container, CancellationToken cancellation) + public override async Task Execute(IHandlerContainer container, CancellationToken cancellation) { if (Method is null) throw new Exception(); diff --git a/Telegrator/SimpleTypesExtensions.cs b/Telegrator/SimpleTypesExtensions.cs index 06374c9..30bbdcd 100644 --- a/Telegrator/SimpleTypesExtensions.cs +++ b/Telegrator/SimpleTypesExtensions.cs @@ -129,16 +129,6 @@ namespace Telegrator return -1; } - /// - /// Returns an enumerable that repeats the item multiple times. - /// - /// - /// - /// - /// - public static IEnumerable Repeat(this T item, int times) - => Enumerable.Range(0, times).Select(_ => item); - /// /// Returns the only element of a sequence, or a default value if the sequence is empty. /// This method returns default if there is more than one element in the sequence.