2017-12-08 22:38:59 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
#
|
|
|
|
# A library that provides a Python interface to the Telegram Bot API
|
2023-01-01 21:31:29 +01:00
|
|
|
# Copyright (C) 2015-2023
|
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."""
|
2023-02-02 18:55:07 +01:00
|
|
|
from typing import Optional, Sequence, 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
|
2022-12-15 15:00:36 +01:00
|
|
|
from telegram._utils.argumentparsing import parse_sequence_arg
|
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.
|
|
|
|
|
2023-01-01 16:24:00 +01: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
|
|
|
|
2023-01-01 16:24:00 +01:00
|
|
|
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
|
|
|
|
|
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.
|
2022-12-15 15:00:36 +01:00
|
|
|
caption_entities (Sequence[:class:`telegram.MessageEntity`], optional): |caption_entities|
|
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
|sequenceclassargs|
|
|
|
|
|
2022-11-22 10:39:20 +01:00
|
|
|
parse_mode (:obj:`str`, optional): |parse_mode|
|
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.
|
2023-01-01 16:24:00 +01:00
|
|
|
caption (:obj:`str`): Optional. Caption of the media to be sent,
|
|
|
|
0-:tg-const:`telegram.constants.MessageLimit.CAPTION_LENGTH` characters after entities
|
|
|
|
parsing.
|
|
|
|
parse_mode (:obj:`str`): Optional. |parse_mode|
|
2023-01-01 14:24:30 +01:00
|
|
|
caption_entities (Tuple[:class:`telegram.MessageEntity`]): Optional. |captionentitiesattr|
|
2022-12-15 15:00:36 +01:00
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
|
|
|
|
* |tupleclassattrs|
|
|
|
|
* |alwaystuple|
|
|
|
|
|
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],
|
2023-05-18 07:57:59 +02:00
|
|
|
caption: Optional[str] = None,
|
|
|
|
caption_entities: Optional[Sequence[MessageEntity]] = None,
|
2021-10-15 18:03:56 +02:00
|
|
|
parse_mode: ODVInput[str] = DEFAULT_NONE,
|
2022-10-07 11:51:53 +02:00
|
|
|
*,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[JSONDict] = None,
|
2021-10-15 18:03:56 +02:00
|
|
|
):
|
2022-10-07 11:51:53 +02:00
|
|
|
super().__init__(api_kwargs=api_kwargs)
|
2023-02-02 18:55:07 +01:00
|
|
|
self.type: str = media_type
|
|
|
|
self.media: Union[str, InputFile, Animation, Audio, Document, PhotoSize, Video] = media
|
|
|
|
self.caption: Optional[str] = caption
|
|
|
|
self.caption_entities: Tuple[MessageEntity, ...] = parse_sequence_arg(caption_entities)
|
|
|
|
self.parse_mode: ODVInput[str] = parse_mode
|
2020-11-29 16:20:46 +01:00
|
|
|
|
2022-12-15 15:00:36 +01:00
|
|
|
self._freeze()
|
|
|
|
|
2021-10-15 18:03:56 +02:00
|
|
|
@staticmethod
|
2023-09-03 14:23:48 +02:00
|
|
|
def _parse_thumbnail_input(thumbnail: 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 (
|
2023-09-03 14:23:48 +02:00
|
|
|
parse_file_input(thumbnail, attach=True, local_mode=True)
|
|
|
|
if thumbnail is not None
|
|
|
|
else thumbnail
|
2022-09-19 22:31:23 +02:00
|
|
|
)
|
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
|
|
|
|
2023-01-01 16:24:00 +01:00
|
|
|
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
|
|
|
|
|
2023-09-03 14:46:28 +02:00
|
|
|
.. versionchanged:: 20.5
|
2023-09-03 14:23:48 +02:00
|
|
|
|removed_thumb_note|
|
|
|
|
|
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
|
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.
|
2022-11-22 10:39:20 +01:00
|
|
|
parse_mode (:obj:`str`, optional): |parse_mode|
|
2022-12-15 15:00:36 +01:00
|
|
|
caption_entities (Sequence[:class:`telegram.MessageEntity`], optional): |caption_entities|
|
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
|sequenceclassargs|
|
|
|
|
|
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.
|
2023-01-01 17:00:49 +01:00
|
|
|
has_spoiler (:obj:`bool`, optional): Pass :obj:`True`, if the animation needs to be covered
|
|
|
|
with a spoiler animation.
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
2023-03-25 11:47:26 +01:00
|
|
|
thumbnail (:term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | :obj:`str`, \
|
|
|
|
optional): |thumbdocstringnopath|
|
|
|
|
|
2023-03-25 13:25:59 +01:00
|
|
|
.. versionadded:: 20.2
|
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.
|
2023-01-01 16:24:00 +01:00
|
|
|
caption (:obj:`str`): Optional. Caption of the animation to be sent,
|
|
|
|
0-:tg-const:`telegram.constants.MessageLimit.CAPTION_LENGTH` characters
|
|
|
|
after entities parsing.
|
2020-12-30 15:59:50 +01:00
|
|
|
parse_mode (:obj:`str`): Optional. The parse mode to use for text formatting.
|
2023-01-01 14:24:30 +01:00
|
|
|
caption_entities (Tuple[:class:`telegram.MessageEntity`]): Optional. |captionentitiesattr|
|
2022-12-15 15:00:36 +01:00
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
|
|
|
|
* |tupleclassattrs|
|
|
|
|
* |alwaystuple|
|
2020-12-30 15:59:50 +01: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.
|
2023-01-01 17:00:49 +01:00
|
|
|
has_spoiler (:obj:`bool`): Optional. :obj:`True`, if the animation is covered with a
|
|
|
|
spoiler animation.
|
2020-12-30 15:59:50 +01:00
|
|
|
|
2023-01-01 17:00:49 +01:00
|
|
|
.. versionadded:: 20.0
|
2023-03-25 11:47:26 +01:00
|
|
|
thumbnail (:class:`telegram.InputFile`): Optional. |thumbdocstringbase|
|
|
|
|
|
2023-03-25 13:25:59 +01:00
|
|
|
.. versionadded:: 20.2
|
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
|
|
|
"""
|
|
|
|
|
2023-03-25 11:47:26 +01:00
|
|
|
__slots__ = ("duration", "height", "width", "has_spoiler", "thumbnail")
|
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],
|
2023-05-18 07:57:59 +02:00
|
|
|
caption: Optional[str] = None,
|
2021-02-19 19:07:48 +01:00
|
|
|
parse_mode: ODVInput[str] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
width: Optional[int] = None,
|
|
|
|
height: Optional[int] = None,
|
|
|
|
duration: Optional[int] = None,
|
|
|
|
caption_entities: Optional[Sequence[MessageEntity]] = None,
|
|
|
|
filename: Optional[str] = None,
|
|
|
|
has_spoiler: Optional[bool] = None,
|
|
|
|
thumbnail: Optional[FileInput] = None,
|
2022-10-07 11:51:53 +02:00
|
|
|
*,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[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,
|
|
|
|
)
|
2022-12-15 15:00:36 +01:00
|
|
|
with self._unfrozen():
|
2023-09-03 14:23:48 +02:00
|
|
|
self.thumbnail: Optional[Union[str, InputFile]] = self._parse_thumbnail_input(
|
|
|
|
thumbnail
|
|
|
|
)
|
2023-02-02 18:55:07 +01:00
|
|
|
self.width: Optional[int] = width
|
|
|
|
self.height: Optional[int] = height
|
|
|
|
self.duration: Optional[int] = duration
|
|
|
|
self.has_spoiler: Optional[bool] = has_spoiler
|
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.
|
|
|
|
|
2023-01-01 16:24:00 +01:00
|
|
|
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
|
|
|
|
|
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.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.
|
2022-11-22 10:39:20 +01:00
|
|
|
parse_mode (:obj:`str`, optional): |parse_mode|
|
2022-12-15 15:00:36 +01:00
|
|
|
caption_entities (Sequence[:class:`telegram.MessageEntity`], optional): |caption_entities|
|
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
|sequenceclassargs|
|
2023-01-01 17:00:49 +01:00
|
|
|
has_spoiler (:obj:`bool`, optional): Pass :obj:`True`, if the photo needs to be covered
|
|
|
|
with a spoiler animation.
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
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.
|
2023-01-01 16:24:00 +01:00
|
|
|
caption (:obj:`str`): Optional. Caption of the photo to be sent,
|
|
|
|
0-:tg-const:`telegram.constants.MessageLimit.CAPTION_LENGTH` characters
|
|
|
|
after entities parsing.
|
|
|
|
parse_mode (:obj:`str`): Optional. |parse_mode|
|
2023-01-01 14:24:30 +01:00
|
|
|
caption_entities (Tuple[:class:`telegram.MessageEntity`]): Optional. |captionentitiesattr|
|
2022-12-15 15:00:36 +01:00
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
|
|
|
|
* |tupleclassattrs|
|
|
|
|
* |alwaystuple|
|
2023-01-01 17:00:49 +01:00
|
|
|
has_spoiler (:obj:`bool`): Optional. :obj:`True`, if the photo is covered with a
|
|
|
|
spoiler animation.
|
2020-12-30 15:59:50 +01:00
|
|
|
|
2023-01-01 17:00:49 +01:00
|
|
|
.. versionadded:: 20.0
|
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
|
|
|
"""
|
|
|
|
|
2023-01-01 17:00:49 +01:00
|
|
|
__slots__ = ("has_spoiler",)
|
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],
|
2023-05-18 07:57:59 +02:00
|
|
|
caption: Optional[str] = None,
|
2021-02-19 19:07:48 +01:00
|
|
|
parse_mode: ODVInput[str] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
caption_entities: Optional[Sequence[MessageEntity]] = None,
|
|
|
|
filename: Optional[str] = None,
|
|
|
|
has_spoiler: Optional[bool] = None,
|
2022-10-07 11:51:53 +02:00
|
|
|
*,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[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
|
|
|
|
2023-01-01 17:00:49 +01:00
|
|
|
with self._unfrozen():
|
2023-02-02 18:55:07 +01:00
|
|
|
self.has_spoiler: Optional[bool] = has_spoiler
|
2022-12-15 15:00:36 +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
|
|
|
|
|
|
|
class InputMediaVideo(InputMedia):
|
|
|
|
"""Represents a video to be sent.
|
|
|
|
|
2023-01-01 16:24:00 +01:00
|
|
|
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
|
|
|
|
|
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.
|
2023-09-03 14:23:48 +02:00
|
|
|
* :paramref:`thumbnail` will be ignored for small video files, for which Telegram can
|
|
|
|
easily generate thumbnails. However, this behaviour is undocumented and might be
|
|
|
|
changed by Telegram.
|
|
|
|
|
2023-09-03 14:46:28 +02:00
|
|
|
.. versionchanged:: 20.5
|
2023-09-03 14:23:48 +02:00
|
|
|
|removed_thumb_note|
|
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.
|
2022-11-22 10:39:20 +01:00
|
|
|
parse_mode (:obj:`str`, optional): |parse_mode|
|
2022-12-15 15:00:36 +01:00
|
|
|
caption_entities (Sequence[:class:`telegram.MessageEntity`], optional): |caption_entities|
|
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
|sequenceclassargs|
|
|
|
|
|
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.
|
2023-01-01 17:00:49 +01:00
|
|
|
has_spoiler (:obj:`bool`, optional): Pass :obj:`True`, if the video needs to be covered
|
|
|
|
with a spoiler animation.
|
|
|
|
|
|
|
|
.. versionadded:: 20.0
|
2023-03-25 11:47:26 +01:00
|
|
|
thumbnail (:term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | :obj:`str`, \
|
|
|
|
optional): |thumbdocstringnopath|
|
|
|
|
|
2023-03-25 13:25:59 +01:00
|
|
|
.. versionadded:: 20.2
|
2020-12-18 11:20:03 +01: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.VIDEO`.
|
2020-12-30 15:59:50 +01:00
|
|
|
media (:obj:`str` | :class:`telegram.InputFile`): Video file to send.
|
2023-01-01 16:24:00 +01:00
|
|
|
caption (:obj:`str`): Optional. Caption of the video to be sent,
|
|
|
|
0-:tg-const:`telegram.constants.MessageLimit.CAPTION_LENGTH` characters
|
|
|
|
after entities parsing.
|
|
|
|
parse_mode (:obj:`str`): Optional. |parse_mode|
|
2023-01-01 14:24:30 +01:00
|
|
|
caption_entities (Tuple[:class:`telegram.MessageEntity`]): Optional. |captionentitiesattr|
|
2022-12-15 15:00:36 +01:00
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
|
|
|
|
* |tupleclassattrs|
|
|
|
|
* |alwaystuple|
|
2020-12-30 15:59:50 +01: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.
|
2023-01-01 16:24:00 +01:00
|
|
|
supports_streaming (:obj:`bool`): Optional. :obj:`True`, if the uploaded video is
|
2020-12-30 15:59:50 +01:00
|
|
|
suitable for streaming.
|
2023-01-01 17:00:49 +01:00
|
|
|
has_spoiler (:obj:`bool`): Optional. :obj:`True`, if the video is covered with a
|
|
|
|
spoiler animation.
|
2020-12-30 15:59:50 +01:00
|
|
|
|
2023-01-01 17:00:49 +01:00
|
|
|
.. versionadded:: 20.0
|
2023-03-25 11:47:26 +01:00
|
|
|
thumbnail (:class:`telegram.InputFile`): Optional. |thumbdocstringbase|
|
|
|
|
|
2023-03-25 13:25:59 +01:00
|
|
|
.. versionadded:: 20.2
|
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
|
|
|
"""
|
|
|
|
|
2023-03-25 11:47:26 +01:00
|
|
|
__slots__ = (
|
|
|
|
"duration",
|
|
|
|
"height",
|
|
|
|
"supports_streaming",
|
|
|
|
"width",
|
|
|
|
"has_spoiler",
|
|
|
|
"thumbnail",
|
|
|
|
)
|
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],
|
2023-05-18 07:57:59 +02:00
|
|
|
caption: Optional[str] = None,
|
|
|
|
width: Optional[int] = None,
|
|
|
|
height: Optional[int] = None,
|
|
|
|
duration: Optional[int] = None,
|
|
|
|
supports_streaming: Optional[bool] = None,
|
2021-02-19 19:07:48 +01:00
|
|
|
parse_mode: ODVInput[str] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
caption_entities: Optional[Sequence[MessageEntity]] = None,
|
|
|
|
filename: Optional[str] = None,
|
|
|
|
has_spoiler: Optional[bool] = None,
|
|
|
|
thumbnail: Optional[FileInput] = None,
|
2022-10-07 11:51:53 +02:00
|
|
|
*,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[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,
|
|
|
|
)
|
2022-12-15 15:00:36 +01:00
|
|
|
with self._unfrozen():
|
2023-02-02 18:55:07 +01:00
|
|
|
self.width: Optional[int] = width
|
|
|
|
self.height: Optional[int] = height
|
|
|
|
self.duration: Optional[int] = duration
|
2023-09-03 14:23:48 +02:00
|
|
|
self.thumbnail: Optional[Union[str, InputFile]] = self._parse_thumbnail_input(
|
|
|
|
thumbnail
|
|
|
|
)
|
2023-02-02 18:55:07 +01:00
|
|
|
self.supports_streaming: Optional[bool] = supports_streaming
|
|
|
|
self.has_spoiler: Optional[bool] = has_spoiler
|
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.
|
|
|
|
|
2023-01-01 16:24:00 +01:00
|
|
|
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
|
|
|
|
|
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
|
|
|
|
2023-09-03 14:46:28 +02:00
|
|
|
.. versionchanged:: 20.5
|
2023-09-03 14:23:48 +02:00
|
|
|
|removed_thumb_note|
|
|
|
|
|
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.
|
2022-11-22 10:39:20 +01:00
|
|
|
parse_mode (:obj:`str`, optional): |parse_mode|
|
2022-12-15 15:00:36 +01:00
|
|
|
caption_entities (Sequence[:class:`telegram.MessageEntity`], optional): |caption_entities|
|
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
|sequenceclassargs|
|
|
|
|
|
2023-01-01 16:24:00 +01:00
|
|
|
duration (:obj:`int`, optional): Duration of the audio in seconds as defined by sender.
|
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
|
|
|
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.
|
2023-03-25 11:47:26 +01:00
|
|
|
thumbnail (:term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | :obj:`str`, \
|
|
|
|
optional): |thumbdocstringnopath|
|
|
|
|
|
2023-03-25 13:25:59 +01:00
|
|
|
.. versionadded:: 20.2
|
2023-03-25 11:47:26 +01: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.AUDIO`.
|
2020-12-30 15:59:50 +01:00
|
|
|
media (:obj:`str` | :class:`telegram.InputFile`): Audio file to send.
|
2023-01-01 16:24:00 +01:00
|
|
|
caption (:obj:`str`): Optional. Caption of the audio to be sent,
|
|
|
|
0-:tg-const:`telegram.constants.MessageLimit.CAPTION_LENGTH` characters
|
|
|
|
after entities parsing.
|
|
|
|
parse_mode (:obj:`str`): Optional. |parse_mode|
|
2023-01-01 14:24:30 +01:00
|
|
|
caption_entities (Tuple[:class:`telegram.MessageEntity`]): Optional. |captionentitiesattr|
|
2022-12-15 15:00:36 +01:00
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
|
|
|
|
* |tupleclassattrs|
|
|
|
|
* |alwaystuple|
|
2023-01-01 16:24:00 +01:00
|
|
|
duration (:obj:`int`): Optional. Duration of the audio in seconds.
|
2020-12-30 15:59:50 +01:00
|
|
|
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.
|
2023-03-25 11:47:26 +01:00
|
|
|
thumbnail (:class:`telegram.InputFile`): Optional. |thumbdocstringbase|
|
|
|
|
|
2023-03-25 13:25:59 +01:00
|
|
|
.. versionadded:: 20.2
|
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
|
|
|
"""
|
|
|
|
|
2023-03-25 11:47:26 +01:00
|
|
|
__slots__ = ("duration", "performer", "title", "thumbnail")
|
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],
|
2023-05-18 07:57:59 +02:00
|
|
|
caption: Optional[str] = None,
|
2021-02-19 19:07:48 +01:00
|
|
|
parse_mode: ODVInput[str] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
duration: Optional[int] = None,
|
|
|
|
performer: Optional[str] = None,
|
|
|
|
title: Optional[str] = None,
|
|
|
|
caption_entities: Optional[Sequence[MessageEntity]] = None,
|
|
|
|
filename: Optional[str] = None,
|
|
|
|
thumbnail: Optional[FileInput] = None,
|
2022-10-07 11:51:53 +02:00
|
|
|
*,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[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,
|
|
|
|
)
|
2022-12-15 15:00:36 +01:00
|
|
|
with self._unfrozen():
|
2023-09-03 14:23:48 +02:00
|
|
|
self.thumbnail: Optional[Union[str, InputFile]] = self._parse_thumbnail_input(
|
|
|
|
thumbnail
|
|
|
|
)
|
2023-02-02 18:55:07 +01:00
|
|
|
self.duration: Optional[int] = duration
|
|
|
|
self.title: Optional[str] = title
|
|
|
|
self.performer: Optional[str] = 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.
|
|
|
|
|
2023-01-01 16:24:00 +01:00
|
|
|
.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
|
|
|
|
|
2023-09-03 14:46:28 +02:00
|
|
|
.. versionchanged:: 20.5
|
2023-09-03 14:23:48 +02:00
|
|
|
|removed_thumb_note|
|
|
|
|
|
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.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.
|
2022-11-22 10:39:20 +01:00
|
|
|
parse_mode (:obj:`str`, optional): |parse_mode|
|
2022-12-15 15:00:36 +01:00
|
|
|
caption_entities (Sequence[:class:`telegram.MessageEntity`], optional): |caption_entities|
|
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
|sequenceclassargs|
|
|
|
|
|
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.
|
2023-03-25 11:47:26 +01:00
|
|
|
thumbnail (:term:`file object` | :obj:`bytes` | :class:`pathlib.Path` | :obj:`str`, \
|
|
|
|
optional): |thumbdocstringnopath|
|
|
|
|
|
2023-03-25 13:25:59 +01:00
|
|
|
.. versionadded:: 20.2
|
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.
|
2023-01-01 16:24:00 +01:00
|
|
|
caption (:obj:`str`): Optional. Caption of the document to be sent,
|
|
|
|
0-:tg-const:`telegram.constants.MessageLimit.CAPTION_LENGTH` characters
|
|
|
|
after entities parsing.
|
|
|
|
parse_mode (:obj:`str`): Optional. |parse_mode|
|
2023-01-01 14:24:30 +01:00
|
|
|
caption_entities (Tuple[:class:`telegram.MessageEntity`]): Optional. |captionentitiesattr|
|
2022-12-15 15:00:36 +01:00
|
|
|
|
|
|
|
.. versionchanged:: 20.0
|
|
|
|
|
|
|
|
* |tupleclassattrs|
|
|
|
|
* |alwaystuple|
|
2020-12-30 15:59:50 +01:00
|
|
|
disable_content_type_detection (:obj:`bool`): Optional. Disables automatic server-side
|
2023-01-01 16:24:00 +01:00
|
|
|
content type detection for files uploaded using multipart/form-data. Always
|
|
|
|
:obj:`True`, if the document is sent as part of an album.
|
2023-03-25 11:47:26 +01:00
|
|
|
thumbnail (:class:`telegram.InputFile`): Optional. |thumbdocstringbase|
|
2020-12-30 15:59:50 +01:00
|
|
|
|
2023-03-25 13:25:59 +01:00
|
|
|
.. versionadded:: 20.2
|
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
|
|
|
"""
|
|
|
|
|
2023-03-25 11:47:26 +01:00
|
|
|
__slots__ = ("disable_content_type_detection", "thumbnail")
|
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],
|
2023-05-18 07:57:59 +02:00
|
|
|
caption: Optional[str] = None,
|
2021-02-19 19:07:48 +01:00
|
|
|
parse_mode: ODVInput[str] = DEFAULT_NONE,
|
2023-05-18 07:57:59 +02:00
|
|
|
disable_content_type_detection: Optional[bool] = None,
|
|
|
|
caption_entities: Optional[Sequence[MessageEntity]] = None,
|
|
|
|
filename: Optional[str] = None,
|
|
|
|
thumbnail: Optional[FileInput] = None,
|
2022-10-07 11:51:53 +02:00
|
|
|
*,
|
2023-05-18 07:57:59 +02:00
|
|
|
api_kwargs: Optional[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)
|
2023-03-25 11:47:26 +01:00
|
|
|
|
2022-10-07 11:51:53 +02:00
|
|
|
super().__init__(
|
|
|
|
InputMediaType.DOCUMENT,
|
|
|
|
media,
|
|
|
|
caption,
|
|
|
|
caption_entities,
|
|
|
|
parse_mode,
|
|
|
|
api_kwargs=api_kwargs,
|
|
|
|
)
|
2022-12-15 15:00:36 +01:00
|
|
|
with self._unfrozen():
|
2023-09-03 14:23:48 +02:00
|
|
|
self.thumbnail: Optional[Union[str, InputFile]] = self._parse_thumbnail_input(
|
|
|
|
thumbnail
|
|
|
|
)
|
2023-02-02 18:55:07 +01:00
|
|
|
self.disable_content_type_detection: Optional[bool] = disable_content_type_detection
|