From 365845f832026985558e7ee2778bdc41d5979bac Mon Sep 17 00:00:00 2001 From: AmirAbbas Date: Wed, 1 Nov 2023 13:59:26 +0330 Subject: [PATCH] [FEATURE] Add MiddlewareMessageLoop to BotBaseBuilder --- TelegramBotBase/Builder/BotBaseBuilder.cs | 6 ++++++ .../Builder/Interfaces/IMessageLoopSelectionStage.cs | 10 +++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/TelegramBotBase/Builder/BotBaseBuilder.cs b/TelegramBotBase/Builder/BotBaseBuilder.cs index ddbf4a8..e05242d 100644 --- a/TelegramBotBase/Builder/BotBaseBuilder.cs +++ b/TelegramBotBase/Builder/BotBaseBuilder.cs @@ -137,6 +137,12 @@ public class BotBaseBuilder : IAPIKeySelectionStage, IMessageLoopSelectionStage, return this; } + public IStartFormSelectionStage MiddlewareMessageLoop(Func messageLoopConfiguration) + { + _messageLoopFactory = messageLoopConfiguration(new MiddlewareBaseMessageLoop()); + + return this; + } public IStartFormSelectionStage MinimalMessageLoop() { diff --git a/TelegramBotBase/Builder/Interfaces/IMessageLoopSelectionStage.cs b/TelegramBotBase/Builder/Interfaces/IMessageLoopSelectionStage.cs index 21223e7..422aadc 100644 --- a/TelegramBotBase/Builder/Interfaces/IMessageLoopSelectionStage.cs +++ b/TelegramBotBase/Builder/Interfaces/IMessageLoopSelectionStage.cs @@ -1,4 +1,6 @@ -using TelegramBotBase.Interfaces; +using System; +using TelegramBotBase.Interfaces; +using TelegramBotBase.MessageLoops; namespace TelegramBotBase.Builder.Interfaces; @@ -12,6 +14,12 @@ public interface IMessageLoopSelectionStage IStartFormSelectionStage DefaultMessageLoop(); + /// + /// Choses a fully customizable middleware-based message loop. + /// + IStartFormSelectionStage MiddlewareMessageLoop(Func messageLoopConfiguration); + + /// /// Chooses a minimalistic message loop, which catches all update types and only calls the Load function. ///