2017-12-08 22:38:59 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
#
|
|
|
|
# A library that provides a Python interface to the Telegram Bot API
|
2022-01-03 08:15:18 +01:00
|
|
|
# Copyright (C) 2015-2022
|
2017-12-08 22:38:59 +01:00
|
|
|
# Leandro Toledo de Souza <devs@python-telegram-bot.org>
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Lesser Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Lesser Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser Public License
|
|
|
|
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
|
|
|
"""Base class for Telegram InputMedia Objects."""
|
2022-05-05 09:27:54 +02:00
|
|
|
from typing import List, Optional, Tuple, Union
|
2020-11-29 16:20:46 +01:00
|
|
|
|
2022-05-05 09:27:54 +02:00
|
|
|
from telegram._files.animation import Animation
|
|
|
|
from telegram._files.audio import Audio
|
|
|
|
from telegram._files.document import Document
|
|
|
|
from telegram._files.inputfile import InputFile
|
|
|
|
from telegram._files.photosize import PhotoSize
|
|
|
|
from telegram._files.video import Video
|
|
|
|
from telegram._messageentity import MessageEntity
|
|
|
|
from telegram._telegramobject import TelegramObject
|
2021-10-10 15:10:21 +02:00
|
|
|
from telegram._utils.defaultvalue import DEFAULT_NONE
|
|
|
|
from telegram._utils.files import parse_file_input
|
|
|
|
from telegram._utils.types import FileInput, JSONDict, ODVInput
|
2021-10-19 18:28:19 +02:00
|
|
|
from telegram.constants import InputMediaType
|
2017-12-08 22:38:59 +01:00
|
|
|
|
2021-10-15 18:03:56 +02:00
|
|
|
MediaType = Union[Animation, Audio, Document, PhotoSize, Video]
|
|
|
|
|
2017-12-08 22:38:59 +01:00
|
|
|
|
|
|
|
class InputMedia(TelegramObject):
|
2021-10-15 18:03:56 +02:00
|
|
|
"""
|
|
|
|
Base class for Telegram InputMedia Objects.
|
|
|
|
|
2022-05-06 17:15:23 +02:00
|
|
|
.. versionchanged:: 20.0:
|
2022-02-09 17:30:16 +01:00
|
|
|
Added arguments and attributes :attr:`type`, :attr:`media`, :attr:`caption`,
|
|
|
|
:attr:`caption_entities`, :paramref:`parse_mode`.
|
2017-12-08 22:38:59 +01:00
|
|
|
|
2021-10-15 18:03:56 +02:00
|
|
|
Args:
|
2022-04-24 12:38:09 +02:00
|
|
|
media_type (:obj:`str`): Type of media that the instance represents.
|
2022-02-09 17:30:16 +01:00
|
|
|
media (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | \
|
2021-10-15 18:03:56 +02:00
|
|
|
:class:`telegram.Animation` | :class:`telegram.Audio` | \
|
|
|
|
:class:`telegram.Document` | :class:`telegram.PhotoSize` | \
|
2022-09-19 22:31:23 +02:00
|
|
|
:class:`telegram.Video`): File to send.
|
|
|
|
|fileinputnopath|
|
2021-10-15 18:03:56 +02:00
|
|
|
Lastly you can pass an existing telegram media object of the corresponding type
|
|
|
|
to send.
|
2022-04-24 12:38:09 +02:00
|
|
|
caption (:obj:`str`, optional): Caption of the media to be sent,
|
|
|
|
0-:tg-const:`telegram.constants.MessageLimit.CAPTION_LENGTH` characters after entities
|
|
|
|
parsing.
|
2021-10-15 18:03:56 +02:00
|
|
|
caption_entities (List[:class:`telegram.MessageEntity`], optional): List of special
|
2022-04-24 12:38:09 +02:00
|
|
|
entities that appear in the caption, which can be specified instead of
|
|
|
|
:paramref:`parse_mode`.
|
2021-10-15 18:03:56 +02:00
|
|
|
parse_mode (:obj:`str`, optional): Send Markdown or HTML, if you want Telegram apps to show
|
|
|
|
bold, italic, fixed-width text or inline URLs in the media caption. See the constants
|
2021-10-19 18:28:19 +02:00
|
|
|
in :class:`telegram.constants.ParseMode` for the available modes.
|
2017-12-08 22:38:59 +01:00
|
|
|
|
2021-10-15 18:03:56 +02:00
|
|
|
Attributes:
|
|
|
|
type (:obj:`str`): Type of the input media.
|
|
|
|
media (:obj:`str` | :class:`telegram.InputFile`): Media to send.
|
|
|
|
caption (:obj:`str`): Optional. Caption of the media to be sent.
|
|
|
|
parse_mode (:obj:`str`): Optional. The parse mode to use for text formatting.
|
|
|
|
caption_entities (List[:class:`telegram.MessageEntity`]): Optional. List of special
|
|
|
|
entities that appear in the caption.
|
2017-12-08 22:38:59 +01:00
|
|
|
"""
|
2020-10-09 17:22:07 +02:00
|
|
|
|
2021-10-15 18:03:56 +02:00
|
|
|
__slots__ = ("caption", "caption_entities", "media", "parse_mode", "type")
|
|
|
|
|
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
media_type: str,
|
|
|
|
media: Union[str, InputFile, MediaType],
|
|
|
|
caption: str = None,
|
|
|
|
caption_entities: Union[List[MessageEntity], Tuple[MessageEntity, ...]] = None,
|
|
|
|
parse_mode: ODVInput[str] = DEFAULT_NONE,
|
2022-10-07 11:51:53 +02:00
|
|
|
*,
|
|
|
|
api_kwargs: JSONDict = None,
|
2021-10-15 18:03:56 +02:00
|
|
|
):
|
2022-10-07 11:51:53 +02:00
|
|
|
super().__init__(api_kwargs=api_kwargs)
|
2021-10-15 18:03:56 +02:00
|
|
|
self.type = media_type
|
|
|
|
self.media = media
|
|
|
|
self.caption = caption
|
|
|
|
self.caption_entities = caption_entities
|
|
|
|
self.parse_mode = parse_mode
|
2020-11-29 16:20:46 +01:00
|
|
|
|
2021-10-15 18:03:56 +02:00
|
|
|
@staticmethod
|
|
|
|
def _parse_thumb_input(thumb: Optional[FileInput]) -> Optional[Union[str, InputFile]]:
|
2022-09-19 22:31:23 +02:00
|
|
|
# We use local_mode=True because we don't have access to the actual setting and want
|
|
|
|
# things to work in local mode.
|
|
|
|
return (
|
|
|
|
parse_file_input(thumb, attach=True, local_mode=True) if thumb is not None else thumb
|
|
|
|
)
|
2021-10-15 18:03:56 +02:00
|
|
|
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
|
|
|
|
class InputMediaAnimation(InputMedia):
|
|
|
|
"""Represents an animation file (GIF or H.264/MPEG-4 AVC video without sound) to be sent.
|
|
|
|
|
2020-12-30 15:59:50 +01:00
|
|
|
Note:
|
2022-04-24 12:38:09 +02:00
|
|
|
When using a :class:`telegram.Animation` for the :attr:`media` attribute, it will take the
|
2020-12-30 15:59:50 +01:00
|
|
|
width, height and duration from that video, unless otherwise specified with the optional
|
|
|
|
arguments.
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
|
|
|
|
Args:
|
2022-02-09 17:30:16 +01:00
|
|
|
media (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | \
|
2022-09-19 22:31:23 +02:00
|
|
|
:class:`telegram.Animation`): File to send. |fileinputnopath|
|
|
|
|
Lastly you can pass an existing :class:`telegram.Animation` object to send.
|
2020-12-18 11:20:03 +01:00
|
|
|
|
|
|
|
.. versionchanged:: 13.2
|
|
|
|
Accept :obj:`bytes` as input.
|
2020-12-16 14:28:53 +01:00
|
|
|
filename (:obj:`str`, optional): Custom file name for the animation, when uploading a
|
|
|
|
new file. Convenience parameter, useful e.g. when sending files generated by the
|
|
|
|
:obj:`tempfile` module.
|
2020-12-17 19:05:12 +01:00
|
|
|
|
2022-09-19 22:31:23 +02:00
|
|
|
.. versionadded:: 13.1
|
|
|
|
thumb (:term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | :obj:`str`, \
|
|
|
|
optional): |thumbdocstringnopath|
|
2020-12-18 11:20:03 +01:00
|
|
|
|
|
|
|
.. versionchanged:: 13.2
|
|
|
|
Accept :obj:`bytes` as input.
|
2021-10-19 18:28:19 +02:00
|
|
|
caption (:obj:`str`, optional): Caption of the animation to be sent,
|
|
|
|
0-:tg-const:`telegram.constants.MessageLimit.CAPTION_LENGTH` characters
|
2020-03-28 11:49:47 +01:00
|
|
|
after entities parsing.
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
parse_mode (:obj:`str`, optional): Send Markdown or HTML, if you want Telegram apps to show
|
|
|
|
bold, italic, fixed-width text or inline URLs in the media caption. See the constants
|
2021-10-19 18:28:19 +02:00
|
|
|
in :class:`telegram.constants.ParseMode` for the available modes.
|
2020-11-29 16:20:46 +01:00
|
|
|
caption_entities (List[:class:`telegram.MessageEntity`], optional): List of special
|
2022-04-24 12:38:09 +02:00
|
|
|
entities that appear in the caption, which can be specified instead of
|
|
|
|
:paramref:`parse_mode`.
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
width (:obj:`int`, optional): Animation width.
|
|
|
|
height (:obj:`int`, optional): Animation height.
|
2021-12-13 18:21:38 +01:00
|
|
|
duration (:obj:`int`, optional): Animation duration in seconds.
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
|
2020-12-30 15:59:50 +01:00
|
|
|
Attributes:
|
2021-10-19 18:28:19 +02:00
|
|
|
type (:obj:`str`): :tg-const:`telegram.constants.InputMediaType.ANIMATION`.
|
2020-12-30 15:59:50 +01:00
|
|
|
media (:obj:`str` | :class:`telegram.InputFile`): Animation to send.
|
|
|
|
caption (:obj:`str`): Optional. Caption of the document to be sent.
|
|
|
|
parse_mode (:obj:`str`): Optional. The parse mode to use for text formatting.
|
|
|
|
caption_entities (List[:class:`telegram.MessageEntity`]): Optional. List of special
|
|
|
|
entities that appear in the caption.
|
|
|
|
thumb (:class:`telegram.InputFile`): Optional. Thumbnail of the file to send.
|
|
|
|
width (:obj:`int`): Optional. Animation width.
|
|
|
|
height (:obj:`int`): Optional. Animation height.
|
2021-12-13 18:21:38 +01:00
|
|
|
duration (:obj:`int`): Optional. Animation duration in seconds.
|
2020-12-30 15:59:50 +01:00
|
|
|
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
"""
|
|
|
|
|
2021-10-15 18:03:56 +02:00
|
|
|
__slots__ = ("duration", "height", "thumb", "width")
|
2021-05-29 16:18:16 +02:00
|
|
|
|
2020-02-06 11:22:56 +01:00
|
|
|
def __init__(
|
|
|
|
self,
|
2020-11-29 16:20:46 +01:00
|
|
|
media: Union[FileInput, Animation],
|
|
|
|
thumb: FileInput = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
caption: str = None,
|
2021-02-19 19:07:48 +01:00
|
|
|
parse_mode: ODVInput[str] = DEFAULT_NONE,
|
2020-10-06 19:28:40 +02:00
|
|
|
width: int = None,
|
|
|
|
height: int = None,
|
|
|
|
duration: int = None,
|
2020-11-29 16:20:46 +01:00
|
|
|
caption_entities: Union[List[MessageEntity], Tuple[MessageEntity, ...]] = None,
|
2020-12-16 14:28:53 +01:00
|
|
|
filename: str = None,
|
2022-10-07 11:51:53 +02:00
|
|
|
*,
|
|
|
|
api_kwargs: JSONDict = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
):
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
if isinstance(media, Animation):
|
2021-10-15 18:03:56 +02:00
|
|
|
width = media.width if width is None else width
|
|
|
|
height = media.height if height is None else height
|
|
|
|
duration = media.duration if duration is None else duration
|
|
|
|
media = media.file_id
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
else:
|
2022-09-19 22:31:23 +02:00
|
|
|
# We use local_mode=True because we don't have access to the actual setting and want
|
|
|
|
# things to work in local mode.
|
|
|
|
media = parse_file_input(media, filename=filename, attach=True, local_mode=True)
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
|
2022-10-07 11:51:53 +02:00
|
|
|
super().__init__(
|
|
|
|
InputMediaType.ANIMATION,
|
|
|
|
media,
|
|
|
|
caption,
|
|
|
|
caption_entities,
|
|
|
|
parse_mode,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2021-10-15 18:03:56 +02:00
|
|
|
self.thumb = self._parse_thumb_input(thumb)
|
|
|
|
self.width = width
|
|
|
|
self.height = height
|
|
|
|
self.duration = duration
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
|
|
|
|
|
|
|
|
class InputMediaPhoto(InputMedia):
|
|
|
|
"""Represents a photo to be sent.
|
|
|
|
|
|
|
|
Args:
|
2022-02-09 17:30:16 +01:00
|
|
|
media (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | \
|
2022-09-19 22:31:23 +02:00
|
|
|
:class:`telegram.PhotoSize`): File to send. |fileinputnopath|
|
|
|
|
Lastly you can pass an existing :class:`telegram.PhotoSize` object to send.
|
2020-12-18 11:20:03 +01:00
|
|
|
|
|
|
|
.. versionchanged:: 13.2
|
|
|
|
Accept :obj:`bytes` as input.
|
2020-12-16 14:28:53 +01:00
|
|
|
filename (:obj:`str`, optional): Custom file name for the photo, when uploading a
|
|
|
|
new file. Convenience parameter, useful e.g. when sending files generated by the
|
|
|
|
:obj:`tempfile` module.
|
2020-12-17 19:05:12 +01:00
|
|
|
|
2022-09-19 22:31:23 +02:00
|
|
|
.. versionadded:: 13.1
|
2021-10-19 18:28:19 +02:00
|
|
|
caption (:obj:`str`, optional ): Caption of the photo to be sent,
|
|
|
|
0-:tg-const:`telegram.constants.MessageLimit.CAPTION_LENGTH` characters after
|
2020-03-28 11:49:47 +01:00
|
|
|
entities parsing.
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
parse_mode (:obj:`str`, optional): Send Markdown or HTML, if you want Telegram apps to show
|
|
|
|
bold, italic, fixed-width text or inline URLs in the media caption. See the constants
|
2021-10-19 18:28:19 +02:00
|
|
|
in :class:`telegram.constants.ParseMode` for the available modes.
|
2020-11-29 16:20:46 +01:00
|
|
|
caption_entities (List[:class:`telegram.MessageEntity`], optional): List of special
|
2022-04-24 12:38:09 +02:00
|
|
|
entities that appear in the caption, which can be specified instead of
|
|
|
|
:paramref:`parse_mode`.
|
2020-12-30 15:59:50 +01:00
|
|
|
|
|
|
|
Attributes:
|
2021-10-19 18:28:19 +02:00
|
|
|
type (:obj:`str`): :tg-const:`telegram.constants.InputMediaType.PHOTO`.
|
2020-12-30 15:59:50 +01:00
|
|
|
media (:obj:`str` | :class:`telegram.InputFile`): Photo to send.
|
|
|
|
caption (:obj:`str`): Optional. Caption of the document to be sent.
|
|
|
|
parse_mode (:obj:`str`): Optional. The parse mode to use for text formatting.
|
|
|
|
caption_entities (List[:class:`telegram.MessageEntity`]): Optional. List of special
|
|
|
|
entities that appear in the caption.
|
|
|
|
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
"""
|
|
|
|
|
2021-10-15 18:03:56 +02:00
|
|
|
__slots__ = ()
|
2021-05-29 16:18:16 +02:00
|
|
|
|
2020-10-06 19:28:40 +02:00
|
|
|
def __init__(
|
|
|
|
self,
|
2020-11-29 16:20:46 +01:00
|
|
|
media: Union[FileInput, PhotoSize],
|
2020-10-06 19:28:40 +02:00
|
|
|
caption: str = None,
|
2021-02-19 19:07:48 +01:00
|
|
|
parse_mode: ODVInput[str] = DEFAULT_NONE,
|
2020-11-29 16:20:46 +01:00
|
|
|
caption_entities: Union[List[MessageEntity], Tuple[MessageEntity, ...]] = None,
|
2020-12-16 14:28:53 +01:00
|
|
|
filename: str = None,
|
2022-10-07 11:51:53 +02:00
|
|
|
*,
|
|
|
|
api_kwargs: JSONDict = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
):
|
2022-09-19 22:31:23 +02:00
|
|
|
# We use local_mode=True because we don't have access to the actual setting and want
|
|
|
|
# things to work in local mode.
|
|
|
|
media = parse_file_input(media, PhotoSize, filename=filename, attach=True, local_mode=True)
|
2022-10-07 11:51:53 +02:00
|
|
|
super().__init__(
|
|
|
|
InputMediaType.PHOTO,
|
|
|
|
media,
|
|
|
|
caption,
|
|
|
|
caption_entities,
|
|
|
|
parse_mode,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
|
|
|
|
|
|
|
|
class InputMediaVideo(InputMedia):
|
|
|
|
"""Represents a video to be sent.
|
|
|
|
|
2020-12-30 15:59:50 +01:00
|
|
|
Note:
|
2022-04-24 12:38:09 +02:00
|
|
|
* When using a :class:`telegram.Video` for the :attr:`media` attribute, it will take the
|
2020-12-30 15:59:50 +01:00
|
|
|
width, height and duration from that video, unless otherwise specified with the optional
|
|
|
|
arguments.
|
2022-04-24 12:38:09 +02:00
|
|
|
* :paramref:`thumb` will be ignored for small video files, for which Telegram can easily
|
2021-10-15 18:03:56 +02:00
|
|
|
generate thumbnails. However, this behaviour is undocumented and might be changed
|
2020-12-30 15:59:50 +01:00
|
|
|
by Telegram.
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
|
|
|
|
Args:
|
2022-02-09 17:30:16 +01:00
|
|
|
media (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | \
|
2022-09-19 22:31:23 +02:00
|
|
|
:class:`telegram.Video`): File to send. |fileinputnopath|
|
|
|
|
Lastly you can pass an existing :class:`telegram.Video` object to send.
|
2020-12-18 11:20:03 +01:00
|
|
|
|
|
|
|
.. versionchanged:: 13.2
|
|
|
|
Accept :obj:`bytes` as input.
|
2020-12-16 14:28:53 +01:00
|
|
|
filename (:obj:`str`, optional): Custom file name for the video, when uploading a
|
|
|
|
new file. Convenience parameter, useful e.g. when sending files generated by the
|
|
|
|
:obj:`tempfile` module.
|
2020-12-17 19:05:12 +01:00
|
|
|
|
2022-09-19 22:31:23 +02:00
|
|
|
.. versionadded:: 13.1
|
2021-10-19 18:28:19 +02:00
|
|
|
caption (:obj:`str`, optional): Caption of the video to be sent,
|
|
|
|
0-:tg-const:`telegram.constants.MessageLimit.CAPTION_LENGTH` characters after
|
2020-03-28 11:49:47 +01:00
|
|
|
entities parsing.
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
parse_mode (:obj:`str`, optional): Send Markdown or HTML, if you want Telegram apps to show
|
|
|
|
bold, italic, fixed-width text or inline URLs in the media caption. See the constants
|
2021-10-19 18:28:19 +02:00
|
|
|
in :class:`telegram.constants.ParseMode` for the available modes.
|
2020-11-29 16:20:46 +01:00
|
|
|
caption_entities (List[:class:`telegram.MessageEntity`], optional): List of special
|
2022-04-24 12:38:09 +02:00
|
|
|
entities that appear in the caption, which can be specified instead of
|
|
|
|
:paramref:`parse_mode`.
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
width (:obj:`int`, optional): Video width.
|
|
|
|
height (:obj:`int`, optional): Video height.
|
2021-12-13 18:21:38 +01:00
|
|
|
duration (:obj:`int`, optional): Video duration in seconds.
|
Documentation Improvements (#2008)
* Minor doc updates, following official API docs
* Fix spelling in Defaults docstrings
* Clarify Changelog of v12.7 about aware dates
* Fix typo in CHANGES.rst (#2024)
* Fix PicklePersistence.flush() with only bot_data (#2017)
* Update pylint in pre-commit to fix CI (#2018)
* Add Filters.via_bot (#2009)
* feat: via_bot filter
also fixing a small mistake in the empty parameter of the user filter and improve docs slightly
* fix: forgot to set via_bot to None
* fix: redoing subclassing to copy paste solution
* Cosmetic changes
Co-authored-by: Hinrich Mahler <hinrich.mahler@freenet.de>
* Update CHANGES.rst
Fixed Typo
Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
* Update downloads badge, add info on IRC Channel to Getting Help section
* Remove RegexHandler from ConversationHandlers Docs (#1973)
Replaced RegexHandler with MessageHandler, since the former is deprecated
* Fix Filters.via_bot docstrings
* Add notes on Markdown v1 being legacy mode
* Fixed typo in the Regex doc.. (#2036)
* Typo: Spelling
* Minor cleanup from #2043
* Document CommandHandler ignoring channel posts
* Doc fixes for a few telegram.ext classes
* Doc fixes for most `telegram` classes.
* pep-8
forgot the hard wrap is at 99 chars, not 100!
fixed a few spelling mistakes too.
* Address review and made rendering of booleans consistent
True, False, None are now rendered with ``bool`` wherever they weren't in telegram and telegram.ext classes.
* Few doc fixes for inline* classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram/files classes
As usual, docs were cross-checked with official tg api docs.
* Doc fixes for telegram.Game
Mostly just added hyperlinks. And fixed message length doc.
As usual, docs were cross-checked with official tg api docs.
* Very minor doc fix for passportfile.py and passportelementerrors.py
Didn't bother changing too much since this seems to be a custom implementation.
* Doc fixes for telegram.payments
As usual, cross-checked with official bot api docs.
* Address review 2
Few tiny other fixes too.
* Changed from ``True/False/None`` to :obj:`True/False/None` project-wide.
Few tiny other doc fixes too.
Co-authored-by: Robert Geislinger <mitachundkrach@gmail.com>
Co-authored-by: Poolitzer <25934244+Poolitzer@users.noreply.github.com>
Co-authored-by: GauthamramRavichandran <30320759+GauthamramRavichandran@users.noreply.github.com>
Co-authored-by: Mahesh19 <maheshvagicherla99438@gmail.com>
Co-authored-by: hoppingturtles <ilovebhagwan@gmail.com>
2020-08-24 19:35:57 +02:00
|
|
|
supports_streaming (:obj:`bool`, optional): Pass :obj:`True`, if the uploaded video is
|
|
|
|
suitable for streaming.
|
2022-09-19 22:31:23 +02:00
|
|
|
thumb (:term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | :obj:`str`, \
|
|
|
|
optional): |thumbdocstringnopath|
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
|
2020-12-18 11:20:03 +01:00
|
|
|
.. versionchanged:: 13.2
|
|
|
|
Accept :obj:`bytes` as input.
|
|
|
|
|
2020-12-30 15:59:50 +01:00
|
|
|
Attributes:
|
2021-10-19 18:28:19 +02:00
|
|
|
type (:obj:`str`): :tg-const:`telegram.constants.InputMediaType.VIDEO`.
|
2020-12-30 15:59:50 +01:00
|
|
|
media (:obj:`str` | :class:`telegram.InputFile`): Video file to send.
|
|
|
|
caption (:obj:`str`): Optional. Caption of the document to be sent.
|
|
|
|
parse_mode (:obj:`str`): Optional. The parse mode to use for text formatting.
|
|
|
|
caption_entities (List[:class:`telegram.MessageEntity`]): Optional. List of special
|
|
|
|
entities that appear in the caption.
|
|
|
|
width (:obj:`int`): Optional. Video width.
|
|
|
|
height (:obj:`int`): Optional. Video height.
|
2021-12-13 18:21:38 +01:00
|
|
|
duration (:obj:`int`): Optional. Video duration in seconds.
|
2020-12-30 15:59:50 +01:00
|
|
|
supports_streaming (:obj:`bool`): Optional. Pass :obj:`True`, if the uploaded video is
|
|
|
|
suitable for streaming.
|
|
|
|
thumb (:class:`telegram.InputFile`): Optional. Thumbnail of the file to send.
|
|
|
|
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
"""
|
|
|
|
|
2021-10-15 18:03:56 +02:00
|
|
|
__slots__ = ("duration", "height", "thumb", "supports_streaming", "width")
|
2021-05-29 16:18:16 +02:00
|
|
|
|
2020-10-06 19:28:40 +02:00
|
|
|
def __init__(
|
|
|
|
self,
|
2020-11-29 16:20:46 +01:00
|
|
|
media: Union[FileInput, Video],
|
2020-10-06 19:28:40 +02:00
|
|
|
caption: str = None,
|
|
|
|
width: int = None,
|
|
|
|
height: int = None,
|
|
|
|
duration: int = None,
|
|
|
|
supports_streaming: bool = None,
|
2021-02-19 19:07:48 +01:00
|
|
|
parse_mode: ODVInput[str] = DEFAULT_NONE,
|
2020-11-29 16:20:46 +01:00
|
|
|
thumb: FileInput = None,
|
|
|
|
caption_entities: Union[List[MessageEntity], Tuple[MessageEntity, ...]] = None,
|
2020-12-16 14:28:53 +01:00
|
|
|
filename: str = None,
|
2022-10-07 11:51:53 +02:00
|
|
|
*,
|
|
|
|
api_kwargs: JSONDict = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
):
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
|
|
|
|
if isinstance(media, Video):
|
2021-10-15 18:03:56 +02:00
|
|
|
width = width if width is not None else media.width
|
|
|
|
height = height if height is not None else media.height
|
|
|
|
duration = duration if duration is not None else media.duration
|
|
|
|
media = media.file_id
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
else:
|
2022-09-19 22:31:23 +02:00
|
|
|
# We use local_mode=True because we don't have access to the actual setting and want
|
|
|
|
# things to work in local mode.
|
|
|
|
media = parse_file_input(media, filename=filename, attach=True, local_mode=True)
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
|
2022-10-07 11:51:53 +02:00
|
|
|
super().__init__(
|
|
|
|
InputMediaType.VIDEO,
|
|
|
|
media,
|
|
|
|
caption,
|
|
|
|
caption_entities,
|
|
|
|
parse_mode,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2021-10-15 18:03:56 +02:00
|
|
|
self.width = width
|
|
|
|
self.height = height
|
|
|
|
self.duration = duration
|
|
|
|
self.thumb = self._parse_thumb_input(thumb)
|
|
|
|
self.supports_streaming = supports_streaming
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
|
|
|
|
|
|
|
|
class InputMediaAudio(InputMedia):
|
|
|
|
"""Represents an audio file to be treated as music to be sent.
|
|
|
|
|
2020-12-30 15:59:50 +01:00
|
|
|
Note:
|
2022-04-24 12:38:09 +02:00
|
|
|
When using a :class:`telegram.Audio` for the :attr:`media` attribute, it will take the
|
2020-12-30 15:59:50 +01:00
|
|
|
duration, performer and title from that video, unless otherwise specified with the
|
|
|
|
optional arguments.
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
|
|
|
|
Args:
|
2022-02-09 17:30:16 +01:00
|
|
|
media (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | \
|
2022-09-19 22:31:23 +02:00
|
|
|
:class:`telegram.Audio`): File to send. |fileinputnopath|
|
|
|
|
Lastly you can pass an existing :class:`telegram.Audio` object to send.
|
2020-12-18 11:20:03 +01:00
|
|
|
|
|
|
|
.. versionchanged:: 13.2
|
|
|
|
Accept :obj:`bytes` as input.
|
2020-12-16 14:28:53 +01:00
|
|
|
filename (:obj:`str`, optional): Custom file name for the audio, when uploading a
|
|
|
|
new file. Convenience parameter, useful e.g. when sending files generated by the
|
|
|
|
:obj:`tempfile` module.
|
2020-12-17 19:05:12 +01:00
|
|
|
|
2022-09-19 22:31:23 +02:00
|
|
|
.. versionadded:: 13.1
|
2021-10-19 18:28:19 +02:00
|
|
|
caption (:obj:`str`, optional): Caption of the audio to be sent,
|
|
|
|
0-:tg-const:`telegram.constants.MessageLimit.CAPTION_LENGTH` characters after
|
2020-03-28 11:49:47 +01:00
|
|
|
entities parsing.
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
parse_mode (:obj:`str`, optional): Send Markdown or HTML, if you want Telegram apps to show
|
|
|
|
bold, italic, fixed-width text or inline URLs in the media caption. See the constants
|
2021-10-19 18:28:19 +02:00
|
|
|
in :class:`telegram.constants.ParseMode` for the available modes.
|
2020-11-29 16:20:46 +01:00
|
|
|
caption_entities (List[:class:`telegram.MessageEntity`], optional): List of special
|
2022-04-24 12:38:09 +02:00
|
|
|
entities that appear in the caption, which can be specified instead of
|
|
|
|
:paramref:`parse_mode`.
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
duration (:obj:`int`): Duration of the audio in seconds as defined by sender.
|
|
|
|
performer (:obj:`str`, optional): Performer of the audio as defined by sender or by audio
|
|
|
|
tags.
|
|
|
|
title (:obj:`str`, optional): Title of the audio as defined by sender or by audio tags.
|
2022-09-19 22:31:23 +02:00
|
|
|
thumb (:term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | :obj:`str`, \
|
|
|
|
optional): |thumbdocstringnopath|
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
|
2020-12-18 11:20:03 +01:00
|
|
|
.. versionchanged:: 13.2
|
|
|
|
Accept :obj:`bytes` as input.
|
|
|
|
|
2020-12-30 15:59:50 +01:00
|
|
|
Attributes:
|
2021-10-19 18:28:19 +02:00
|
|
|
type (:obj:`str`): :tg-const:`telegram.constants.InputMediaType.AUDIO`.
|
2020-12-30 15:59:50 +01:00
|
|
|
media (:obj:`str` | :class:`telegram.InputFile`): Audio file to send.
|
|
|
|
caption (:obj:`str`): Optional. Caption of the document to be sent.
|
|
|
|
parse_mode (:obj:`str`): Optional. The parse mode to use for text formatting.
|
|
|
|
caption_entities (List[:class:`telegram.MessageEntity`]): Optional. List of special
|
|
|
|
entities that appear in the caption.
|
|
|
|
duration (:obj:`int`): Duration of the audio in seconds.
|
|
|
|
performer (:obj:`str`): Optional. Performer of the audio as defined by sender or by audio
|
|
|
|
tags.
|
|
|
|
title (:obj:`str`): Optional. Title of the audio as defined by sender or by audio tags.
|
|
|
|
thumb (:class:`telegram.InputFile`): Optional. Thumbnail of the file to send.
|
|
|
|
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
"""
|
|
|
|
|
2021-10-15 18:03:56 +02:00
|
|
|
__slots__ = ("duration", "performer", "thumb", "title")
|
2021-05-29 16:18:16 +02:00
|
|
|
|
2020-10-06 19:28:40 +02:00
|
|
|
def __init__(
|
|
|
|
self,
|
2020-11-29 16:20:46 +01:00
|
|
|
media: Union[FileInput, Audio],
|
|
|
|
thumb: FileInput = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
caption: str = None,
|
2021-02-19 19:07:48 +01:00
|
|
|
parse_mode: ODVInput[str] = DEFAULT_NONE,
|
2020-10-06 19:28:40 +02:00
|
|
|
duration: int = None,
|
|
|
|
performer: str = None,
|
|
|
|
title: str = None,
|
2020-11-29 16:20:46 +01:00
|
|
|
caption_entities: Union[List[MessageEntity], Tuple[MessageEntity, ...]] = None,
|
2020-12-16 14:28:53 +01:00
|
|
|
filename: str = None,
|
2022-10-07 11:51:53 +02:00
|
|
|
*,
|
|
|
|
api_kwargs: JSONDict = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
):
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
if isinstance(media, Audio):
|
2021-10-15 18:03:56 +02:00
|
|
|
duration = media.duration if duration is None else duration
|
|
|
|
performer = media.performer if performer is None else performer
|
|
|
|
title = media.title if title is None else title
|
|
|
|
media = media.file_id
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
else:
|
2022-09-19 22:31:23 +02:00
|
|
|
# We use local_mode=True because we don't have access to the actual setting and want
|
|
|
|
# things to work in local mode.
|
|
|
|
media = parse_file_input(media, filename=filename, attach=True, local_mode=True)
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
|
2022-10-07 11:51:53 +02:00
|
|
|
super().__init__(
|
|
|
|
InputMediaType.AUDIO,
|
|
|
|
media,
|
|
|
|
caption,
|
|
|
|
caption_entities,
|
|
|
|
parse_mode,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2021-10-15 18:03:56 +02:00
|
|
|
self.thumb = self._parse_thumb_input(thumb)
|
|
|
|
self.duration = duration
|
|
|
|
self.title = title
|
|
|
|
self.performer = performer
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
|
|
|
|
|
|
|
|
class InputMediaDocument(InputMedia):
|
|
|
|
"""Represents a general file to be sent.
|
|
|
|
|
|
|
|
Args:
|
2022-02-09 17:30:16 +01:00
|
|
|
media (:obj:`str` | :term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | \
|
2022-09-19 22:31:23 +02:00
|
|
|
:class:`telegram.Document`): File to send. |fileinputnopath|
|
|
|
|
Lastly you can pass an existing :class:`telegram.Document` object to send.
|
2020-12-18 11:20:03 +01:00
|
|
|
|
|
|
|
.. versionchanged:: 13.2
|
|
|
|
Accept :obj:`bytes` as input.
|
2020-12-16 14:28:53 +01:00
|
|
|
filename (:obj:`str`, optional): Custom file name for the document, when uploading a
|
|
|
|
new file. Convenience parameter, useful e.g. when sending files generated by the
|
|
|
|
:obj:`tempfile` module.
|
2020-12-17 19:05:12 +01:00
|
|
|
|
2022-09-19 22:31:23 +02:00
|
|
|
.. versionadded:: 13.1
|
2021-10-19 18:28:19 +02:00
|
|
|
caption (:obj:`str`, optional): Caption of the document to be sent,
|
|
|
|
0-:tg-const:`telegram.constants.MessageLimit.CAPTION_LENGTH` characters after
|
2020-03-28 11:49:47 +01:00
|
|
|
entities parsing.
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
parse_mode (:obj:`str`, optional): Send Markdown or HTML, if you want Telegram apps to show
|
|
|
|
bold, italic, fixed-width text or inline URLs in the media caption. See the constants
|
2021-10-19 18:28:19 +02:00
|
|
|
in :class:`telegram.constants.ParseMode` for the available modes.
|
2020-11-29 16:20:46 +01:00
|
|
|
caption_entities (List[:class:`telegram.MessageEntity`], optional): List of special
|
2022-04-24 12:38:09 +02:00
|
|
|
entities that appear in the caption, which can be specified instead of
|
|
|
|
:paramref:`parse_mode`.
|
2022-09-19 22:31:23 +02:00
|
|
|
thumb (:term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | :obj:`str`, \
|
|
|
|
optional): |thumbdocstringnopath|
|
2020-12-18 11:20:03 +01:00
|
|
|
|
|
|
|
.. versionchanged:: 13.2
|
|
|
|
Accept :obj:`bytes` as input.
|
2020-11-29 16:20:46 +01:00
|
|
|
disable_content_type_detection (:obj:`bool`, optional): Disables automatic server-side
|
2022-04-24 12:38:09 +02:00
|
|
|
content type detection for files uploaded using multipart/form-data. Always
|
|
|
|
:obj:`True`, if the document is sent as part of an album.
|
2020-12-30 15:59:50 +01:00
|
|
|
|
|
|
|
Attributes:
|
2021-10-19 18:28:19 +02:00
|
|
|
type (:obj:`str`): :tg-const:`telegram.constants.InputMediaType.DOCUMENT`.
|
2020-12-30 15:59:50 +01:00
|
|
|
media (:obj:`str` | :class:`telegram.InputFile`): File to send.
|
|
|
|
caption (:obj:`str`): Optional. Caption of the document to be sent.
|
|
|
|
parse_mode (:obj:`str`): Optional. The parse mode to use for text formatting.
|
|
|
|
caption_entities (List[:class:`telegram.MessageEntity`]): Optional. List of special
|
|
|
|
entities that appear in the caption.
|
|
|
|
thumb (:class:`telegram.InputFile`): Optional. Thumbnail of the file to send.
|
|
|
|
disable_content_type_detection (:obj:`bool`): Optional. Disables automatic server-side
|
|
|
|
content type detection for files uploaded using multipart/form-data. Always true, if
|
|
|
|
the document is sent as part of an album.
|
|
|
|
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
"""
|
|
|
|
|
2021-10-15 18:03:56 +02:00
|
|
|
__slots__ = ("disable_content_type_detection", "thumb")
|
2021-05-29 16:18:16 +02:00
|
|
|
|
2020-10-06 19:28:40 +02:00
|
|
|
def __init__(
|
|
|
|
self,
|
2020-11-29 16:20:46 +01:00
|
|
|
media: Union[FileInput, Document],
|
|
|
|
thumb: FileInput = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
caption: str = None,
|
2021-02-19 19:07:48 +01:00
|
|
|
parse_mode: ODVInput[str] = DEFAULT_NONE,
|
2020-11-29 16:20:46 +01:00
|
|
|
disable_content_type_detection: bool = None,
|
|
|
|
caption_entities: Union[List[MessageEntity], Tuple[MessageEntity, ...]] = None,
|
2020-12-16 14:28:53 +01:00
|
|
|
filename: str = None,
|
2022-10-07 11:51:53 +02:00
|
|
|
*,
|
|
|
|
api_kwargs: JSONDict = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
):
|
2022-09-19 22:31:23 +02:00
|
|
|
# We use local_mode=True because we don't have access to the actual setting and want
|
|
|
|
# things to work in local mode.
|
|
|
|
media = parse_file_input(media, Document, filename=filename, attach=True, local_mode=True)
|
2022-10-07 11:51:53 +02:00
|
|
|
super().__init__(
|
|
|
|
InputMediaType.DOCUMENT,
|
|
|
|
media,
|
|
|
|
caption,
|
|
|
|
caption_entities,
|
|
|
|
parse_mode,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2021-10-15 18:03:56 +02:00
|
|
|
self.thumb = self._parse_thumb_input(thumb)
|
2020-11-29 16:20:46 +01:00
|
|
|
self.disable_content_type_detection = disable_content_type_detection
|