-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Use datetime.timedelta
to Represent Time Periods
#4575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi, my class group and I want to work in this Issue. Group: |
@cuevasrja & friends if you're still interested, would you like to get started on this? I think it would be good to split this into two PRs, one for the Bot method arguments and one for the classes. Some additional pointers on both:
|
Hi @Bibo-Joshi , Sorry, we are coming back from vacation and now I am reading your message. Yes, not all of us will be able to participate but we are still interested in contributing to the project if possible even if it is not for an academic reason. |
No worries :) glad to hear that you'd like to contribute. In the meantime I've already created #4651 for the bot method part, but the class parameter/attribute part is still open. You're welcome to open a PR for that. Let me know if you have any questions. |
# Conflicts: # telegram/_bot.py # telegram/_utils/types.py # telegram/ext/_extbot.py
@cuevasrja how is it looking for your? Ideally, I'd still like to get this into a 21.x release, such that we can remove any deprecation shims in 23.0 |
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 passtotalseconds()
to TG. Convertingdtm.timedelta
toint
can probably be done in the internals ofBot
or requests so that it doesn't have to happen in each bot method.Classes
timedelta
support 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 oncetimedelta
is natively supported. Not overly clean …*_period
attributes 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.
The text was updated successfully, but these errors were encountered: