Allow sending audio playlists
This commit is contained in:
parent
832f1f6d53
commit
fe16dc8043
@ -34,7 +34,7 @@ class SendMediaGroup(Scaffold):
|
||||
async def send_media_group(
|
||||
self,
|
||||
chat_id: Union[int, str],
|
||||
media: List[Union["types.InputMediaPhoto", "types.InputMediaVideo"]],
|
||||
media: List[Union["types.InputMediaPhoto", "types.InputMediaVideo", "types.InputMediaAudio"]],
|
||||
disable_notification: bool = None,
|
||||
reply_to_message_id: int = None
|
||||
) -> List["types.Message"]:
|
||||
@ -152,6 +152,53 @@ class SendMediaGroup(Scaffold):
|
||||
)
|
||||
)
|
||||
|
||||
media = raw.types.InputMediaDocument(
|
||||
id=raw.types.InputDocument(
|
||||
id=media.document.id,
|
||||
access_hash=media.document.access_hash,
|
||||
file_reference=media.document.file_reference
|
||||
)
|
||||
)
|
||||
else:
|
||||
media = utils.get_input_media_from_file_id(i.media, i.file_ref, 4)
|
||||
elif isinstance(i, types.InputMediaAudio):
|
||||
if os.path.isfile(i.media):
|
||||
media = await self.send(
|
||||
raw.functions.messages.UploadMedia(
|
||||
peer=await self.resolve_peer(chat_id),
|
||||
media=raw.types.InputMediaUploadedDocument(
|
||||
mime_type=self.guess_mime_type(i.media) or "audio/mpeg",
|
||||
file=await self.save_file(i.media),
|
||||
thumb=await self.save_file(i.thumb),
|
||||
attributes=[
|
||||
raw.types.DocumentAttributeAudio(
|
||||
duration=i.duration,
|
||||
performer=i.performer,
|
||||
title=i.title
|
||||
),
|
||||
raw.types.DocumentAttributeFilename(file_name=os.path.basename(i.media))
|
||||
]
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
media = raw.types.InputMediaDocument(
|
||||
id=raw.types.InputDocument(
|
||||
id=media.document.id,
|
||||
access_hash=media.document.access_hash,
|
||||
file_reference=media.document.file_reference
|
||||
)
|
||||
)
|
||||
elif re.match("^https?://", i.media):
|
||||
media = await self.send(
|
||||
raw.functions.messages.UploadMedia(
|
||||
peer=await self.resolve_peer(chat_id),
|
||||
media=raw.types.InputMediaDocumentExternal(
|
||||
url=i.media
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
media = raw.types.InputMediaDocument(
|
||||
id=raw.types.InputDocument(
|
||||
id=media.document.id,
|
||||
|
Loading…
Reference in New Issue
Block a user