* Render-fixes for BP

* docs: fix simple typo, submition -> submission (#2260)

There is a small typo in tests/test_bot.py.

Should read `submission` rather than `submition`.

* Type on rawapibot.py docstring

* typo

* Typo: Filters.document(s)

* Typo fix

* Doc fix for messageentity (#2311)

* Add New Shortcuts to Chat (#2291)

* Add shortcuts

* Add a note

* Add run_async Parameter to ConversationHandler (#2292)

* Add run_async parameter

* Update docstring

* Update test to explicitly specify parameter

* Fix test job queue

* Add version added tag to docs

* Update docstring

Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>

* Doc nitpicking

Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>

* Fix rendering in messageentity

Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: zeshuaro <joshuaystang@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>

* fix: type hints for TelegramError

changed :class:`telegram.TelegramError` to :class:`telegram.error.TelegramError`

* fix: the error can be more then just a Telegram error

* Doc fix for inlinekeyboardbutton.py

added missing colon which broke rendering

* fix: remove context argument and doc remark

look at us already being in post 12

* use rtd badge

* filters doc fixes

* fix some rendering

* Doc & Rendering fixes for helpers.py

Co-authored-by: Tim Gates <tim.gates@iress.com>
Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com>
Co-authored-by: zeshuaro <joshuaystang@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: Harshil <ilovebhagwan@gmail.com>
This commit is contained in:
Bibo-Joshi 2021-02-01 17:59:39 +01:00 committed by GitHub
parent 25506f131d
commit 36d49ea9cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 166 additions and 181 deletions

View file

@ -28,8 +28,8 @@ We have a vibrant community of developers helping each other in our `Telegram gr
:target: https://pypistats.org/packages/python-telegram-bot :target: https://pypistats.org/packages/python-telegram-bot
:alt: PyPi Package Monthly Download :alt: PyPi Package Monthly Download
.. image:: https://img.shields.io/badge/docs-latest-af1a97.svg .. image:: https://readthedocs.org/projects/python-telegram-bot/badge/?version=stable
:target: https://python-telegram-bot.readthedocs.io/ :target: https://python-telegram-bot.readthedocs.io/en/stable/?badge=stable
:alt: Documentation Status :alt: Documentation Status
.. image:: https://img.shields.io/pypi/l/python-telegram-bot.svg .. image:: https://img.shields.io/pypi/l/python-telegram-bot.svg

View file

@ -127,9 +127,7 @@ def cancel(update: Update, context: CallbackContext) -> int:
def main() -> None: def main() -> None:
# Create the Updater and pass it your bot's token. # Create the Updater and pass it your bot's token.
# Make sure to set use_context=True to use the new context based callbacks updater = Updater("TOKEN")
# Post version 12 this will no longer be necessary
updater = Updater("TOKEN", use_context=True)
# Get the dispatcher to register handlers # Get the dispatcher to register handlers
dispatcher = updater.dispatcher dispatcher = updater.dispatcher

View file

@ -112,9 +112,7 @@ def done(update: Update, context: CallbackContext) -> int:
def main() -> None: def main() -> None:
# Create the Updater and pass it your bot's token. # Create the Updater and pass it your bot's token.
# Make sure to set use_context=True to use the new context based callbacks updater = Updater("TOKEN")
# Post version 12 this will no longer be necessary
updater = Updater("TOKEN", use_context=True)
# Get the dispatcher to register handlers # Get the dispatcher to register handlers
dispatcher = updater.dispatcher dispatcher = updater.dispatcher

View file

@ -107,7 +107,7 @@ def deep_linked_level_4(update: Update, context: CallbackContext) -> None:
def main(): def main():
"""Start the bot.""" """Start the bot."""
# Create the Updater and pass it your bot's token. # Create the Updater and pass it your bot's token.
updater = Updater("TOKEN", use_context=True) updater = Updater("TOKEN")
# Get the dispatcher to register handlers # Get the dispatcher to register handlers
dispatcher = updater.dispatcher dispatcher = updater.dispatcher

View file

@ -49,9 +49,7 @@ def echo(update: Update, context: CallbackContext) -> None:
def main(): def main():
"""Start the bot.""" """Start the bot."""
# Create the Updater and pass it your bot's token. # Create the Updater and pass it your bot's token.
# Make sure to set use_context=True to use the new context based callbacks updater = Updater("TOKEN")
# Post version 12 this will no longer be necessary
updater = Updater("TOKEN", use_context=True)
# Get the dispatcher to register handlers # Get the dispatcher to register handlers
dispatcher = updater.dispatcher dispatcher = updater.dispatcher

View file

@ -67,9 +67,7 @@ def start(update: Update, context: CallbackContext) -> None:
def main(): def main():
# Create the Updater and pass it your bot's token. # Create the Updater and pass it your bot's token.
# Make sure to set use_context=True to use the new context based callbacks updater = Updater(BOT_TOKEN)
# Post version 12 this will no longer be necessary
updater = Updater(BOT_TOKEN, use_context=True)
# Get the dispatcher to register handlers # Get the dispatcher to register handlers
dispatcher = updater.dispatcher dispatcher = updater.dispatcher

View file

@ -68,9 +68,7 @@ def inlinequery(update: Update, context: CallbackContext) -> None:
def main() -> None: def main() -> None:
# Create the Updater and pass it your bot's token. # Create the Updater and pass it your bot's token.
# Make sure to set use_context=True to use the new context based callbacks updater = Updater("TOKEN")
# Post version 12 this will no longer be necessary
updater = Updater("TOKEN", use_context=True)
# Get the dispatcher to register handlers # Get the dispatcher to register handlers
dispatcher = updater.dispatcher dispatcher = updater.dispatcher

View file

@ -47,9 +47,7 @@ def help_command(update: Update, context: CallbackContext) -> None:
def main(): def main():
# Create the Updater and pass it your bot's token. # Create the Updater and pass it your bot's token.
# Make sure to set use_context=True to use the new context based callbacks updater = Updater("TOKEN")
# Post version 12 this will no longer be necessary
updater = Updater("TOKEN", use_context=True)
updater.dispatcher.add_handler(CommandHandler('start', start)) updater.dispatcher.add_handler(CommandHandler('start', start))
updater.dispatcher.add_handler(CallbackQueryHandler(button)) updater.dispatcher.add_handler(CallbackQueryHandler(button))

View file

@ -161,7 +161,7 @@ def end(update: Update, context: CallbackContext) -> None:
def main(): def main():
# Create the Updater and pass it your bot's token. # Create the Updater and pass it your bot's token.
updater = Updater("TOKEN", use_context=True) updater = Updater("TOKEN")
# Get the dispatcher to register handlers # Get the dispatcher to register handlers
dispatcher = updater.dispatcher dispatcher = updater.dispatcher

View file

@ -301,9 +301,7 @@ def stop_nested(update: Update, context: CallbackContext) -> None:
def main(): def main():
# Create the Updater and pass it your bot's token. # Create the Updater and pass it your bot's token.
# Make sure to set use_context=True to use the new context based callbacks updater = Updater("TOKEN")
# Post version 12 this will no longer be necessary
updater = Updater("TOKEN", use_context=True)
# Get the dispatcher to register handlers # Get the dispatcher to register handlers
dispatcher = updater.dispatcher dispatcher = updater.dispatcher

View file

@ -127,9 +127,7 @@ def successful_payment_callback(update: Update, context: CallbackContext) -> Non
def main(): def main():
# Create the Updater and pass it your bot's token. # Create the Updater and pass it your bot's token.
# Make sure to set use_context=True to use the new context based callbacks updater = Updater("TOKEN")
# Post version 12 this will no longer be necessary
updater = Updater("TOKEN", use_context=True)
# Get the dispatcher to register handlers # Get the dispatcher to register handlers
dispatcher = updater.dispatcher dispatcher = updater.dispatcher

View file

@ -130,7 +130,7 @@ def done(update: Update, context: CallbackContext) -> None:
def main(): def main():
# Create the Updater and pass it your bot's token. # Create the Updater and pass it your bot's token.
pp = PicklePersistence(filename='conversationbot') pp = PicklePersistence(filename='conversationbot')
updater = Updater("TOKEN", persistence=pp, use_context=True) updater = Updater("TOKEN", persistence=pp)
# Get the dispatcher to register handlers # Get the dispatcher to register handlers
dp = updater.dispatcher dp = updater.dispatcher

View file

@ -153,9 +153,7 @@ def help_handler(update: Update, context: CallbackContext) -> None:
def main() -> None: def main() -> None:
# Create the Updater and pass it your bot's token. # Create the Updater and pass it your bot's token.
# Make sure to set use_context=True to use the new context based callbacks updater = Updater("TOKEN")
# Post version 12 this will no longer be necessary
updater = Updater("TOKEN", use_context=True)
dispatcher = updater.dispatcher dispatcher = updater.dispatcher
dispatcher.add_handler(CommandHandler('start', start)) dispatcher.add_handler(CommandHandler('start', start))
dispatcher.add_handler(CommandHandler('poll', poll)) dispatcher.add_handler(CommandHandler('poll', poll))

View file

@ -2,7 +2,7 @@
# pylint: disable=W0603 # pylint: disable=W0603
"""Simple Bot to reply to Telegram messages. """Simple Bot to reply to Telegram messages.
This is built on the API wrapper, see rawapibot.py to see the same example built This is built on the API wrapper, see echobot.py to see the same example built
on the telegram.ext bot framework. on the telegram.ext bot framework.
This program is dedicated to the public domain under the CC0 license. This program is dedicated to the public domain under the CC0 license.
""" """

View file

@ -87,9 +87,7 @@ def unset(update: Update, context: CallbackContext) -> None:
def main(): def main():
"""Run bot.""" """Run bot."""
# Create the Updater and pass it your bot's token. # Create the Updater and pass it your bot's token.
# Make sure to set use_context=True to use the new context based callbacks updater = Updater("TOKEN")
# Post version 12 this will no longer be necessary
updater = Updater("TOKEN", use_context=True)
# Get the dispatcher to register handlers # Get the dispatcher to register handlers
dispatcher = updater.dispatcher dispatcher = updater.dispatcher

View file

@ -377,7 +377,7 @@ class Bot(TelegramObject):
credentials are valid, :obj:`None` otherwise. credentials are valid, :obj:`None` otherwise.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
result = self._post('getMe', timeout=timeout, api_kwargs=api_kwargs) result = self._post('getMe', timeout=timeout, api_kwargs=api_kwargs)
@ -434,7 +434,7 @@ class Bot(TelegramObject):
:class:`telegram.Message`: On success, the sent message is returned. :class:`telegram.Message`: On success, the sent message is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'chat_id': chat_id, 'text': text} data: JSONDict = {'chat_id': chat_id, 'text': text}
@ -493,7 +493,7 @@ class Bot(TelegramObject):
:obj:`bool`: On success, :obj:`True` is returned. :obj:`bool`: On success, :obj:`True` is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'chat_id': chat_id, 'message_id': message_id} data: JSONDict = {'chat_id': chat_id, 'message_id': message_id}
@ -532,7 +532,7 @@ class Bot(TelegramObject):
:class:`telegram.Message`: On success, the sent Message is returned. :class:`telegram.Message`: On success, the sent Message is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {} data: JSONDict = {}
@ -616,7 +616,7 @@ class Bot(TelegramObject):
:class:`telegram.Message`: On success, the sent Message is returned. :class:`telegram.Message`: On success, the sent Message is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = { data: JSONDict = {
@ -729,7 +729,7 @@ class Bot(TelegramObject):
:class:`telegram.Message`: On success, the sent Message is returned. :class:`telegram.Message`: On success, the sent Message is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = { data: JSONDict = {
@ -842,7 +842,7 @@ class Bot(TelegramObject):
:class:`telegram.Message`: On success, the sent Message is returned. :class:`telegram.Message`: On success, the sent Message is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = { data: JSONDict = {
@ -920,7 +920,7 @@ class Bot(TelegramObject):
:class:`telegram.Message`: On success, the sent Message is returned. :class:`telegram.Message`: On success, the sent Message is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'chat_id': chat_id, 'sticker': parse_file_input(sticker, Sticker)} data: JSONDict = {'chat_id': chat_id, 'sticker': parse_file_input(sticker, Sticker)}
@ -1027,7 +1027,7 @@ class Bot(TelegramObject):
:class:`telegram.Message`: On success, the sent Message is returned. :class:`telegram.Message`: On success, the sent Message is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = { data: JSONDict = {
@ -1136,7 +1136,7 @@ class Bot(TelegramObject):
:class:`telegram.Message`: On success, the sent Message is returned. :class:`telegram.Message`: On success, the sent Message is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = { data: JSONDict = {
@ -1246,7 +1246,7 @@ class Bot(TelegramObject):
:class:`telegram.Message`: On success, the sent Message is returned. :class:`telegram.Message`: On success, the sent Message is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = { data: JSONDict = {
@ -1350,7 +1350,7 @@ class Bot(TelegramObject):
:class:`telegram.Message`: On success, the sent Message is returned. :class:`telegram.Message`: On success, the sent Message is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = { data: JSONDict = {
@ -1413,7 +1413,7 @@ class Bot(TelegramObject):
List[:class:`telegram.Message`]: An array of the sent Messages. List[:class:`telegram.Message`]: An array of the sent Messages.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'chat_id': chat_id, 'media': media} data: JSONDict = {'chat_id': chat_id, 'media': media}
@ -1496,7 +1496,7 @@ class Bot(TelegramObject):
:class:`telegram.Message`: On success, the sent Message is returned. :class:`telegram.Message`: On success, the sent Message is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
if not ((latitude is not None and longitude is not None) or location): if not ((latitude is not None and longitude is not None) or location):
@ -1739,7 +1739,7 @@ class Bot(TelegramObject):
:class:`telegram.Message`: On success, the sent Message is returned. :class:`telegram.Message`: On success, the sent Message is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
if not (venue or all([latitude, longitude, address, title])): if not (venue or all([latitude, longitude, address, title])):
@ -1836,7 +1836,7 @@ class Bot(TelegramObject):
:class:`telegram.Message`: On success, the sent Message is returned. :class:`telegram.Message`: On success, the sent Message is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
if (not contact) and (not all([phone_number, first_name])): if (not contact) and (not all([phone_number, first_name])):
@ -1910,7 +1910,7 @@ class Bot(TelegramObject):
:class:`telegram.Message`: On success, the sent Message is returned. :class:`telegram.Message`: On success, the sent Message is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'chat_id': chat_id, 'game_short_name': game_short_name} data: JSONDict = {'chat_id': chat_id, 'game_short_name': game_short_name}
@ -1956,7 +1956,7 @@ class Bot(TelegramObject):
:obj:`bool`: On success, :obj:`True` is returned. :obj:`bool`: On success, :obj:`True` is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'chat_id': chat_id, 'action': action} data: JSONDict = {'chat_id': chat_id, 'action': action}
@ -1995,8 +1995,8 @@ class Bot(TelegramObject):
results (List[:class:`telegram.InlineQueryResult`] | Callable): A list of results for results (List[:class:`telegram.InlineQueryResult`] | Callable): A list of results for
the inline query. In case :attr:`current_offset` is passed, ``results`` may also be the inline query. In case :attr:`current_offset` is passed, ``results`` may also be
a callable that accepts the current page index starting from 0. It must return a callable that accepts the current page index starting from 0. It must return
either a list of :class:`telegram.InlineResult` instances or :obj:`None` if there either a list of :class:`telegram.InlineQueryResult` instances or :obj:`None` if
are no more results. there are no more results.
cache_time (:obj:`int`, optional): The maximum amount of time in seconds that the cache_time (:obj:`int`, optional): The maximum amount of time in seconds that the
result of the inline query may be cached on the server. Defaults to 300. result of the inline query may be cached on the server. Defaults to 300.
is_personal (:obj:`bool`, optional): Pass :obj:`True`, if results may be cached on is_personal (:obj:`bool`, optional): Pass :obj:`True`, if results may be cached on
@ -2035,7 +2035,7 @@ class Bot(TelegramObject):
:obj:`bool`: On success, :obj:`True` is returned. :obj:`bool`: On success, :obj:`True` is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
@ -2151,7 +2151,7 @@ class Bot(TelegramObject):
:class:`telegram.UserProfilePhotos` :class:`telegram.UserProfilePhotos`
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'user_id': user_id} data: JSONDict = {'user_id': user_id}
@ -2204,7 +2204,7 @@ class Bot(TelegramObject):
:class:`telegram.File` :class:`telegram.File`
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
try: try:
@ -2259,7 +2259,7 @@ class Bot(TelegramObject):
:obj:`bool` On success, :obj:`True` is returned. :obj:`bool` On success, :obj:`True` is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'chat_id': chat_id, 'user_id': user_id} data: JSONDict = {'chat_id': chat_id, 'user_id': user_id}
@ -2307,7 +2307,7 @@ class Bot(TelegramObject):
:obj:`bool` On success, :obj:`True` is returned. :obj:`bool` On success, :obj:`True` is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'chat_id': chat_id, 'user_id': user_id} data: JSONDict = {'chat_id': chat_id, 'user_id': user_id}
@ -2364,7 +2364,7 @@ class Bot(TelegramObject):
:obj:`bool` On success, :obj:`True` is returned. :obj:`bool` On success, :obj:`True` is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'callback_query_id': callback_query_id} data: JSONDict = {'callback_query_id': callback_query_id}
@ -2428,7 +2428,7 @@ class Bot(TelegramObject):
edited message is returned, otherwise :obj:`True` is returned. edited message is returned, otherwise :obj:`True` is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'text': text} data: JSONDict = {'text': text}
@ -2499,7 +2499,7 @@ class Bot(TelegramObject):
edited message is returned, otherwise :obj:`True` is returned. edited message is returned, otherwise :obj:`True` is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
if inline_message_id is None and (chat_id is None or message_id is None): if inline_message_id is None and (chat_id is None or message_id is None):
@ -2572,7 +2572,7 @@ class Bot(TelegramObject):
edited Message is returned, otherwise :obj:`True` is returned. edited Message is returned, otherwise :obj:`True` is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
if inline_message_id is None and (chat_id is None or message_id is None): if inline_message_id is None and (chat_id is None or message_id is None):
@ -2633,7 +2633,7 @@ class Bot(TelegramObject):
edited message is returned, otherwise :obj:`True` is returned. edited message is returned, otherwise :obj:`True` is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
if inline_message_id is None and (chat_id is None or message_id is None): if inline_message_id is None and (chat_id is None or message_id is None):
@ -2705,7 +2705,7 @@ class Bot(TelegramObject):
List[:class:`telegram.Update`] List[:class:`telegram.Update`]
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'timeout': timeout} data: JSONDict = {'timeout': timeout}
@ -2807,7 +2807,7 @@ class Bot(TelegramObject):
:obj:`bool` On success, :obj:`True` is returned. :obj:`bool` On success, :obj:`True` is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
.. _`guide to Webhooks`: https://core.telegram.org/bots/webhooks .. _`guide to Webhooks`: https://core.telegram.org/bots/webhooks
@ -2852,7 +2852,7 @@ class Bot(TelegramObject):
:obj:`bool` On success, :obj:`True` is returned. :obj:`bool` On success, :obj:`True` is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data = {} data = {}
@ -2883,7 +2883,7 @@ class Bot(TelegramObject):
:obj:`bool` On success, :obj:`True` is returned. :obj:`bool` On success, :obj:`True` is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'chat_id': chat_id} data: JSONDict = {'chat_id': chat_id}
@ -2913,7 +2913,7 @@ class Bot(TelegramObject):
:class:`telegram.Chat` :class:`telegram.Chat`
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'chat_id': chat_id} data: JSONDict = {'chat_id': chat_id}
@ -2948,7 +2948,7 @@ class Bot(TelegramObject):
appointed, only the creator will be returned. appointed, only the creator will be returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'chat_id': chat_id} data: JSONDict = {'chat_id': chat_id}
@ -2976,7 +2976,7 @@ class Bot(TelegramObject):
:obj:`int`: Number of members in the chat. :obj:`int`: Number of members in the chat.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'chat_id': chat_id} data: JSONDict = {'chat_id': chat_id}
@ -3009,7 +3009,7 @@ class Bot(TelegramObject):
:class:`telegram.ChatMember` :class:`telegram.ChatMember`
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'chat_id': chat_id, 'user_id': user_id} data: JSONDict = {'chat_id': chat_id, 'user_id': user_id}
@ -3138,7 +3138,7 @@ class Bot(TelegramObject):
, :obj:`True`. , :obj:`True`.
Raises: Raises:
:class:`telegram.TelegramError`: If the new score is not greater than the user's :class:`telegram.error.TelegramError`: If the new score is not greater than the user's
current score in the chat and force is :obj:`False`. current score in the chat and force is :obj:`False`.
""" """
@ -3194,7 +3194,7 @@ class Bot(TelegramObject):
List[:class:`telegram.GameHighScore`] List[:class:`telegram.GameHighScore`]
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'user_id': user_id} data: JSONDict = {'user_id': user_id}
@ -3299,7 +3299,7 @@ class Bot(TelegramObject):
:class:`telegram.Message`: On success, the sent Message is returned. :class:`telegram.Message`: On success, the sent Message is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = { data: JSONDict = {
@ -3387,7 +3387,7 @@ class Bot(TelegramObject):
:obj:`bool`: On success, :obj:`True` is returned. :obj:`bool`: On success, :obj:`True` is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
ok = bool(ok) ok = bool(ok)
@ -3454,7 +3454,7 @@ class Bot(TelegramObject):
:obj:`bool`: On success, :obj:`True` is returned. :obj:`bool`: On success, :obj:`True` is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
ok = bool(ok) ok = bool(ok)
@ -3517,7 +3517,7 @@ class Bot(TelegramObject):
:obj:`bool`: On success, :obj:`True` is returned. :obj:`bool`: On success, :obj:`True` is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = { data: JSONDict = {
'chat_id': chat_id, 'chat_id': chat_id,
@ -3592,7 +3592,7 @@ class Bot(TelegramObject):
:obj:`bool`: On success, :obj:`True` is returned. :obj:`bool`: On success, :obj:`True` is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'chat_id': chat_id, 'user_id': user_id} data: JSONDict = {'chat_id': chat_id, 'user_id': user_id}
@ -3647,7 +3647,7 @@ class Bot(TelegramObject):
:obj:`bool`: On success, :obj:`True` is returned. :obj:`bool`: On success, :obj:`True` is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'chat_id': chat_id, 'permissions': permissions.to_dict()} data: JSONDict = {'chat_id': chat_id, 'permissions': permissions.to_dict()}
@ -3685,7 +3685,7 @@ class Bot(TelegramObject):
:obj:`bool`: On success, :obj:`True` is returned. :obj:`bool`: On success, :obj:`True` is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'chat_id': chat_id, 'user_id': user_id, 'custom_title': custom_title} data: JSONDict = {'chat_id': chat_id, 'user_id': user_id, 'custom_title': custom_title}
@ -3718,7 +3718,7 @@ class Bot(TelegramObject):
:obj:`str`: New invite link on success. :obj:`str`: New invite link on success.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'chat_id': chat_id} data: JSONDict = {'chat_id': chat_id}
@ -3757,7 +3757,7 @@ class Bot(TelegramObject):
:obj:`bool`: On success, :obj:`True` is returned. :obj:`bool`: On success, :obj:`True` is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'chat_id': chat_id, 'photo': parse_file_input(photo)} data: JSONDict = {'chat_id': chat_id, 'photo': parse_file_input(photo)}
@ -3788,7 +3788,7 @@ class Bot(TelegramObject):
:obj:`bool`: On success, :obj:`True` is returned. :obj:`bool`: On success, :obj:`True` is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'chat_id': chat_id} data: JSONDict = {'chat_id': chat_id}
@ -3824,7 +3824,7 @@ class Bot(TelegramObject):
:obj:`bool`: On success, :obj:`True` is returned. :obj:`bool`: On success, :obj:`True` is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'chat_id': chat_id, 'title': title} data: JSONDict = {'chat_id': chat_id, 'title': title}
@ -3860,7 +3860,7 @@ class Bot(TelegramObject):
:obj:`bool`: On success, :obj:`True` is returned. :obj:`bool`: On success, :obj:`True` is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'chat_id': chat_id, 'description': description} data: JSONDict = {'chat_id': chat_id, 'description': description}
@ -3901,7 +3901,7 @@ class Bot(TelegramObject):
:obj:`bool`: On success, :obj:`True` is returned. :obj:`bool`: On success, :obj:`True` is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'chat_id': chat_id, 'message_id': message_id} data: JSONDict = {'chat_id': chat_id, 'message_id': message_id}
@ -3942,7 +3942,7 @@ class Bot(TelegramObject):
:obj:`bool`: On success, :obj:`True` is returned. :obj:`bool`: On success, :obj:`True` is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'chat_id': chat_id} data: JSONDict = {'chat_id': chat_id}
@ -3980,7 +3980,7 @@ class Bot(TelegramObject):
:obj:`bool`: On success, :obj:`True` is returned. :obj:`bool`: On success, :obj:`True` is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
@ -4008,7 +4008,7 @@ class Bot(TelegramObject):
:class:`telegram.StickerSet` :class:`telegram.StickerSet`
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'name': name} data: JSONDict = {'name': name}
@ -4053,7 +4053,7 @@ class Bot(TelegramObject):
:class:`telegram.File`: On success, the uploaded File is returned. :class:`telegram.File`: On success, the uploaded File is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'user_id': user_id, 'png_sticker': parse_file_input(png_sticker)} data: JSONDict = {'user_id': user_id, 'png_sticker': parse_file_input(png_sticker)}
@ -4131,7 +4131,7 @@ class Bot(TelegramObject):
:obj:`bool`: On success, :obj:`True` is returned. :obj:`bool`: On success, :obj:`True` is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'user_id': user_id, 'name': name, 'title': title, 'emojis': emojis} data: JSONDict = {'user_id': user_id, 'name': name, 'title': title, 'emojis': emojis}
@ -4212,7 +4212,7 @@ class Bot(TelegramObject):
:obj:`bool`: On success, :obj:`True` is returned. :obj:`bool`: On success, :obj:`True` is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'user_id': user_id, 'name': name, 'emojis': emojis} data: JSONDict = {'user_id': user_id, 'name': name, 'emojis': emojis}
@ -4249,7 +4249,7 @@ class Bot(TelegramObject):
:obj:`bool`: On success, :obj:`True` is returned. :obj:`bool`: On success, :obj:`True` is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'sticker': sticker, 'position': position} data: JSONDict = {'sticker': sticker, 'position': position}
@ -4278,7 +4278,7 @@ class Bot(TelegramObject):
:obj:`bool`: On success, :obj:`True` is returned. :obj:`bool`: On success, :obj:`True` is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'sticker': sticker} data: JSONDict = {'sticker': sticker}
@ -4327,7 +4327,7 @@ class Bot(TelegramObject):
:obj:`bool`: On success, :obj:`True` is returned. :obj:`bool`: On success, :obj:`True` is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'name': name, 'user_id': user_id} data: JSONDict = {'name': name, 'user_id': user_id}
@ -4371,7 +4371,7 @@ class Bot(TelegramObject):
:obj:`bool`: On success, :obj:`True` is returned. :obj:`bool`: On success, :obj:`True` is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'user_id': user_id, 'errors': [error.to_dict() for error in errors]} data: JSONDict = {'user_id': user_id, 'errors': [error.to_dict() for error in errors]}
@ -4457,7 +4457,7 @@ class Bot(TelegramObject):
:class:`telegram.Message`: On success, the sent Message is returned. :class:`telegram.Message`: On success, the sent Message is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'chat_id': chat_id, 'question': question, 'options': options} data: JSONDict = {'chat_id': chat_id, 'question': question, 'options': options}
@ -4533,7 +4533,7 @@ class Bot(TelegramObject):
returned. returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = {'chat_id': chat_id, 'message_id': message_id} data: JSONDict = {'chat_id': chat_id, 'message_id': message_id}
@ -4591,7 +4591,7 @@ class Bot(TelegramObject):
:class:`telegram.Message`: On success, the sent Message is returned. :class:`telegram.Message`: On success, the sent Message is returned.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = { data: JSONDict = {
@ -4630,7 +4630,7 @@ class Bot(TelegramObject):
List[:class:`telegram.BotCommand]`: On success, the commands set for the bot List[:class:`telegram.BotCommand]`: On success, the commands set for the bot
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
result = self._post('getMyCommands', timeout=timeout, api_kwargs=api_kwargs) result = self._post('getMyCommands', timeout=timeout, api_kwargs=api_kwargs)
@ -4663,7 +4663,7 @@ class Bot(TelegramObject):
:obj:`True`: On success :obj:`True`: On success
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
cmds = [c if isinstance(c, BotCommand) else BotCommand(c[0], c[1]) for c in commands] cmds = [c if isinstance(c, BotCommand) else BotCommand(c[0], c[1]) for c in commands]
@ -4691,7 +4691,7 @@ class Bot(TelegramObject):
:obj:`True`: On success :obj:`True`: On success
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
return self._post('logOut') # type: ignore[return-value] return self._post('logOut') # type: ignore[return-value]
@ -4708,7 +4708,7 @@ class Bot(TelegramObject):
:obj:`True`: On success :obj:`True`: On success
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
return self._post('close') # type: ignore[return-value] return self._post('close') # type: ignore[return-value]
@ -4766,7 +4766,7 @@ class Bot(TelegramObject):
:class:`telegram.MessageId`: On success :class:`telegram.MessageId`: On success
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
data: JSONDict = { data: JSONDict = {
'chat_id': chat_id, 'chat_id': chat_id,

View file

@ -73,9 +73,8 @@ class CallbackContext:
is handled by :class:`telegram.ext.CommandHandler`, :class:`telegram.ext.PrefixHandler` is handled by :class:`telegram.ext.CommandHandler`, :class:`telegram.ext.PrefixHandler`
or :class:`telegram.ext.StringCommandHandler`. It contains a list of the words in the or :class:`telegram.ext.StringCommandHandler`. It contains a list of the words in the
text after the command, using any whitespace string as a delimiter. text after the command, using any whitespace string as a delimiter.
error (:class:`telegram.TelegramError`): Optional. The error that was raised. error (:obj:`Exception`): Optional. The error that was raised. Only present when passed
Only present when passed to a error handler registered with to a error handler registered with :attr:`telegram.ext.Dispatcher.add_error_handler`.
:attr:`telegram.ext.Dispatcher.add_error_handler`.
async_args (List[:obj:`object`]): Optional. Positional arguments of the function that async_args (List[:obj:`object`]): Optional. Positional arguments of the function that
raised the error. Only present when the raising function was run asynchronously using raised the error. Only present when the raising function was run asynchronously using
:meth:`telegram.ext.Dispatcher.run_async`. :meth:`telegram.ext.Dispatcher.run_async`.

View file

@ -407,12 +407,13 @@ class Dispatcher:
Note: Note:
If the update is handled by least one synchronously running handlers (i.e. If the update is handled by least one synchronously running handlers (i.e.
``run_async=False`), :meth:`update_persistence` is called *once* after all handlers ``run_async=False``), :meth:`update_persistence` is called *once* after all handlers
synchronous handlers are done. Each asynchronously running handler will trigger synchronous handlers are done. Each asynchronously running handler will trigger
:meth:`update_persistence` on its own. :meth:`update_persistence` on its own.
Args: Args:
update (:class:`telegram.Update` | :obj:`object` | :class:`telegram.TelegramError`): update (:class:`telegram.Update` | :obj:`object` |
:class:`telegram.error.TelegramError`):
The update to process. The update to process.
""" """

