diff --git a/.gitignore b/.gitignore
index a8546f7..1038af7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -362,3 +362,4 @@ MigrationBackup/
# Fody - auto-generated XML schema
FodyWeavers.xsd
/GETTING_STARTED.md
+/ANNOTATION_OVERVIEW.md
diff --git a/Telegrator/Handlers/CallbackQueryHandler.cs b/Telegrator/Handlers/CallbackQueryHandler.cs
index 9c5ae19..0d6d9fa 100644
--- a/Telegrator/Handlers/CallbackQueryHandler.cs
+++ b/Telegrator/Handlers/CallbackQueryHandler.cs
@@ -110,7 +110,7 @@ namespace Telegrator.Handlers
/// A URL that will be opened by the client.
/// The maximum amount of time in seconds that the result of the callback query may be cached client-side.
/// The cancellation token.
- protected async Task AnswerCallbackQuery(
+ protected async Task Answer(
string? text = null,
bool showAlert = false,
string? url = null,
diff --git a/Telegrator/StateKeeping/Components/StateKeeperBase.cs b/Telegrator/StateKeeping/Components/StateKeeperBase.cs
index 8f0b84b..e2e0193 100644
--- a/Telegrator/StateKeeping/Components/StateKeeperBase.cs
+++ b/Telegrator/StateKeeping/Components/StateKeeperBase.cs
@@ -26,7 +26,7 @@ namespace Telegrator.StateKeeping.Components
///
/// The update to use as a key source.
/// The new state value.
- public void SetState(Update keySource, TState newState)
+ public virtual void SetState(Update keySource, TState newState)
{
TKey key = KeyResolver.ResolveKey(keySource);
States.Set(key, newState, DefaultState);
@@ -37,7 +37,7 @@ namespace Telegrator.StateKeeping.Components
///
/// The update to use as a key source.
/// The state value.
- public TState GetState(Update keySource)
+ public virtual TState GetState(Update keySource)
{
TKey key = KeyResolver.ResolveKey(keySource);
return States[key];
@@ -49,7 +49,7 @@ namespace Telegrator.StateKeeping.Components
/// The update to use as a key source.
/// When this method returns, contains the state value if found; otherwise, the default value.
/// True if the state was found; otherwise, false.
- public bool TryGetState(Update keySource, out TState? state)
+ public virtual bool TryGetState(Update keySource, out TState? state)
{
TKey key = KeyResolver.ResolveKey(keySource);
return States.TryGetValue(key, out state);
@@ -60,7 +60,7 @@ namespace Telegrator.StateKeeping.Components
///
/// The update to use as a key source.
/// True if the state exists; otherwise, false.
- public bool HasState(Update keySource)
+ public virtual bool HasState(Update keySource)
{
TKey key = KeyResolver.ResolveKey(keySource);
return States.ContainsKey(key);
@@ -70,7 +70,7 @@ namespace Telegrator.StateKeeping.Components
/// Creates a state for the specified update using the default state value.
///
/// The update to use as a key source.
- public void CreateState(Update keySource)
+ public virtual void CreateState(Update keySource)
{
TKey key = KeyResolver.ResolveKey(keySource);
States.Set(key, DefaultState);
@@ -80,7 +80,7 @@ namespace Telegrator.StateKeeping.Components
/// Deletes the state for the specified update.
///
/// The update to use as a key source.
- public void DeleteState(Update keySource)
+ public virtual void DeleteState(Update keySource)
{
TKey key = KeyResolver.ResolveKey(keySource);
States.Remove(key);
@@ -90,7 +90,7 @@ namespace Telegrator.StateKeeping.Components
/// Moves the state forward for the specified update.
///
/// The update to use as a key source.
- public void MoveForward(Update keySource)
+ public virtual void MoveForward(Update keySource)
{
TKey key = KeyResolver.ResolveKey(keySource);
if (!States.TryGetValue(key, out TState currentState))
@@ -107,22 +107,29 @@ namespace Telegrator.StateKeeping.Components
/// Moves the state backward for the specified update.
///
/// The update to use as a key source.
- public void MoveBackward(Update keySource)
+ public virtual void MoveBackward(Update keySource)
{
TKey key = KeyResolver.ResolveKey(keySource);
- TState currentState = States[key];
+ if (!States.TryGetValue(key, out TState currentState))
+ {
+ States.Set(key, DefaultState);
+ return;
+ }
+
TState newState = MoveBackward(currentState, key);
States[key] = newState;
}
+ /*
///
/// Gets the state keeper for the specified key.
///
/// The type of the state keeper.
/// The key.
/// The state keeper instance.
- protected TStateKeeper GetKeeper(TKey key) where TStateKeeper : StateKeeperBase
+ protected virtual TStateKeeper GetKeeper(TKey key) where TStateKeeper : StateKeeperBase
=> States[key] as TStateKeeper ?? throw new InvalidCastException();
+ */
///
/// Moves the state forward for the specified current state and key.
diff --git a/Telegrator/StateKeeping/StringStateKeeper.cs b/Telegrator/StateKeeping/StringStateKeeper.cs
index 67e7382..8c8fc5a 100644
--- a/Telegrator/StateKeeping/StringStateKeeper.cs
+++ b/Telegrator/StateKeeping/StringStateKeeper.cs
@@ -1,25 +1,30 @@
using Telegrator.Annotations.StateKeeping;
using Telegrator.Handlers.Components;
+using Telegrator.StateKeeping.Components;
namespace Telegrator.StateKeeping
{
///
/// State keeper that manages string-based states for chat sessions.
- /// Inherits from with long keys and string states.
///
- /// Initial array of string states to manage
- public class StringStateKeeper(params string[] states) : ArrayStateKeeper(states)
+ public class StringStateKeeper() : StateKeeperBase()
{
- ///
- /// Initializes a new instance of with an empty state array.
- ///
- public StringStateKeeper()
- : this([]) { }
-
///
/// Gets the default state value, which is an empty string.
///
public override string DefaultState => string.Empty;
+
+ ///
+ protected override string MoveBackward(string currentState, string currentKey)
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ protected override string MoveForward(string currentState, string currentKey)
+ {
+ throw new NotImplementedException();
+ }
}
///
@@ -58,6 +63,10 @@ namespace Telegrator.StateKeeping
public static void SetStringState(this IHandlerContainer container, string? newState)
=> container.StringStateKeeper().SetState(container.HandlingUpdate, newState ?? StringStateAttribute.DefaultState);
+ public static string GetStringState(this IHandlerContainer container, string key)
+ => container.StringStateKeeper().GetState()
+
+ /*
///
/// Moves the string state forward to the next state in the sequence.
///
@@ -71,5 +80,6 @@ namespace Telegrator.StateKeeping
/// The handler container instance
public static void BackwardStringState(this IHandlerContainer container)
=> container.StringStateKeeper().MoveBackward(container.HandlingUpdate);
+ */
}
}