SKitLs Stateful
Sargeras02 edited this page Jul 25, 2023
·
3 revisions
Status: Released
Allows you to define Stateful Users and split your logic into independent parts, that would be executed only if user's state matches action condition.
dotnet add package SKitLs.Bots.Telegram.Stateful
Just use StatefulActionManager
instead of Linear one:
// Basic realization
var privateText = new DefaultSignedMessageTextUpdateHandler();
// Default Action Manager
var commandsManager = new DefaultActionManager<SignedMessageTextUpdate>();
// other code...
privateText.CommandsManager = commandsManager;
var privateMessages = new DefaultSignedMessageUpdateHandler();
privateMessages.TextMessageUpdateHandler = privateText;
// Advanced realization
var privateCallbacks = new DefaultCallbackHandler();
// Stateful Action Manager
var statefulCallbacks = new DefaultStatefulManager<SignedCallbackUpdate>();
// other code...
privateCallbacks.CallbackManager = statefulCallbacks;
// Defining
ChatDesigner privates = ChatDesigner.NewDesigner()
.UseMessageHandler(privateMessages)
.UseCallbackHandler(privateCallbacks);
If you don't understand how this or that thing works, please share your problem in discussion.