View file

@ -643,7 +643,7 @@ class Filters:
send media with wrong types that don't fit to this handler. send media with wrong types that don't fit to this handler.
Example: Example:
Filters.documents.category('audio/') returns :obj:`True` for all types Filters.document.category('audio/') returns :obj:`True` for all types
of audio sent as file, for example 'audio/mpeg' or 'audio/x-wav'. of audio sent as file, for example 'audio/mpeg' or 'audio/x-wav'.
""" """
@ -677,7 +677,7 @@ class Filters:
send media with wrong types that don't fit to this handler. send media with wrong types that don't fit to this handler.
Example: Example:
``Filters.documents.mime_type('audio/mpeg')`` filters all audio in mp3 format. ``Filters.document.mime_type('audio/mpeg')`` filters all audio in mp3 format.
""" """
def __init__(self, mimetype: Optional[str]): def __init__(self, mimetype: Optional[str]):
@ -794,7 +794,7 @@ class Filters:
send media with wrong types that don't fit to this handler. send media with wrong types that don't fit to this handler.
Example: Example:
``Filters.documents.category('audio/')`` filters all types ``Filters.document.category('audio/')`` filters all types
of audio sent as file, for example 'audio/mpeg' or 'audio/x-wav'. of audio sent as file, for example 'audio/mpeg' or 'audio/x-wav'.
application: Same as ``Filters.document.category("application")``. application: Same as ``Filters.document.category("application")``.
audio: Same as ``Filters.document.category("audio")``. audio: Same as ``Filters.document.category("audio")``.
@ -811,23 +811,23 @@ class Filters:
send media with wrong types that don't fit to this handler. send media with wrong types that don't fit to this handler.
Example: Example:
``Filters.documents.mime_type('audio/mpeg')`` filters all audio in mp3 format. ``Filters.document.mime_type('audio/mpeg')`` filters all audio in mp3 format.
apk: Same as ``Filters.document.mime_type("application/vnd.android.package-archive")``- apk: Same as ``Filters.document.mime_type("application/vnd.android.package-archive")``.
doc: Same as ``Filters.document.mime_type("application/msword")``- doc: Same as ``Filters.document.mime_type("application/msword")``.
docx: Same as ``Filters.document.mime_type("application/vnd.openxmlformats-\ docx: Same as ``Filters.document.mime_type("application/vnd.openxmlformats-\
officedocument.wordprocessingml.document")``- officedocument.wordprocessingml.document")``.
exe: Same as ``Filters.document.mime_type("application/x-ms-dos-executable")``- exe: Same as ``Filters.document.mime_type("application/x-ms-dos-executable")``.
gif: Same as ``Filters.document.mime_type("video/mp4")``- gif: Same as ``Filters.document.mime_type("video/mp4")``.
jpg: Same as ``Filters.document.mime_type("image/jpeg")``- jpg: Same as ``Filters.document.mime_type("image/jpeg")``.
mp3: Same as ``Filters.document.mime_type("audio/mpeg")``- mp3: Same as ``Filters.document.mime_type("audio/mpeg")``.
pdf: Same as ``Filters.document.mime_type("application/pdf")``- pdf: Same as ``Filters.document.mime_type("application/pdf")``.
py: Same as ``Filters.document.mime_type("text/x-python")``- py: Same as ``Filters.document.mime_type("text/x-python")``.
svg: Same as ``Filters.document.mime_type("image/svg+xml")``- svg: Same as ``Filters.document.mime_type("image/svg+xml")``.
txt: Same as ``Filters.document.mime_type("text/plain")``- txt: Same as ``Filters.document.mime_type("text/plain")``.
targz: Same as ``Filters.document.mime_type("application/x-compressed-tar")``- targz: Same as ``Filters.document.mime_type("application/x-compressed-tar")``.
wav: Same as ``Filters.document.mime_type("audio/x-wav")``- wav: Same as ``Filters.document.mime_type("audio/x-wav")``.
xml: Same as ``Filters.document.mime_type("application/xml")``- xml: Same as ``Filters.document.mime_type("application/xml")``.
zip: Same as ``Filters.document.mime_type("application/zip")``- zip: Same as ``Filters.document.mime_type("application/zip")``.
file_extension: This filter filters documents by their file ending/extension. file_extension: This filter filters documents by their file ending/extension.
Note: Note:
@ -1699,14 +1699,14 @@ officedocument.wordprocessingml.document")``-
chat_id(:class:`telegram.utils.types.SLT[int]`, optional): chat_id(:class:`telegram.utils.types.SLT[int]`, optional):
Which sender chat chat ID(s) to allow through. Which sender chat chat ID(s) to allow through.
username(:class:`telegram.utils.types.SLT[str]`, optional): username(:class:`telegram.utils.types.SLT[str]`, optional):
Which sender chat sername(s) to allow through. Which sender chat username(s) to allow through.
Leading `'@'` s in usernames will be discarded. Leading `'@'` s in usernames will be discarded.
allow_empty(:obj:`bool`, optional): Whether updates should be processed, if no sender allow_empty(:obj:`bool`, optional): Whether updates should be processed, if no sender
chat is specified in :attr:`chat_ids` and :attr:`usernames`. Defaults to chat is specified in :attr:`chat_ids` and :attr:`usernames`. Defaults to
:obj:`False` :obj:`False`
Raises: Raises:
RuntimeError: If chat_id and username are both present. RuntimeError: If both chat_id and username are present.
Attributes: Attributes:
chat_ids(set(:obj:`int`), optional): Which sender chat chat ID(s) to allow through. chat_ids(set(:obj:`int`), optional): Which sender chat chat ID(s) to allow through.
@ -1756,7 +1756,7 @@ officedocument.wordprocessingml.document")``-
Args: Args:
username(:class:`telegram.utils.types.SLT[str]`, optional): username(:class:`telegram.utils.types.SLT[str]`, optional):
Which sender chat username(s) to disallow through. Which sender chat username(s) to disallow through.
Leading '@'s in usernames will be discarded. Leading `'@'` s in usernames will be discarded.
""" """
return super().remove_usernames(username) return super().remove_usernames(username)

