MajMcCloud / TelegramBotFramework

This is a context based application framework for the C# TelegramBot library.
https://www.t.me/tgbotbase
MIT License
149 stars 43 forks source link

How can i serialize state of controls? #42

Closed bretbas closed 1 year ago

bretbas commented 1 year ago

How can i serialize state of controls? For example CalendarPicker? I create autoclean messaged bot and when i restart the app i can't restore message of CalendarPicker for clean it

MajMcCloud commented 1 year ago

Use the notes below for custom serialization: https://github.com/MajMcCloud/TelegramBotFramework#istateform

bretbas commented 1 year ago

Yes, but its problem, because in my Opened handler of some my forms, I added controls. And when deserialization in IStateForm i can restore this controls, BUT Opened handler invoked too Therefore i have 2 and more the same controls in the form...

MajMcCloud commented 1 year ago

why restore the full controls ? Just restore the MessageId of the control. And load it when Opened handler got invoked.

bretbas commented 1 year ago

And how i can pass the MessageId to your CalendarPicker?

MajMcCloud commented 1 year ago

There is a MessageId property where you can set it. It is currently private but you can change the source to test it.

MajMcCloud commented 1 year ago

There is now a prerelease version which addresses the MessageId property. https://www.nuget.org/packages/TelegramBotBase/5.3.1-alpha