BotSharp/src/Infrastructure/BotSharp.Abstraction/Conversations/Models/StateKeyValue.cs

62 lines
1.5 KiB
C#
Raw Normal View History

2024-04-02 16:38:18 +00:00
using BotSharp.Abstraction.Conversations.Enums;
2023-09-09 21:44:25 +00:00
namespace BotSharp.Abstraction.Conversations.Models;
public class StateKeyValue
{
public string Key { get; set; }
2024-03-26 21:57:13 +00:00
public bool Versioning { get; set; }
2024-04-02 20:39:14 +00:00
public bool Readonly { get; set; }
2024-01-02 17:40:08 +00:00
public List<StateValue> Values { get; set; } = new List<StateValue>();
2023-09-09 21:44:25 +00:00
public StateKeyValue()
{
}
2024-01-02 17:40:08 +00:00
public StateKeyValue(string key, List<StateValue> values)
2023-09-09 21:44:25 +00:00
{
Key = key;
2024-01-02 17:40:08 +00:00
Values = values;
2023-09-09 21:44:25 +00:00
}
2024-04-02 16:38:18 +00:00
public override string ToString()
{
var lastValue = Values.LastOrDefault();
return $"{Key} => ({lastValue?.ToString()})";
}
2023-09-09 21:44:25 +00:00
}
2024-01-02 17:40:08 +00:00
public class StateValue
{
public string Data { get; set; }
2024-03-26 22:09:49 +00:00
2024-03-26 21:57:13 +00:00
[JsonPropertyName("message_id")]
2024-03-27 18:50:27 +00:00
public string? MessageId { get; set; }
2024-03-26 22:09:49 +00:00
2024-03-26 21:57:13 +00:00
public bool Active { get; set; }
2024-03-26 22:09:49 +00:00
2024-03-27 18:50:27 +00:00
[JsonPropertyName("active_rounds")]
public int ActiveRounds { get; set; }
2024-04-02 16:38:18 +00:00
[JsonPropertyName("data_type")]
public string DataType { get; set; } = StateDataType.String;
[JsonPropertyName("source")]
public string Source { get; set; }
2024-03-26 21:57:13 +00:00
[JsonPropertyName("update_time")]
2024-01-02 17:40:08 +00:00
public DateTime UpdateTime { get; set; }
public StateValue()
{
}
2024-04-02 16:38:18 +00:00
public override string ToString()
{
var isActive = Active ? "Yes" : "No";
var activeRounds = ActiveRounds <= 0 ? "infinity" : ActiveRounds.ToString();
return $"Data: {Data}, Active: {isActive}, Active rounds: {activeRounds}, Source: {Source}";
}
2024-01-02 17:40:08 +00:00
}