mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-12-22 14:35:00 +01:00
Doc Fixes (#2253)
* 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:
parent
25506f131d
commit
36d49ea9cd
34 changed files with 166 additions and 181 deletions
|
@ -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
|
||||
:alt: PyPi Package Monthly Download
|
||||
|
||||
.. image:: https://img.shields.io/badge/docs-latest-af1a97.svg
|
||||
:target: https://python-telegram-bot.readthedocs.io/
|
||||
.. image:: https://readthedocs.org/projects/python-telegram-bot/badge/?version=stable
|
||||
:target: https://python-telegram-bot.readthedocs.io/en/stable/?badge=stable
|
||||
:alt: Documentation Status
|
||||
|
||||
.. image:: https://img.shields.io/pypi/l/python-telegram-bot.svg
|
||||
|
|
|
@ -127,9 +127,7 @@ def cancel(update: Update, context: CallbackContext) -> int:
|
|||
|
||||
def main() -> None:
|
||||
# Create the Updater and pass it your bot's token.
|
||||
# Make sure to set use_context=True to use the new context based callbacks
|
||||
# Post version 12 this will no longer be necessary
|
||||
updater = Updater("TOKEN", use_context=True)
|
||||
updater = Updater("TOKEN")
|
||||
|
||||
# Get the dispatcher to register handlers
|
||||
dispatcher = updater.dispatcher
|
||||
|
|
|
@ -112,9 +112,7 @@ def done(update: Update, context: CallbackContext) -> int:
|
|||
|
||||
def main() -> None:
|
||||
# Create the Updater and pass it your bot's token.
|
||||
# Make sure to set use_context=True to use the new context based callbacks
|
||||
# Post version 12 this will no longer be necessary
|
||||
updater = Updater("TOKEN", use_context=True)
|
||||
updater = Updater("TOKEN")
|
||||
|
||||
# Get the dispatcher to register handlers
|
||||
dispatcher = updater.dispatcher
|
||||
|
|
|
@ -107,7 +107,7 @@ def deep_linked_level_4(update: Update, context: CallbackContext) -> None:
|
|||
def main():
|
||||
"""Start the bot."""
|
||||
# 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
|
||||
dispatcher = updater.dispatcher
|
||||
|
|
|
@ -49,9 +49,7 @@ def echo(update: Update, context: CallbackContext) -> None:
|
|||
def main():
|
||||
"""Start the bot."""
|
||||
# Create the Updater and pass it your bot's token.
|
||||
# Make sure to set use_context=True to use the new context based callbacks
|
||||
# Post version 12 this will no longer be necessary
|
||||
updater = Updater("TOKEN", use_context=True)
|
||||
updater = Updater("TOKEN")
|
||||
|
||||
# Get the dispatcher to register handlers
|
||||
dispatcher = updater.dispatcher
|
||||
|
|
|
@ -67,9 +67,7 @@ def start(update: Update, context: CallbackContext) -> None:
|
|||
|
||||
def main():
|
||||
# Create the Updater and pass it your bot's token.
|
||||
# Make sure to set use_context=True to use the new context based callbacks
|
||||
# Post version 12 this will no longer be necessary
|
||||
updater = Updater(BOT_TOKEN, use_context=True)
|
||||
updater = Updater(BOT_TOKEN)
|
||||
|
||||
# Get the dispatcher to register handlers
|
||||
dispatcher = updater.dispatcher
|
||||
|
|
|
@ -68,9 +68,7 @@ def inlinequery(update: Update, context: CallbackContext) -> None:
|
|||
|
||||
def main() -> None:
|
||||
# Create the Updater and pass it your bot's token.
|
||||
# Make sure to set use_context=True to use the new context based callbacks
|
||||
# Post version 12 this will no longer be necessary
|
||||
updater = Updater("TOKEN", use_context=True)
|
||||
updater = Updater("TOKEN")
|
||||
|
||||
# Get the dispatcher to register handlers
|
||||
dispatcher = updater.dispatcher
|
||||
|
|
|
@ -47,9 +47,7 @@ def help_command(update: Update, context: CallbackContext) -> None:
|
|||
|
||||
def main():
|
||||
# Create the Updater and pass it your bot's token.
|
||||
# Make sure to set use_context=True to use the new context based callbacks
|
||||
# Post version 12 this will no longer be necessary
|
||||
updater = Updater("TOKEN", use_context=True)
|
||||
updater = Updater("TOKEN")
|
||||
|
||||
updater.dispatcher.add_handler(CommandHandler('start', start))
|
||||
updater.dispatcher.add_handler(CallbackQueryHandler(button))
|
||||
|
|
|
@ -161,7 +161,7 @@ def end(update: Update, context: CallbackContext) -> None:
|
|||
|
||||
def main():
|
||||
# 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
|
||||
dispatcher = updater.dispatcher
|
||||
|
|
|
@ -301,9 +301,7 @@ def stop_nested(update: Update, context: CallbackContext) -> None:
|
|||
|
||||
def main():
|
||||
# Create the Updater and pass it your bot's token.
|
||||
# Make sure to set use_context=True to use the new context based callbacks
|
||||
# Post version 12 this will no longer be necessary
|
||||
updater = Updater("TOKEN", use_context=True)
|
||||
updater = Updater("TOKEN")
|
||||
|
||||
# Get the dispatcher to register handlers
|
||||
dispatcher = updater.dispatcher
|
||||
|
|
|
@ -127,9 +127,7 @@ def successful_payment_callback(update: Update, context: CallbackContext) -> Non
|
|||
|
||||
def main():
|
||||
# Create the Updater and pass it your bot's token.
|
||||
# Make sure to set use_context=True to use the new context based callbacks
|
||||
# Post version 12 this will no longer be necessary
|
||||
updater = Updater("TOKEN", use_context=True)
|
||||
updater = Updater("TOKEN")
|
||||
|
||||
# Get the dispatcher to register handlers
|
||||
dispatcher = updater.dispatcher
|
||||
|
|
|
@ -130,7 +130,7 @@ def done(update: Update, context: CallbackContext) -> None:
|
|||
def main():
|
||||
# Create the Updater and pass it your bot's token.
|
||||
pp = PicklePersistence(filename='conversationbot')
|
||||
updater = Updater("TOKEN", persistence=pp, use_context=True)
|
||||
updater = Updater("TOKEN", persistence=pp)
|
||||
|
||||
# Get the dispatcher to register handlers
|
||||
dp = updater.dispatcher
|
||||
|
|
|
@ -153,9 +153,7 @@ def help_handler(update: Update, context: CallbackContext) -> None:
|
|||
|
||||
def main() -> None:
|
||||
# Create the Updater and pass it your bot's token.
|
||||
# Make sure to set use_context=True to use the new context based callbacks
|
||||
# Post version 12 this will no longer be necessary
|
||||
updater = Updater("TOKEN", use_context=True)
|
||||
updater = Updater("TOKEN")
|
||||
dispatcher = updater.dispatcher
|
||||
dispatcher.add_handler(CommandHandler('start', start))
|
||||
dispatcher.add_handler(CommandHandler('poll', poll))
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# pylint: disable=W0603
|
||||
"""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.
|
||||
This program is dedicated to the public domain under the CC0 license.
|
||||
"""
|
||||
|
|
|
@ -87,9 +87,7 @@ def unset(update: Update, context: CallbackContext) -> None:
|
|||
def main():
|
||||
"""Run bot."""
|
||||
# Create the Updater and pass it your bot's token.
|
||||
# Make sure to set use_context=True to use the new context based callbacks
|
||||
# Post version 12 this will no longer be necessary
|
||||
updater = Updater("TOKEN", use_context=True)
|
||||
updater = Updater("TOKEN")
|
||||
|
||||
# Get the dispatcher to register handlers
|
||||
dispatcher = updater.dispatcher
|
||||
|
|
142
telegram/bot.py
142
telegram/bot.py
|
@ -377,7 +377,7 @@ class Bot(TelegramObject):
|
|||
credentials are valid, :obj:`None` otherwise.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
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.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
data: JSONDict = {'chat_id': chat_id, 'text': text}
|
||||
|
@ -493,7 +493,7 @@ class Bot(TelegramObject):
|
|||
:obj:`bool`: On success, :obj:`True` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
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.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
data: JSONDict = {}
|
||||
|
@ -616,7 +616,7 @@ class Bot(TelegramObject):
|
|||
:class:`telegram.Message`: On success, the sent Message is returned.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
data: JSONDict = {
|
||||
|
@ -729,7 +729,7 @@ class Bot(TelegramObject):
|
|||
:class:`telegram.Message`: On success, the sent Message is returned.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
data: JSONDict = {
|
||||
|
@ -842,7 +842,7 @@ class Bot(TelegramObject):
|
|||
:class:`telegram.Message`: On success, the sent Message is returned.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
data: JSONDict = {
|
||||
|
@ -920,7 +920,7 @@ class Bot(TelegramObject):
|
|||
:class:`telegram.Message`: On success, the sent Message is returned.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
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.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
data: JSONDict = {
|
||||
|
@ -1136,7 +1136,7 @@ class Bot(TelegramObject):
|
|||
:class:`telegram.Message`: On success, the sent Message is returned.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
data: JSONDict = {
|
||||
|
@ -1246,7 +1246,7 @@ class Bot(TelegramObject):
|
|||
:class:`telegram.Message`: On success, the sent Message is returned.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
data: JSONDict = {
|
||||
|
@ -1350,7 +1350,7 @@ class Bot(TelegramObject):
|
|||
:class:`telegram.Message`: On success, the sent Message is returned.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
data: JSONDict = {
|
||||
|
@ -1413,7 +1413,7 @@ class Bot(TelegramObject):
|
|||
List[:class:`telegram.Message`]: An array of the sent Messages.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
"""
|
||||
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.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
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.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
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.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
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.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
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.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
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
|
||||
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
|
||||
either a list of :class:`telegram.InlineResult` instances or :obj:`None` if there
|
||||
are no more results.
|
||||
either a list of :class:`telegram.InlineQueryResult` instances or :obj:`None` if
|
||||
there are no more results.
|
||||
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.
|
||||
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.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
|
||||
|
@ -2151,7 +2151,7 @@ class Bot(TelegramObject):
|
|||
:class:`telegram.UserProfilePhotos`
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
data: JSONDict = {'user_id': user_id}
|
||||
|
@ -2204,7 +2204,7 @@ class Bot(TelegramObject):
|
|||
:class:`telegram.File`
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
try:
|
||||
|
@ -2259,7 +2259,7 @@ class Bot(TelegramObject):
|
|||
:obj:`bool` On success, :obj:`True` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
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.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
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.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
data: JSONDict = {'callback_query_id': callback_query_id}
|
||||
|
@ -2428,7 +2428,7 @@ class Bot(TelegramObject):
|
|||
edited message is returned, otherwise :obj:`True` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
data: JSONDict = {'text': text}
|
||||
|
@ -2499,7 +2499,7 @@ class Bot(TelegramObject):
|
|||
edited message is returned, otherwise :obj:`True` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
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.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
"""
|
||||
|
||||
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.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
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`]
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
data: JSONDict = {'timeout': timeout}
|
||||
|
@ -2807,7 +2807,7 @@ class Bot(TelegramObject):
|
|||
:obj:`bool` On success, :obj:`True` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
.. _`guide to Webhooks`: https://core.telegram.org/bots/webhooks
|
||||
|
||||
|
@ -2852,7 +2852,7 @@ class Bot(TelegramObject):
|
|||
:obj:`bool` On success, :obj:`True` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
data = {}
|
||||
|
@ -2883,7 +2883,7 @@ class Bot(TelegramObject):
|
|||
:obj:`bool` On success, :obj:`True` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
data: JSONDict = {'chat_id': chat_id}
|
||||
|
@ -2913,7 +2913,7 @@ class Bot(TelegramObject):
|
|||
:class:`telegram.Chat`
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
data: JSONDict = {'chat_id': chat_id}
|
||||
|
@ -2948,7 +2948,7 @@ class Bot(TelegramObject):
|
|||
appointed, only the creator will be returned.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
data: JSONDict = {'chat_id': chat_id}
|
||||
|
@ -2976,7 +2976,7 @@ class Bot(TelegramObject):
|
|||
:obj:`int`: Number of members in the chat.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
data: JSONDict = {'chat_id': chat_id}
|
||||
|
@ -3009,7 +3009,7 @@ class Bot(TelegramObject):
|
|||
:class:`telegram.ChatMember`
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
data: JSONDict = {'chat_id': chat_id, 'user_id': user_id}
|
||||
|
@ -3138,7 +3138,7 @@ class Bot(TelegramObject):
|
|||
, :obj:`True`.
|
||||
|
||||
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`.
|
||||
|
||||
"""
|
||||
|
@ -3194,7 +3194,7 @@ class Bot(TelegramObject):
|
|||
List[:class:`telegram.GameHighScore`]
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
data: JSONDict = {'user_id': user_id}
|
||||
|
@ -3299,7 +3299,7 @@ class Bot(TelegramObject):
|
|||
:class:`telegram.Message`: On success, the sent Message is returned.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
data: JSONDict = {
|
||||
|
@ -3387,7 +3387,7 @@ class Bot(TelegramObject):
|
|||
:obj:`bool`: On success, :obj:`True` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
ok = bool(ok)
|
||||
|
@ -3454,7 +3454,7 @@ class Bot(TelegramObject):
|
|||
:obj:`bool`: On success, :obj:`True` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
ok = bool(ok)
|
||||
|
@ -3517,7 +3517,7 @@ class Bot(TelegramObject):
|
|||
:obj:`bool`: On success, :obj:`True` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
"""
|
||||
data: JSONDict = {
|
||||
'chat_id': chat_id,
|
||||
|
@ -3592,7 +3592,7 @@ class Bot(TelegramObject):
|
|||
:obj:`bool`: On success, :obj:`True` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
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.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
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.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
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.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
data: JSONDict = {'chat_id': chat_id}
|
||||
|
@ -3757,7 +3757,7 @@ class Bot(TelegramObject):
|
|||
:obj:`bool`: On success, :obj:`True` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
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.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
data: JSONDict = {'chat_id': chat_id}
|
||||
|
@ -3824,7 +3824,7 @@ class Bot(TelegramObject):
|
|||
:obj:`bool`: On success, :obj:`True` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
data: JSONDict = {'chat_id': chat_id, 'title': title}
|
||||
|
@ -3860,7 +3860,7 @@ class Bot(TelegramObject):
|
|||
:obj:`bool`: On success, :obj:`True` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
data: JSONDict = {'chat_id': chat_id, 'description': description}
|
||||
|
@ -3901,7 +3901,7 @@ class Bot(TelegramObject):
|
|||
:obj:`bool`: On success, :obj:`True` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
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.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
data: JSONDict = {'chat_id': chat_id}
|
||||
|
@ -3980,7 +3980,7 @@ class Bot(TelegramObject):
|
|||
:obj:`bool`: On success, :obj:`True` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
|
||||
|
@ -4008,7 +4008,7 @@ class Bot(TelegramObject):
|
|||
:class:`telegram.StickerSet`
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
data: JSONDict = {'name': name}
|
||||
|
@ -4053,7 +4053,7 @@ class Bot(TelegramObject):
|
|||
:class:`telegram.File`: On success, the uploaded File is returned.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
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.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
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.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
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.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
data: JSONDict = {'sticker': sticker, 'position': position}
|
||||
|
@ -4278,7 +4278,7 @@ class Bot(TelegramObject):
|
|||
:obj:`bool`: On success, :obj:`True` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
data: JSONDict = {'sticker': sticker}
|
||||
|
@ -4327,7 +4327,7 @@ class Bot(TelegramObject):
|
|||
:obj:`bool`: On success, :obj:`True` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
data: JSONDict = {'name': name, 'user_id': user_id}
|
||||
|
@ -4371,7 +4371,7 @@ class Bot(TelegramObject):
|
|||
:obj:`bool`: On success, :obj:`True` is returned.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
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.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
data: JSONDict = {'chat_id': chat_id, 'question': question, 'options': options}
|
||||
|
@ -4533,7 +4533,7 @@ class Bot(TelegramObject):
|
|||
returned.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
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.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
data: JSONDict = {
|
||||
|
@ -4630,7 +4630,7 @@ class Bot(TelegramObject):
|
|||
List[:class:`telegram.BotCommand]`: On success, the commands set for the bot
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
result = self._post('getMyCommands', timeout=timeout, api_kwargs=api_kwargs)
|
||||
|
@ -4663,7 +4663,7 @@ class Bot(TelegramObject):
|
|||
:obj:`True`: On success
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
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
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
return self._post('logOut') # type: ignore[return-value]
|
||||
|
@ -4708,7 +4708,7 @@ class Bot(TelegramObject):
|
|||
:obj:`True`: On success
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
return self._post('close') # type: ignore[return-value]
|
||||
|
@ -4766,7 +4766,7 @@ class Bot(TelegramObject):
|
|||
:class:`telegram.MessageId`: On success
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
"""
|
||||
data: JSONDict = {
|
||||
'chat_id': chat_id,
|
||||
|
|
|
@ -73,9 +73,8 @@ class CallbackContext:
|
|||
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
|
||||
text after the command, using any whitespace string as a delimiter.
|
||||
error (:class:`telegram.TelegramError`): Optional. The error that was raised.
|
||||
Only present when passed to a error handler registered with
|
||||
:attr:`telegram.ext.Dispatcher.add_error_handler`.
|
||||
error (:obj:`Exception`): Optional. The error that was raised. Only present when passed
|
||||
to a error handler registered with :attr:`telegram.ext.Dispatcher.add_error_handler`.
|
||||
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
|
||||
:meth:`telegram.ext.Dispatcher.run_async`.
|
||||
|
|
|
@ -407,12 +407,13 @@ class Dispatcher:
|
|||
|
||||
Note:
|
||||
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
|
||||
:meth:`update_persistence` on its own.
|
||||
|
||||
Args:
|
||||
update (:class:`telegram.Update` | :obj:`object` | :class:`telegram.TelegramError`):
|
||||
update (:class:`telegram.Update` | :obj:`object` |
|
||||
:class:`telegram.error.TelegramError`):
|
||||
The update to process.
|
||||
|
||||
"""
|
||||
|
|
|
@ -643,7 +643,7 @@ class Filters:
|
|||
send media with wrong types that don't fit to this handler.
|
||||
|
||||
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'.
|
||||
"""
|
||||
|
||||
|
@ -677,7 +677,7 @@ class Filters:
|
|||
send media with wrong types that don't fit to this handler.
|
||||
|
||||
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]):
|
||||
|
@ -794,7 +794,7 @@ class Filters:
|
|||
send media with wrong types that don't fit to this handler.
|
||||
|
||||
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'.
|
||||
application: Same as ``Filters.document.category("application")``.
|
||||
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.
|
||||
|
||||
Example:
|
||||
``Filters.documents.mime_type('audio/mpeg')`` filters all audio in mp3 format.
|
||||
apk: Same as ``Filters.document.mime_type("application/vnd.android.package-archive")``-
|
||||
doc: Same as ``Filters.document.mime_type("application/msword")``-
|
||||
``Filters.document.mime_type('audio/mpeg')`` filters all audio in mp3 format.
|
||||
apk: Same as ``Filters.document.mime_type("application/vnd.android.package-archive")``.
|
||||
doc: Same as ``Filters.document.mime_type("application/msword")``.
|
||||
docx: Same as ``Filters.document.mime_type("application/vnd.openxmlformats-\
|
||||
officedocument.wordprocessingml.document")``-
|
||||
exe: Same as ``Filters.document.mime_type("application/x-ms-dos-executable")``-
|
||||
gif: Same as ``Filters.document.mime_type("video/mp4")``-
|
||||
jpg: Same as ``Filters.document.mime_type("image/jpeg")``-
|
||||
mp3: Same as ``Filters.document.mime_type("audio/mpeg")``-
|
||||
pdf: Same as ``Filters.document.mime_type("application/pdf")``-
|
||||
py: Same as ``Filters.document.mime_type("text/x-python")``-
|
||||
svg: Same as ``Filters.document.mime_type("image/svg+xml")``-
|
||||
txt: Same as ``Filters.document.mime_type("text/plain")``-
|
||||
targz: Same as ``Filters.document.mime_type("application/x-compressed-tar")``-
|
||||
wav: Same as ``Filters.document.mime_type("audio/x-wav")``-
|
||||
xml: Same as ``Filters.document.mime_type("application/xml")``-
|
||||
zip: Same as ``Filters.document.mime_type("application/zip")``-
|
||||
officedocument.wordprocessingml.document")``.
|
||||
exe: Same as ``Filters.document.mime_type("application/x-ms-dos-executable")``.
|
||||
gif: Same as ``Filters.document.mime_type("video/mp4")``.
|
||||
jpg: Same as ``Filters.document.mime_type("image/jpeg")``.
|
||||
mp3: Same as ``Filters.document.mime_type("audio/mpeg")``.
|
||||
pdf: Same as ``Filters.document.mime_type("application/pdf")``.
|
||||
py: Same as ``Filters.document.mime_type("text/x-python")``.
|
||||
svg: Same as ``Filters.document.mime_type("image/svg+xml")``.
|
||||
txt: Same as ``Filters.document.mime_type("text/plain")``.
|
||||
targz: Same as ``Filters.document.mime_type("application/x-compressed-tar")``.
|
||||
wav: Same as ``Filters.document.mime_type("audio/x-wav")``.
|
||||
xml: Same as ``Filters.document.mime_type("application/xml")``.
|
||||
zip: Same as ``Filters.document.mime_type("application/zip")``.
|
||||
file_extension: This filter filters documents by their file ending/extension.
|
||||
|
||||
Note:
|
||||
|
@ -1699,14 +1699,14 @@ officedocument.wordprocessingml.document")``-
|
|||
chat_id(:class:`telegram.utils.types.SLT[int]`, optional):
|
||||
Which sender chat chat ID(s) to allow through.
|
||||
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.
|
||||
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
|
||||
:obj:`False`
|
||||
|
||||
Raises:
|
||||
RuntimeError: If chat_id and username are both present.
|
||||
RuntimeError: If both chat_id and username are present.
|
||||
|
||||
Attributes:
|
||||
chat_ids(set(:obj:`int`), optional): Which sender chat chat ID(s) to allow through.
|
||||
|
@ -1756,7 +1756,7 @@ officedocument.wordprocessingml.document")``-
|
|||
Args:
|
||||
username(:class:`telegram.utils.types.SLT[str]`, optional):
|
||||
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)
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ class Animation(TelegramObject):
|
|||
:class:`telegram.File`
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
return self.bot.get_file(file_id=self.file_id, timeout=timeout, api_kwargs=api_kwargs)
|
||||
|
|
|
@ -117,7 +117,7 @@ class Audio(TelegramObject):
|
|||
:class:`telegram.File`
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
return self.bot.get_file(file_id=self.file_id, timeout=timeout, api_kwargs=api_kwargs)
|
||||
|
|
|
@ -95,7 +95,7 @@ class ChatPhoto(TelegramObject):
|
|||
:class:`telegram.File`
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
return self.bot.get_file(
|
||||
|
@ -112,7 +112,7 @@ class ChatPhoto(TelegramObject):
|
|||
:class:`telegram.File`
|
||||
|
||||
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)
|
||||
|
|
|
@ -104,7 +104,7 @@ class Document(TelegramObject):
|
|||
:class:`telegram.File`
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
return self.bot.get_file(file_id=self.file_id, timeout=timeout, api_kwargs=api_kwargs)
|
||||
|
|
|
@ -87,7 +87,7 @@ class PhotoSize(TelegramObject):
|
|||
:class:`telegram.File`
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
return self.bot.get_file(file_id=self.file_id, timeout=timeout, api_kwargs=api_kwargs)
|
||||
|
|
|
@ -124,7 +124,7 @@ class Sticker(TelegramObject):
|
|||
:class:`telegram.File`
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
return self.bot.get_file(file_id=self.file_id, timeout=timeout, api_kwargs=api_kwargs)
|
||||
|
|
|
@ -114,7 +114,7 @@ class Video(TelegramObject):
|
|||
:class:`telegram.File`
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
return self.bot.get_file(file_id=self.file_id, timeout=timeout, api_kwargs=api_kwargs)
|
||||
|
|
|
@ -103,7 +103,7 @@ class VideoNote(TelegramObject):
|
|||
:class:`telegram.File`
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
return self.bot.get_file(file_id=self.file_id, timeout=timeout, api_kwargs=api_kwargs)
|
||||
|
|
|
@ -87,7 +87,7 @@ class Voice(TelegramObject):
|
|||
:class:`telegram.File`
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
return self.bot.get_file(file_id=self.file_id, timeout=timeout, api_kwargs=api_kwargs)
|
||||
|
|
|
@ -41,7 +41,7 @@ class InlineKeyboardButton(TelegramObject):
|
|||
Args:
|
||||
text (:obj:`str`): Label text on the button.
|
||||
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.
|
||||
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.
|
||||
|
@ -67,7 +67,7 @@ class InlineKeyboardButton(TelegramObject):
|
|||
Attributes:
|
||||
text (:obj:`str`): Label text on the button.
|
||||
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.
|
||||
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.
|
||||
|
@ -79,7 +79,7 @@ class InlineKeyboardButton(TelegramObject):
|
|||
case just the bot’s username will be inserted.
|
||||
callback_game (:class:`telegram.CallbackGame`): Optional. Description of the game that will
|
||||
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.
|
||||
|
||||
"""
|
||||
|
||||
|
|
|
@ -829,7 +829,7 @@ class Message(TelegramObject):
|
|||
List[:class:`telegram.Message`]: An array of the sent Messages.
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
"""
|
||||
reply_to_message_id = self._quote(quote, reply_to_message_id)
|
||||
return self.bot.send_media_group(
|
||||
|
|
|
@ -33,7 +33,7 @@ class MessageEntity(TelegramObject):
|
|||
usernames, URLs, etc.
|
||||
|
||||
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:
|
||||
type (:obj:`str`): Type of the entity. Can be mention (@username), hashtag, bot_command,
|
||||
|
|
|
@ -115,7 +115,7 @@ class PassportFile(TelegramObject):
|
|||
:class:`telegram.File`
|
||||
|
||||
Raises:
|
||||
:class:`telegram.TelegramError`
|
||||
:class:`telegram.error.TelegramError`
|
||||
|
||||
"""
|
||||
file = self.bot.get_file(file_id=self.file_id, timeout=timeout, api_kwargs=api_kwargs)
|
||||
|
|
|
@ -120,7 +120,7 @@ def parse_file_input(
|
|||
|
||||
Returns:
|
||||
:obj:`str` | :class:`telegram.InputFile` | :obj:`object`: The parsed input or the untouched
|
||||
:attr:`file_input`, in case it's no valid file input.
|
||||
:attr:`file_input`, in case it's no valid file input.
|
||||
"""
|
||||
# Importing on file-level yields cyclic Import Errors
|
||||
from telegram import InputFile # pylint: disable=C0415
|
||||
|
@ -204,7 +204,8 @@ def to_float_timestamp(
|
|||
to be in UTC, if ``bot`` is not passed or ``bot.defaults`` is :obj:`None`.
|
||||
|
||||
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:
|
||||
|
||||
* :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.time` will be interpreted as a specific time of day
|
||||
|
||||
reference_timestamp (float, optional): POSIX timestamp that indicates the absolute time
|
||||
from which relative calculations are to be performed (e.g. when ``t`` is given as an
|
||||
:obj:`int`, indicating "seconds from ``reference_t``"). Defaults to now (the time at
|
||||
reference_timestamp (:obj:`float`, optional): POSIX timestamp that indicates the absolute
|
||||
time from which relative calculations are to be performed (e.g. when ``t`` is given as
|
||||
an :obj:`int`, indicating "seconds from ``reference_t``"). Defaults to now (the time at
|
||||
which this function is called).
|
||||
|
||||
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.
|
||||
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
|
||||
|
@ -230,8 +231,9 @@ def to_float_timestamp(
|
|||
|
||||
|
||||
Returns:
|
||||
(float | None) 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:`float` | :obj:`None`:
|
||||
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``.
|
||||
|
||||
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.
|
||||
|
||||
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:
|
||||
|
@ -301,16 +305,16 @@ def to_timestamp(
|
|||
def from_timestamp(unixtime: Optional[int], tzinfo: dtm.tzinfo = UTC) -> Optional[dtm.datetime]:
|
||||
"""
|
||||
Converts an (integer) unix timestamp to a timezone aware datetime object.
|
||||
: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:
|
||||
unixtime (int): Integer POSIX timestamp.
|
||||
tzinfo (:obj:`datetime.tzinfo`, optional): The timezone, the timestamp is to be converted
|
||||
to. Defaults to UTC.
|
||||
unixtime (:obj:`int`): Integer POSIX timestamp.
|
||||
tzinfo (:obj:`datetime.tzinfo`, optional): The timezone to which the timestamp is to be
|
||||
converted to. Defaults to UTC.
|
||||
|
||||
Returns:
|
||||
timezone aware equivalent :obj:`datetime.datetime` value if ``timestamp`` is not
|
||||
:obj:`None`; else :obj:`None`
|
||||
Timezone aware equivalent :obj:`datetime.datetime` value if ``unixtime`` is not
|
||||
:obj:`None`; else :obj:`None`.
|
||||
"""
|
||||
if unixtime is 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:
|
||||
"""
|
||||
Args:
|
||||
user_id (:obj:`int`) The user's id which you want to mention.
|
||||
name (:obj:`str`) The name the mention is showing.
|
||||
user_id (:obj:`int`): The user's id which you want to mention.
|
||||
name (:obj:`str`): The name the mention is showing.
|
||||
|
||||
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>'
|
||||
|
||||
|
@ -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:
|
||||
"""
|
||||
Args:
|
||||
user_id (:obj:`int`) The user's id which you want to mention.
|
||||
name (:obj:`str`) The name the mention is showing.
|
||||
version (:obj:`int` | :obj:`str`): Use to specify the version of telegrams Markdown.
|
||||
Either ``1`` or ``2``. Defaults to ``1``
|
||||
user_id (:obj:`int`): The user's id which you want to mention.
|
||||
name (:obj:`str`): The name the mention is showing.
|
||||
version (:obj:`int` | :obj:`str`): Use to specify the version of Telegram's Markdown.
|
||||
Either ``1`` or ``2``. Defaults to ``1``.
|
||||
|
||||
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})'
|
||||
|
||||
|
@ -355,10 +359,11 @@ def effective_message_type(entity: Union['Message', 'Update']) -> Optional[str]:
|
|||
:class:`telegram.Update`.
|
||||
|
||||
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:
|
||||
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:
|
||||
"""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:
|
||||
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]]:
|
||||
"""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:
|
||||
json_string (:obj:`str`): The conversations dict as JSON string.
|
||||
|
@ -500,7 +505,7 @@ class DefaultValue:
|
|||
arg = arg.value
|
||||
else:
|
||||
print('`arg` was set explicitly')
|
||||
print('`arg` = ' + str(arg))
|
||||
print(f'`arg` = {str(arg)}')
|
||||
|
||||
This yields::
|
||||
|
||||
|
@ -542,7 +547,7 @@ class DefaultValue:
|
|||
|
||||
|
||||
DEFAULT_NONE: DefaultValue = DefaultValue(None)
|
||||
""":class:`DefaultValue`: Default `None`"""
|
||||
""":class:`DefaultValue`: Default :obj:`None`"""
|
||||
|
||||
DEFAULT_FALSE: DefaultValue = DefaultValue(False)
|
||||
""":class:`DefaultValue`: Default `False`"""
|
||||
""":class:`DefaultValue`: Default :obj:`False`"""
|
||||
|
|
|
@ -1581,7 +1581,7 @@ class TestBot:
|
|||
with pytest.raises(OkException):
|
||||
bot.send_photo(chat_id, open('tests/data/telegram.jpg', 'rb'), timeout=TIMEOUT)
|
||||
|
||||
# Test JSON submition
|
||||
# Test JSON submission
|
||||
with pytest.raises(OkException):
|
||||
bot.get_chat_administrators(chat_id, timeout=TIMEOUT)
|
||||
|
||||
|
|
Loading…
Reference in a new issue