What kind of feature are you missing? Where do you notice a shortcoming of PTB?
Several Telegram Objects and methods currently contain fields/parameters with names \w+_period, wherer the integer value represents a time span in seconds.
Working with plain seconds is not very pythonic, just like working with posix timestamps isn't.
Describe the solution you'd like
In the long run, we should convert the attributes to timedelta objects and make the parameters accept timedelta objects.
Methods Parameters
This is realtively easy, simply accept timedelta as well as integers and pass totalseconds() to TG. Converting dtm.timedelta to int can probably be done in the internals of Bot or requests so that it doesn't have to happen in each bot method.
Classes
- Both attributes and arguments should only accept timedeltas in the long run.
- Since this is a breaking change, we should issue a warning for now about this changing in the future and encouraging users to harden their code against the change
- For making the
timedelta support available early, I have two ideas, both optional
We can provide a temporary property that returns the timedelta object (e.g. xy_period_timedelta). This would need to issue a warning stating that it will be removed once timedelta is natively supported. Not overly clean …
- We anyways need to make the
*_period attributes properties to issue the deprecation warning. We could use this and look for an environment variable, say PTB_TIMEDELTA. If set, we return the timedelta object, otherwise the int. → let's do this
Describe alternatives you've considered
No response
Additional context
Adding support for method parameters can be done independently of handling classes.
What kind of feature are you missing? Where do you notice a shortcoming of PTB?
Several Telegram Objects and methods currently contain fields/parameters with names
\w+_period, wherer the integer value represents a time span in seconds.Working with plain seconds is not very pythonic, just like working with posix timestamps isn't.
Describe the solution you'd like
In the long run, we should convert the attributes to
timedeltaobjects and make the parameters accept timedelta objects.Methods Parameters
This is realtively easy, simply accept
timedeltaas well as integers and passtotalseconds()to TG. Convertingdtm.timedeltatointcan probably be done in the internals ofBotor requests so that it doesn't have to happen in each bot method.Classes
timedeltasupport available early, I have two ideas,both optionalWe can provide a temporary property that returns the timedelta object (e.g.xy_period_timedelta). This would need to issue a warning stating that it will be removed oncetimedeltais natively supported. Not overly clean …*_periodattributes properties to issue the deprecation warning. We could use this and look for an environment variable, sayPTB_TIMEDELTA. If set, we return the timedelta object, otherwise theint. → let's do thisDescribe alternatives you've considered
No response
Additional context
Adding support for method parameters can be done independently of handling classes.