[Python] Pyrogram does not recognize message_entities

Discussão em 'Python' iniciado por Stack, Novembro 30, 2025.

  1. Stack

    Stack Membro Participativo

    I have a problem with forwarding messages with caption_entities. Attached below is the code that I use to make the transfer itself, as well as the result of its operation. The result shows that pyrogram lost the entity and sent it without them for a reason unknown to me.

    enter code here
    from pyrogram import Client
    from pyrogram.types import Message
    from pyrogram.types import ChatPrivileges, InputMediaPhoto, InputMediaVideo

    client = Client()
    group_id = -1
    @client.on_message()
    async def handler(client: Client, message: Message):
    global group_id
    if group_id != -1:
    return
    group_id = message.media_group_id
    msg_group = []; media = []
    async for msg in client.get_chat_history(chat_id=message.chat.id, limit=10):
    if msg.media_group_id == group_id:
    msg_group.append(msg)
    else:
    break
    for m in msg_group:
    if m.photo:
    media.append(InputMediaPhoto(media=m.photo.file_id, caption=m.caption if m.caption else None, caption_entities=m.caption_entities if m.caption_entities else None))
    elif m.video:
    media.append(InputMediaVideo(media=m.video.file_id, caption=m.caption if m.caption else None, caption_entities=m.caption_entities if m.caption_entities else None))

    await client.send_media_group(chat_id=message.chat.id, media=media[::-1])
    group_id = -1

    client.run()


    [​IMG]

    Continue reading...

Compartilhe esta Página