Skip to content

Commit fa7f9f5

Browse files
author
Igor Evdokimov
committed
- ChainStateKeeper as a workaround for starting/ending an input chain
1 parent b526e6b commit fa7f9f5

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System.Collections.Concurrent;
2+
3+
namespace Botticelli.Framework.Commands.Processors;
4+
5+
public static class ChainStateKeeper
6+
{
7+
private static readonly ConcurrentDictionary<string, bool> IsChainOpened = new();
8+
9+
public static bool GetState(string chatId) => IsChainOpened.TryGetValue(chatId, out var isChainOpened) && isChainOpened;
10+
11+
public static void SetState(string chatId, bool isChainOpened) => IsChainOpened[chatId] = isChainOpened;
12+
13+
public static void SetState(IEnumerable<string> chatIds, bool isChainOpened)
14+
{
15+
foreach (var chatId in chatIds) SetState(chatId, isChainOpened);
16+
}
17+
}

Botticelli.Framework/Commands/Processors/WaitForClientResponseCommandChainProcessor.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System.Collections.Concurrent;
21
using Botticelli.Client.Analytics;
32
using Botticelli.Framework.Commands.Validators;
43
using Botticelli.Interfaces;
@@ -8,20 +7,6 @@
87

98
namespace Botticelli.Framework.Commands.Processors;
109

11-
public static class ChainStateKeeper
12-
{
13-
private static readonly ConcurrentDictionary<string, bool> IsChainOpened = new();
14-
15-
public static bool GetState(string chatId) => IsChainOpened.TryGetValue(chatId, out var isChainOpened) && isChainOpened;
16-
17-
public static void SetState(string chatId, bool isChainOpened) => IsChainOpened[chatId] = isChainOpened;
18-
19-
public static void SetState(IEnumerable<string> chatIds, bool isChainOpened)
20-
{
21-
foreach (var chatId in chatIds) SetState(chatId, isChainOpened);
22-
}
23-
}
24-
2510
/// <summary>
2611
/// A command with waiting for a response
2712
/// </summary>

0 commit comments

Comments
 (0)