From ad7b3a41eb43212da1b5dd8abb91f637ee16ea86 Mon Sep 17 00:00:00 2001 From: "LAPTOP-3CFGGVOS\\rabbit" Date: Mon, 27 May 2024 21:17:50 +0800 Subject: [PATCH] optimize UpdateBreakpoint --- .../Conversations/IConversationService.cs | 3 ++- .../Services/ConversationService.UpdateBreakpoint.cs | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Infrastructure/BotSharp.Abstraction/Conversations/IConversationService.cs b/src/Infrastructure/BotSharp.Abstraction/Conversations/IConversationService.cs index 9df6ae7f..055db3cc 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Conversations/IConversationService.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Conversations/IConversationService.cs @@ -51,6 +51,7 @@ public interface IConversationService /// /// Whether to reset all states /// Append user init words + /// /// - Task UpdateBreakpoint(bool resetStates = false, string? reason = null); + Task UpdateBreakpoint(bool resetStates = false, string? reason = null, params string[] excludedStates); } diff --git a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.UpdateBreakpoint.cs b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.UpdateBreakpoint.cs index 1bee7b89..8f88f44f 100644 --- a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.UpdateBreakpoint.cs +++ b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.UpdateBreakpoint.cs @@ -22,7 +22,12 @@ public partial class ConversationService : IConversationService { var states = _services.GetRequiredService(); // keep language state - if(excludedStates.IsNullOrEmpty()) excludedStates = new string[] { StateConst.LANGUAGE }; + if (excludedStates == null) excludedStates = new string[] { }; + if (!excludedStates.Contains(StateConst.LANGUAGE)) + { + excludedStates = excludedStates.Append(StateConst.LANGUAGE).ToArray(); + } + states.CleanStates(excludedStates); }