2017-07-01 17:08:45 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
#
|
|
|
|
# A library that provides a Python interface to the Telegram Bot API
|
2022-01-03 08:15:18 +01:00
|
|
|
# Copyright (C) 2015-2022
|
2017-07-01 17:08:45 +02: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/].
|
|
|
|
"""This module contains an object that represents a Telegram ChatPhoto."""
|
2022-10-07 11:51:53 +02:00
|
|
|
from typing import TYPE_CHECKING
|
2017-07-01 17:08:45 +02:00
|
|
|
|
2022-05-05 09:27:54 +02:00
|
|
|
from telegram._telegramobject import TelegramObject
|
2021-10-10 15:10:21 +02:00
|
|
|
from telegram._utils.defaultvalue import DEFAULT_NONE
|
|
|
|
from telegram._utils.types import JSONDict, ODVInput
|
2020-10-09 17:22:07 +02:00
|
|
|
|
2020-10-06 19:28:40 +02:00
|
|
|
if TYPE_CHECKING:
|
2022-10-07 11:51:53 +02:00
|
|
|
from telegram import File
|
2020-10-06 19:28:40 +02:00
|
|
|
|
2017-07-01 17:08:45 +02:00
|
|
|
|
|
|
|
class ChatPhoto(TelegramObject):
|
2017-09-01 08:43:08 +02:00
|
|
|
"""This object represents a chat photo.
|
2017-07-01 17:08:45 +02:00
|
|
|
|
2020-07-14 21:33:56 +02:00
|
|
|
Objects of this class are comparable in terms of equality. Two objects of this class are
|
|
|
|
considered equal, if their :attr:`small_file_unique_id` and :attr:`big_file_unique_id` are
|
|
|
|
equal.
|
|
|
|
|
2017-07-01 17:08:45 +02:00
|
|
|
Args:
|
2020-03-28 16:37:26 +01:00
|
|
|
small_file_id (:obj:`str`): Unique file identifier of small (160x160) chat photo. This
|
|
|
|
file_id can be used only for photo download and only for as long
|
|
|
|
as the photo is not changed.
|
|
|
|
small_file_unique_id (:obj:`str`): Unique file identifier of small (160x160) chat photo,
|
|
|
|
which is supposed to be the same over time and for different bots.
|
|
|
|
Can't be used to download or reuse the file.
|
|
|
|
big_file_id (:obj:`str`): Unique file identifier of big (640x640) chat photo. This file_id
|
|
|
|
can be used only for photo download and only for as long as the photo is not changed.
|
|
|
|
big_file_unique_id (:obj:`str`): Unique file identifier of big (640x640) chat photo,
|
|
|
|
which is supposed to be the same over time and for different bots.
|
|
|
|
Can't be used to download or reuse the file.
|
2017-09-01 08:43:08 +02:00
|
|
|
|
2020-12-30 15:59:50 +01:00
|
|
|
Attributes:
|
|
|
|
small_file_id (:obj:`str`): File identifier of small (160x160) chat photo.
|
|
|
|
This file_id can be used only for photo download and only for as long
|
|
|
|
as the photo is not changed.
|
|
|
|
small_file_unique_id (:obj:`str`): Unique file identifier of small (160x160) chat photo,
|
|
|
|
which is supposed to be the same over time and for different bots.
|
|
|
|
Can't be used to download or reuse the file.
|
|
|
|
big_file_id (:obj:`str`): File identifier of big (640x640) chat photo.
|
|
|
|
This file_id can be used only for photo download and only for as long as
|
|
|
|
the photo is not changed.
|
|
|
|
big_file_unique_id (:obj:`str`): Unique file identifier of big (640x640) chat photo,
|
|
|
|
which is supposed to be the same over time and for different bots.
|
|
|
|
Can't be used to download or reuse the file.
|
|
|
|
|
2017-07-01 17:08:45 +02:00
|
|
|
"""
|
2017-07-23 22:33:08 +02:00
|
|
|
|
2021-05-29 16:18:16 +02:00
|
|
|
__slots__ = (
|
|
|
|
"big_file_unique_id",
|
|
|
|
"small_file_id",
|
|
|
|
"small_file_unique_id",
|
|
|
|
"big_file_id",
|
|
|
|
)
|
|
|
|
|
2020-03-28 16:37:26 +01:00
|
|
|
def __init__(
|
2020-11-05 18:12:01 +01:00
|
|
|
self,
|
2020-10-06 19:28:40 +02:00
|
|
|
small_file_id: str,
|
|
|
|
small_file_unique_id: str,
|
|
|
|
big_file_id: str,
|
|
|
|
big_file_unique_id: str,
|
2022-10-07 11:51:53 +02:00
|
|
|
*,
|
|
|
|
api_kwargs: JSONDict = None,
|
2020-10-06 19:28:40 +02:00
|
|
|
):
|
2022-10-07 11:51:53 +02:00
|
|
|
super().__init__(api_kwargs=api_kwargs)
|
2017-07-01 17:08:45 +02:00
|
|
|
self.small_file_id = small_file_id
|
2020-03-28 16:37:26 +01:00
|
|
|
self.small_file_unique_id = small_file_unique_id
|
2017-07-01 17:08:45 +02:00
|
|
|
self.big_file_id = big_file_id
|
2020-03-28 16:37:26 +01:00
|
|
|
self.big_file_unique_id = big_file_unique_id
|
|
|
|
|
|
|
|
self._id_attrs = (
|
|
|
|
self.small_file_unique_id,
|
|
|
|
self.big_file_unique_id,
|
|
|
|
)
|
2017-07-01 17:08:45 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def get_small_file(
|
|
|
|
self,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
api_kwargs: JSONDict = None,
|
2021-02-19 19:07:48 +01:00
|
|
|
) -> "File":
|
2019-09-13 21:07:56 +02:00
|
|
|
"""Convenience wrapper over :attr:`telegram.Bot.get_file` for getting the
|
|
|
|
small (160x160) chat photo
|
|
|
|
|
2020-12-30 13:41:07 +01:00
|
|
|
For the documentation of the arguments, please see :meth:`telegram.Bot.get_file`.
|
2019-09-13 21:07:56 +02:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
:class:`telegram.File`
|
|
|
|
|
|
|
|
Raises:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2019-09-13 21:07:56 +02:00
|
|
|
|
|
|
|
"""
|
2022-04-24 12:38:09 +02:00
|
|
|
return await self.get_bot().get_file(
|
|
|
|
file_id=self.small_file_id,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
2020-12-30 13:41:07 +01:00
|
|
|
)
|
2019-09-13 21:07:56 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def get_big_file(
|
|
|
|
self,
|
2022-05-18 17:18:44 +02:00
|
|
|
*,
|
2022-04-24 12:38:09 +02:00
|
|
|
read_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
write_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
connect_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
pool_timeout: ODVInput[float] = DEFAULT_NONE,
|
|
|
|
api_kwargs: JSONDict = None,
|
2021-02-19 19:07:48 +01:00
|
|
|
) -> "File":
|
2019-09-13 21:07:56 +02:00
|
|
|
"""Convenience wrapper over :attr:`telegram.Bot.get_file` for getting the
|
|
|
|
big (640x640) chat photo
|
|
|
|
|
2020-12-30 13:41:07 +01:00
|
|
|
For the documentation of the arguments, please see :meth:`telegram.Bot.get_file`.
|
2019-09-13 21:07:56 +02:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
:class:`telegram.File`
|
|
|
|
|
|
|
|
Raises:
|
2021-02-01 17:59:39 +01:00
|
|
|
:class:`telegram.error.TelegramError`
|
2019-09-13 21:07:56 +02:00
|
|
|
|
|
|
|
"""
|
2022-04-24 12:38:09 +02:00
|
|
|
return await self.get_bot().get_file(
|
|
|
|
file_id=self.big_file_id,
|
|
|
|
read_timeout=read_timeout,
|
|
|
|
write_timeout=write_timeout,
|
|
|
|
connect_timeout=connect_timeout,
|
|
|
|
pool_timeout=pool_timeout,
|
|
|
|
api_kwargs=api_kwargs,
|
2021-10-21 11:17:12 +02:00
|
|
|
)
|