View file

@ -113,7 +113,7 @@ class Animation(TelegramObject):
:class:`telegram.File` :class:`telegram.File`
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
return self.bot.get_file(file_id=self.file_id, timeout=timeout, api_kwargs=api_kwargs) return self.bot.get_file(file_id=self.file_id, timeout=timeout, api_kwargs=api_kwargs)

View file

@ -117,7 +117,7 @@ class Audio(TelegramObject):
:class:`telegram.File` :class:`telegram.File`
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
return self.bot.get_file(file_id=self.file_id, timeout=timeout, api_kwargs=api_kwargs) return self.bot.get_file(file_id=self.file_id, timeout=timeout, api_kwargs=api_kwargs)

View file

@ -95,7 +95,7 @@ class ChatPhoto(TelegramObject):
:class:`telegram.File` :class:`telegram.File`
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
return self.bot.get_file( return self.bot.get_file(
@ -112,7 +112,7 @@ class ChatPhoto(TelegramObject):
:class:`telegram.File` :class:`telegram.File`
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
return self.bot.get_file(file_id=self.big_file_id, timeout=timeout, api_kwargs=api_kwargs) return self.bot.get_file(file_id=self.big_file_id, timeout=timeout, api_kwargs=api_kwargs)

View file

@ -104,7 +104,7 @@ class Document(TelegramObject):
:class:`telegram.File` :class:`telegram.File`
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
return self.bot.get_file(file_id=self.file_id, timeout=timeout, api_kwargs=api_kwargs) return self.bot.get_file(file_id=self.file_id, timeout=timeout, api_kwargs=api_kwargs)

View file

@ -87,7 +87,7 @@ class PhotoSize(TelegramObject):
:class:`telegram.File` :class:`telegram.File`
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
return self.bot.get_file(file_id=self.file_id, timeout=timeout, api_kwargs=api_kwargs) return self.bot.get_file(file_id=self.file_id, timeout=timeout, api_kwargs=api_kwargs)

View file

@ -124,7 +124,7 @@ class Sticker(TelegramObject):
:class:`telegram.File` :class:`telegram.File`
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
return self.bot.get_file(file_id=self.file_id, timeout=timeout, api_kwargs=api_kwargs) return self.bot.get_file(file_id=self.file_id, timeout=timeout, api_kwargs=api_kwargs)

View file

@ -114,7 +114,7 @@ class Video(TelegramObject):
:class:`telegram.File` :class:`telegram.File`
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
return self.bot.get_file(file_id=self.file_id, timeout=timeout, api_kwargs=api_kwargs) return self.bot.get_file(file_id=self.file_id, timeout=timeout, api_kwargs=api_kwargs)

View file

@ -103,7 +103,7 @@ class VideoNote(TelegramObject):
:class:`telegram.File` :class:`telegram.File`
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
return self.bot.get_file(file_id=self.file_id, timeout=timeout, api_kwargs=api_kwargs) return self.bot.get_file(file_id=self.file_id, timeout=timeout, api_kwargs=api_kwargs)

View file

@ -87,7 +87,7 @@ class Voice(TelegramObject):
:class:`telegram.File` :class:`telegram.File`
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
return self.bot.get_file(file_id=self.file_id, timeout=timeout, api_kwargs=api_kwargs) return self.bot.get_file(file_id=self.file_id, timeout=timeout, api_kwargs=api_kwargs)

View file

@ -41,7 +41,7 @@ class InlineKeyboardButton(TelegramObject):
Args: Args:
text (:obj:`str`): Label text on the button. text (:obj:`str`): Label text on the button.
url (:obj:`str`): HTTP or tg:// url to be opened when button is pressed. url (:obj:`str`): HTTP or tg:// url to be opened when button is pressed.
login_url (:class:`telegram.LoginUrl`, optional) An HTTP URL used to automatically login_url (:class:`telegram.LoginUrl`, optional): An HTTP URL used to automatically
authorize the user. Can be used as a replacement for the Telegram Login Widget. authorize the user. Can be used as a replacement for the Telegram Login Widget.
callback_data (:obj:`str`, optional): Data to be sent in a callback query to the bot when callback_data (:obj:`str`, optional): Data to be sent in a callback query to the bot when
button is pressed, UTF-8 1-64 bytes. button is pressed, UTF-8 1-64 bytes.
@ -67,7 +67,7 @@ class InlineKeyboardButton(TelegramObject):
Attributes: Attributes:
text (:obj:`str`): Label text on the button. text (:obj:`str`): Label text on the button.
url (:obj:`str`): Optional. HTTP or tg:// url to be opened when button is pressed. url (:obj:`str`): Optional. HTTP or tg:// url to be opened when button is pressed.
login_url (:class:`telegram.LoginUrl`) Optional. An HTTP URL used to automatically login_url (:class:`telegram.LoginUrl`): Optional. An HTTP URL used to automatically
authorize the user. Can be used as a replacement for the Telegram Login Widget. authorize the user. Can be used as a replacement for the Telegram Login Widget.
callback_data (:obj:`str`): Optional. Data to be sent in a callback query to the bot when callback_data (:obj:`str`): Optional. Data to be sent in a callback query to the bot when
button is pressed, UTF-8 1-64 bytes. button is pressed, UTF-8 1-64 bytes.
@ -79,7 +79,7 @@ class InlineKeyboardButton(TelegramObject):
case just the bots username will be inserted. case just the bots username will be inserted.
callback_game (:class:`telegram.CallbackGame`): Optional. Description of the game that will callback_game (:class:`telegram.CallbackGame`): Optional. Description of the game that will
be launched when the user presses the button. be launched when the user presses the button.
pay (:obj:`bool`): Optional. Specify True, to send a Pay button. pay (:obj:`bool`): Optional. Specify :obj:`True`, to send a Pay button.
""" """

View file

@ -829,7 +829,7 @@ class Message(TelegramObject):
List[:class:`telegram.Message`]: An array of the sent Messages. List[:class:`telegram.Message`]: An array of the sent Messages.
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
reply_to_message_id = self._quote(quote, reply_to_message_id) reply_to_message_id = self._quote(quote, reply_to_message_id)
return self.bot.send_media_group( return self.bot.send_media_group(

View file

@ -33,7 +33,7 @@ class MessageEntity(TelegramObject):
usernames, URLs, etc. usernames, URLs, etc.
Objects of this class are comparable in terms of equality. Two objects of this class are Objects of this class are comparable in terms of equality. Two objects of this class are
considered equal, if their :attr:`type`, :attr:`offset` and :attr`length` are equal. considered equal, if their :attr:`type`, :attr:`offset` and :attr:`length` are equal.
Args: Args:
type (:obj:`str`): Type of the entity. Can be mention (@username), hashtag, bot_command, type (:obj:`str`): Type of the entity. Can be mention (@username), hashtag, bot_command,

View file

@ -115,7 +115,7 @@ class PassportFile(TelegramObject):
:class:`telegram.File` :class:`telegram.File`
Raises: Raises:
:class:`telegram.TelegramError` :class:`telegram.error.TelegramError`
""" """
file = self.bot.get_file(file_id=self.file_id, timeout=timeout, api_kwargs=api_kwargs) file = self.bot.get_file(file_id=self.file_id, timeout=timeout, api_kwargs=api_kwargs)

View file

@ -204,7 +204,8 @@ def to_float_timestamp(
to be in UTC, if ``bot`` is not passed or ``bot.defaults`` is :obj:`None`. to be in UTC, if ``bot`` is not passed or ``bot.defaults`` is :obj:`None`.
Args: Args:
time_object (int | float | datetime.timedelta | datetime.datetime | datetime.time): time_object (:obj:`int` | :obj:`float` | :obj:`datetime.timedelta` | \
:obj:`datetime.datetime` | :obj:`datetime.time`):
Time value to convert. The semantics of this parameter will depend on its type: Time value to convert. The semantics of this parameter will depend on its type:
* :obj:`int` or :obj:`float` will be interpreted as "seconds from ``reference_t``" * :obj:`int` or :obj:`float` will be interpreted as "seconds from ``reference_t``"
@ -213,13 +214,13 @@ def to_float_timestamp(
* :obj:`datetime.datetime` will be interpreted as an absolute date/time value * :obj:`datetime.datetime` will be interpreted as an absolute date/time value
* :obj:`datetime.time` will be interpreted as a specific time of day * :obj:`datetime.time` will be interpreted as a specific time of day
reference_timestamp (float, optional): POSIX timestamp that indicates the absolute time reference_timestamp (:obj:`float`, optional): POSIX timestamp that indicates the absolute
from which relative calculations are to be performed (e.g. when ``t`` is given as an time from which relative calculations are to be performed (e.g. when ``t`` is given as
:obj:`int`, indicating "seconds from ``reference_t``"). Defaults to now (the time at an :obj:`int`, indicating "seconds from ``reference_t``"). Defaults to now (the time at
which this function is called). which this function is called).
If ``t`` is given as an absolute representation of date & time (i.e. a If ``t`` is given as an absolute representation of date & time (i.e. a
``datetime.datetime`` object), ``reference_timestamp`` is not relevant and so its :obj:`datetime.datetime` object), ``reference_timestamp`` is not relevant and so its
value should be :obj:`None`. If this is not the case, a ``ValueError`` will be raised. value should be :obj:`None`. If this is not the case, a ``ValueError`` will be raised.
tzinfo (:obj:`pytz.BaseTzInfo`, optional): If ``t`` is a naive object from the tzinfo (:obj:`pytz.BaseTzInfo`, optional): If ``t`` is a naive object from the
:class:`datetime` module, it will be interpreted as this timezone. Defaults to :class:`datetime` module, it will be interpreted as this timezone. Defaults to
@ -230,8 +231,9 @@ def to_float_timestamp(
Returns: Returns:
(float | None) The return value depends on the type of argument ``t``. If ``t`` is :obj:`float` | :obj:`None`:
given as a time increment (i.e. as a obj:`int`, :obj:`float` or The return value depends on the type of argument ``t``.
If ``t`` is given as a time increment (i.e. as a :obj:`int`, :obj:`float` or
:obj:`datetime.timedelta`), then the return value will be ``reference_t`` + ``t``. :obj:`datetime.timedelta`), then the return value will be ``reference_t`` + ``t``.
Else if it is given as an absolute date/time value (i.e. a :obj:`datetime.datetime` Else if it is given as an absolute date/time value (i.e. a :obj:`datetime.datetime`
@ -241,7 +243,9 @@ def to_float_timestamp(
object), the return value is the nearest future occurrence of that time of day. object), the return value is the nearest future occurrence of that time of day.
Raises: Raises:
TypeError: if `t`'s type is not one of those described above TypeError: If ``t``'s type is not one of those described above.
ValueError: If ``t`` is a :obj:`datetime.datetime` and :obj:`reference_timestamp` is not
:obj:`None`.
""" """
if reference_timestamp is None: if reference_timestamp is None:
@ -304,13 +308,13 @@ def from_timestamp(unixtime: Optional[int], tzinfo: dtm.tzinfo = UTC) -> Optiona
:obj:`None` s are left alone (i.e. ``from_timestamp(None)`` is :obj:`None`). :obj:`None` s are left alone (i.e. ``from_timestamp(None)`` is :obj:`None`).
Args: Args:
unixtime (int): Integer POSIX timestamp. unixtime (:obj:`int`): Integer POSIX timestamp.
tzinfo (:obj:`datetime.tzinfo`, optional): The timezone, the timestamp is to be converted tzinfo (:obj:`datetime.tzinfo`, optional): The timezone to which the timestamp is to be
to. Defaults to UTC. converted to. Defaults to UTC.
Returns: Returns:
timezone aware equivalent :obj:`datetime.datetime` value if ``timestamp`` is not Timezone aware equivalent :obj:`datetime.datetime` value if ``unixtime`` is not
:obj:`None`; else :obj:`None` :obj:`None`; else :obj:`None`.
""" """
if unixtime is None: if unixtime is None:
return None return None
@ -326,11 +330,11 @@ def from_timestamp(unixtime: Optional[int], tzinfo: dtm.tzinfo = UTC) -> Optiona
def mention_html(user_id: Union[int, str], name: str) -> str: def mention_html(user_id: Union[int, str], name: str) -> str:
""" """
Args: Args:
user_id (:obj:`int`) The user's id which you want to mention. user_id (:obj:`int`): The user's id which you want to mention.
name (:obj:`str`) The name the mention is showing. name (:obj:`str`): The name the mention is showing.
Returns: Returns:
:obj:`str`: The inline mention for the user as html. :obj:`str`: The inline mention for the user as HTML.
""" """
return f'<a href="tg://user?id={user_id}">{escape(name)}</a>' return f'<a href="tg://user?id={user_id}">{escape(name)}</a>'
@ -338,13 +342,13 @@ def mention_html(user_id: Union[int, str], name: str) -> str:
def mention_markdown(user_id: Union[int, str], name: str, version: int = 1) -> str: def mention_markdown(user_id: Union[int, str], name: str, version: int = 1) -> str:
""" """
Args: Args:
user_id (:obj:`int`) The user's id which you want to mention. user_id (:obj:`int`): The user's id which you want to mention.
name (:obj:`str`) The name the mention is showing. name (:obj:`str`): The name the mention is showing.
version (:obj:`int` | :obj:`str`): Use to specify the version of telegrams Markdown. version (:obj:`int` | :obj:`str`): Use to specify the version of Telegram's Markdown.
Either ``1`` or ``2``. Defaults to ``1`` Either ``1`` or ``2``. Defaults to ``1``.
Returns: Returns:
:obj:`str`: The inline mention for the user as markdown. :obj:`str`: The inline mention for the user as Markdown.
""" """
return f'[{escape_markdown(name, version=version)}](tg://user?id={user_id})' return f'[{escape_markdown(name, version=version)}](tg://user?id={user_id})'
@ -355,10 +359,11 @@ def effective_message_type(entity: Union['Message', 'Update']) -> Optional[str]:
:class:`telegram.Update`. :class:`telegram.Update`.
Args: Args:
entity (:obj:`Update` | :obj:`Message`) The ``update`` or ``message`` to extract from entity (:class:`telegram.Update` | :class:`telegram.Message`): The ``update`` or
``message`` to extract from.
Returns: Returns:
str: One of ``Message.MESSAGE_TYPES`` :obj:`str`: One of ``Message.MESSAGE_TYPES``
""" """
@ -429,7 +434,7 @@ def create_deep_linked_url(bot_username: str, payload: str = None, group: bool =
def encode_conversations_to_json(conversations: Dict[str, Dict[Tuple, object]]) -> str: def encode_conversations_to_json(conversations: Dict[str, Dict[Tuple, object]]) -> str:
"""Helper method to encode a conversations dict (that uses tuples as keys) to a """Helper method to encode a conversations dict (that uses tuples as keys) to a
JSON-serializable way. Use :attr:`_decode_conversations_from_json` to decode. JSON-serializable way. Use :meth:`decode_conversations_from_json` to decode.
Args: Args:
conversations (:obj:`dict`): The conversations dict to transform to JSON. conversations (:obj:`dict`): The conversations dict to transform to JSON.
@ -447,7 +452,7 @@ def encode_conversations_to_json(conversations: Dict[str, Dict[Tuple, object]])
def decode_conversations_from_json(json_string: str) -> Dict[str, Dict[Tuple, object]]: def decode_conversations_from_json(json_string: str) -> Dict[str, Dict[Tuple, object]]:
"""Helper method to decode a conversations dict (that uses tuples as keys) from a """Helper method to decode a conversations dict (that uses tuples as keys) from a
JSON-string created with :attr:`_encode_conversations_to_json`. JSON-string created with :meth:`encode_conversations_to_json`.
Args: Args:
json_string (:obj:`str`): The conversations dict as JSON string. json_string (:obj:`str`): The conversations dict as JSON string.
@ -500,7 +505,7 @@ class DefaultValue:
arg = arg.value arg = arg.value
else: else:
print('`arg` was set explicitly') print('`arg` was set explicitly')
print('`arg` = ' + str(arg)) print(f'`arg` = {str(arg)}')
This yields:: This yields::
@ -542,7 +547,7 @@ class DefaultValue:
DEFAULT_NONE: DefaultValue = DefaultValue(None) DEFAULT_NONE: DefaultValue = DefaultValue(None)
""":class:`DefaultValue`: Default `None`""" """:class:`DefaultValue`: Default :obj:`None`"""
DEFAULT_FALSE: DefaultValue = DefaultValue(False) DEFAULT_FALSE: DefaultValue = DefaultValue(False)
""":class:`DefaultValue`: Default `False`""" """:class:`DefaultValue`: Default :obj:`False`"""

View file

@ -1581,7 +1581,7 @@ class TestBot:
with pytest.raises(OkException): with pytest.raises(OkException):
bot.send_photo(chat_id, open('tests/data/telegram.jpg', 'rb'), timeout=TIMEOUT) bot.send_photo(chat_id, open('tests/data/telegram.jpg', 'rb'), timeout=TIMEOUT)
# Test JSON submition # Test JSON submission
with pytest.raises(OkException): with pytest.raises(OkException):
bot.get_chat_administrators(chat_id, timeout=TIMEOUT) bot.get_chat_administrators(chat_id, timeout=TIMEOUT)