forked from SciSharp/BotSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConversationService.UpdateBreakpoint.cs
More file actions
43 lines (36 loc) · 1.45 KB
/
ConversationService.UpdateBreakpoint.cs
File metadata and controls
43 lines (36 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using BotSharp.Abstraction.Hooks;
using BotSharp.Abstraction.Infrastructures.Enums;
namespace BotSharp.Core.Conversations.Services;
public partial class ConversationService
{
public async Task UpdateBreakpoint(bool resetStates = false, string? reason = null, params string[] excludedStates)
{
var db = _services.GetRequiredService<IBotSharpRepository>();
var routingCtx = _services.GetRequiredService<IRoutingContext>();
var messageId = routingCtx.MessageId;
db.UpdateConversationBreakpoint(_conversationId, new ConversationBreakpoint
{
MessageId = messageId,
Breakpoint = DateTime.UtcNow,
Reason = reason
});
// Reset states
if (resetStates)
{
var states = _services.GetRequiredService<IConversationStateService>();
// keep language state
if (excludedStates == null) excludedStates = new string[] { };
if (!excludedStates.Contains(StateConst.LANGUAGE))
{
excludedStates = excludedStates.Append(StateConst.LANGUAGE).ToArray();
}
states.CleanStates(excludedStates);
}
var hooks = _services.GetHooksOrderByPriority<IConversationHook>(routingCtx.GetCurrentAgentId());
// Before executing functions
foreach (var hook in hooks)
{
await hook.OnBreakpointUpdated(_conversationId, resetStates);
}
}
}