mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-11-22 15:17:00 +01:00
Doc Fixes & Extensions (#2201)
* Add note on dispatcherhandlerstop to conversationhandler * Fine tune @run_async deprecation warning * Refine docs of JobQueue.jobs/get_jobs_by_name
This commit is contained in:
parent
ae9ce60b55
commit
ca04daf782
3 changed files with 9 additions and 4 deletions
|
@ -84,6 +84,8 @@ class ConversationHandler(Handler):
|
||||||
the conversation ends immediately after the execution of this callback function.
|
the conversation ends immediately after the execution of this callback function.
|
||||||
To end the conversation, the callback function must return :attr:`END` or ``-1``. To
|
To end the conversation, the callback function must return :attr:`END` or ``-1``. To
|
||||||
handle the conversation timeout, use handler :attr:`TIMEOUT` or ``-2``.
|
handle the conversation timeout, use handler :attr:`TIMEOUT` or ``-2``.
|
||||||
|
Finally, :class:`telegram.ext.DispatcherHandlerStop` can be used in conversations as described
|
||||||
|
in the corresponding documentation.
|
||||||
|
|
||||||
Note:
|
Note:
|
||||||
In each of the described collections of handlers, a handler may in turn be a
|
In each of the described collections of handlers, a handler may in turn be a
|
||||||
|
|
|
@ -67,8 +67,8 @@ def run_async(
|
||||||
@wraps(func)
|
@wraps(func)
|
||||||
def async_func(*args: Any, **kwargs: Any) -> Any:
|
def async_func(*args: Any, **kwargs: Any) -> Any:
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
'The @run_async decorator is deprecated. Use the `run_async` parameter of'
|
'The @run_async decorator is deprecated. Use the `run_async` parameter of '
|
||||||
'`Dispatcher.add_handler` or `Dispatcher.run_async` instead.',
|
'your Handler or `Dispatcher.run_async` instead.',
|
||||||
TelegramDeprecationWarning,
|
TelegramDeprecationWarning,
|
||||||
stacklevel=2,
|
stacklevel=2,
|
||||||
)
|
)
|
||||||
|
|
|
@ -498,11 +498,14 @@ class JobQueue:
|
||||||
self.scheduler.shutdown()
|
self.scheduler.shutdown()
|
||||||
|
|
||||||
def jobs(self) -> Tuple['Job', ...]:
|
def jobs(self) -> Tuple['Job', ...]:
|
||||||
"""Returns a tuple of all jobs that are currently in the ``JobQueue``."""
|
"""
|
||||||
|
Returns a tuple of all *pending/scheduled* jobs that are currently in the ``JobQueue``.
|
||||||
|
"""
|
||||||
return tuple(Job.from_aps_job(job, self) for job in self.scheduler.get_jobs())
|
return tuple(Job.from_aps_job(job, self) for job in self.scheduler.get_jobs())
|
||||||
|
|
||||||
def get_jobs_by_name(self, name: str) -> Tuple['Job', ...]:
|
def get_jobs_by_name(self, name: str) -> Tuple['Job', ...]:
|
||||||
"""Returns a tuple of jobs with the given name that are currently in the ``JobQueue``"""
|
"""Returns a tuple of all *pending/scheduled* jobs with the given name that are currently
|
||||||
|
in the ``JobQueue``"""
|
||||||
return tuple(job for job in self.jobs() if job.name == name)
|
return tuple(job for job in self.jobs() if job.name == name)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue