Giter Site home page Giter Site logo

Comments (5)

WaffleLapkin avatar WaffleLapkin commented on June 8, 2024 1

I think what @HKalbasi is trying to highlight here is that dialogues are usually short lived, so in a lot of cases it does not matter much if we lose it. (the probability to loose it mid dialogue is lower because it's short lived, it can be redone easily for the same reason, etc)

from teloxide.

HKalbasi avatar HKalbasi commented on June 8, 2024 1

And it doesn't need to replace the current api, just complement it. For long dialogues or cases that persistence is very important, users can always use the current api.

from teloxide.

Hirrolot avatar Hirrolot commented on June 8, 2024 1

I think what @HKalbasi is trying to highlight here is that dialogues are usually short lived, so in a lot of cases it does not matter much if we lose it. (the probability to loose it mid dialogue is lower because it's short lived, it can be redone easily for the same reason, etc)

A sudden interruption of the control flow can still look like a bug though. If a bot has enough users, this will certainly be noticed at some point.

My other concern is having two alternative implementations of the same idea. What usually happens is that users prefer the nicer-looking solution, then (some part of users) stumble upon the limitations of the basic solution, then rewrite the logic to use the more advanced solution. We already have it in the form of REPLs/dispatcher. Having it also for dialogues/.await points means that once a user of the library decides to use state machines instead of .await, they will need to rewrite almost the whole bot logic (in addition to breaking library changes). Having FSM-based logic right from the beginning would thus save time long-term.

Other than that, I agree with @WaffleLapkin that we don't have the capacity to implement it anytime soon.

from teloxide.

Hirrolot avatar Hirrolot commented on June 8, 2024

In this way we store the state in the tokio task local variables, so we will lose it on bot restart. This tolerable in most cases, and sometimes even desired. We can always manually store things in the persistent storage in important checkpoints, and use this api for short dialogs.

Consider what happens when a bot gets restarted, which can happen due to some server error or if you decided to update the code. In this case, a user should not notice anything, but with the approach you've suggested the dialogue will be removed from memory and lost forever. From the point of a user, it'd look like a bug.

It's true that .await is much more readable and declarative though. In essence, .await can be described as a finite state machine (I remember there even was a macro for that back in the old days). However, I wasn't able to figure out how to exploit .await to make it compatible with persistent dialogues.

Also, the approach of saving the dialogue state in certain points is error-prone -- we can just forget to do that. On the other hand, the current approach with FSMs does it automatically behind the scenes.

from teloxide.

WaffleLapkin avatar WaffleLapkin commented on June 8, 2024

I think my biggest concern here is that this requires quite a bit of design & implementation work. Given our capacity I don't think we'll be able to get to it anytime soon.

But it does look like with enough work & workarounds, this should be possible to implement. So, maybe one day :)

from teloxide.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.