Fix copy methods spoilers

This commit is contained in:
KurimuzonAkuma 2024-05-15 18:54:23 +03:00
parent 0d61c4ef7e
commit cc4aa8a2d3
2 changed files with 15 additions and 5 deletions

View File

@ -30,6 +30,7 @@ class CopyMediaGroup:
from_chat_id: Union[int, str], from_chat_id: Union[int, str],
message_id: int, message_id: int,
captions: Union[List[str], str] = None, captions: Union[List[str], str] = None,
has_spoilers: Union[List[bool], bool] = None,
disable_notification: bool = None, disable_notification: bool = None,
message_thread_id: int = None, message_thread_id: int = None,
reply_to_message_id: int = None, reply_to_message_id: int = None,
@ -137,7 +138,19 @@ class CopyMediaGroup:
else: else:
raise ValueError("Message with this type can't be copied.") raise ValueError("Message with this type can't be copied.")
media = utils.get_input_media_from_file_id(file_id=file_id) media = utils.get_input_media_from_file_id(
file_id=file_id,
has_spoiler=(
has_spoilers[i]
if isinstance(has_spoilers, list)
and i < len(has_spoilers)
else (
has_spoilers
if isinstance(has_spoilers, bool)
else message.has_media_spoiler
)
),
)
multi_media.append( multi_media.append(
raw.types.InputSingleMedia( raw.types.InputSingleMedia(
media=media, media=media,

View File

@ -4102,9 +4102,6 @@ class Message(Object, Update):
protect_content (``bool``, *optional*): protect_content (``bool``, *optional*):
Protects the contents of the sent message from forwarding and saving. Protects the contents of the sent message from forwarding and saving.
has_spoiler (``bool``, *optional*):
True, if the message media is covered by a spoiler animation.
business_connection_id (``str``, *optional*): business_connection_id (``str``, *optional*):
Unique identifier of the business connection on behalf of which the message will be sent. Unique identifier of the business connection on behalf of which the message will be sent.
@ -4158,7 +4155,7 @@ class Message(Object, Update):
quote_entities=quote_entities, quote_entities=quote_entities,
schedule_date=schedule_date, schedule_date=schedule_date,
protect_content=protect_content, protect_content=protect_content,
has_spoiler=has_spoiler, has_spoiler=self.has_media_spoiler if has_spoiler is None else has_spoiler,
business_connection_id=business_connection_id, business_connection_id=business_connection_id,
reply_markup=self.reply_markup if reply_markup is object else reply_markup reply_markup=self.reply_markup if reply_markup is object else reply_markup
) )