Skip to content
This repository was archived by the owner on Sep 14, 2026. It is now read-only.
This repository was archived by the owner on Sep 14, 2026. It is now read-only.

send_media_group() throws topics error but still sends media (Regression in 2.3.69) #167

Description

@ISmartThinker

Checklist

  • I am sure the error is coming from Pyrofork's code and not elsewhere
  • I have searched in the issue tracker for similar bug reports, including closed ones
  • I ran pip3 install -U git+https://github.com/Mayuri-Chan/pyrofork and reproduced the issue using the latest development version

Description

After upgrading pyrofork from 2.3.68 to 2.3.69.dev1 / 2.3.69, send_media_group() raises an exception related to topics, even though the media group is sent successfully.
This did not happen in 2.3.68, so this is a regression.

Steps to reproduce

After upgrading pyrofork from 2.3.68 to 2.3.69.dev1 / 2.3.69, send_media_group() raises an exception related to topics, even though the media group is sent successfully.
This did not happen in 2.3.68, so this is a regression.
Error
Copy code
Text
TypeError: Messages.init() missing 1 required keyword-only argument: 'topics'
Trying to manually pass topics results in:
Copy code
Text
TypeError: SendMediaGroup.send_media_group() got an unexpected keyword argument 'topics'
Expected
No exception when media is sent successfully
Or topics handled internally / officially supported
Actual
Media group is delivered
Pyrofork throws an exception afterward, breaking handlers
Versions
✅ 2.3.68 — works
❌ 2.3.69.dev1 — broken
❌ 2.3.69 — broken
Notes
Looks like raw.types.messages.Messages now requires topics, but send_media_group() neither sets a default nor exposes it, causing a post-send failure.
Impact
False errors in production bots despite successful delivery.

Code example

@dp.message(Command(commands=["in", "insta", "ig"], prefix=BotCommands))
@new_task
@SmartDefender
async def insta_handler(message: Message, bot: Bot):
    progress_message = None
    
    try:
        url = None
        args = get_args(message)
        
        if args:
            match = re.search(r"https?://(www\.)?instagram\.com/\S+", args[0])
            if match:
                url = match.group(0)
        elif message.reply_to_message and message.reply_to_message.text:
            match = re.search(r"https?://(www\.)?instagram\.com/\S+", message.reply_to_message.text)
            if match:
                url = match.group(0)
        
        if not url:
            progress_message = await send_message(
                chat_id=message.chat.id,
                text="<b>Please provide a valid Instagram URL or reply to a message with one ❌</b>",
                parse_mode=SmartParseMode.HTML
            )
            return
        
        content_type = "reel" if "/reel/" in url else "igtv" if "/tv/" in url else "story" if "/stories/" in url else "post"
        
        progress_message = await send_message(
            chat_id=message.chat.id,
            text="<b>Searching The Video...</b>" if content_type in ["reel", "igtv"] else "<code>🔍 Fetching media from Instagram...</code>",
            parse_mode=SmartParseMode.HTML
        )
        
        ig_downloader = InstagramDownloader(Config.TEMP_DIR)
        content_info = await ig_downloader.download_content(url, progress_message, content_type)
        
        if not content_info:
            await delete_messages(message.chat.id, progress_message.message_id)
            await send_message(
                chat_id=message.chat.id,
                text="<b>Unable To Extract The URL 😕</b>",
                parse_mode=SmartParseMode.HTML
            )
            return
        
        media_files = content_info["media_files"]
        content_type = content_info["type"]
        
        if content_type in ["carousel", "image"]:
            await progress_message.edit_text(
                "<code>📤 Uploading...</code>",
                parse_mode=SmartParseMode.HTML
            )
        
        try:
            if content_type == "carousel" and len(media_files) > 1:
                for i in range(0, len(media_files), Config.MAX_MEDIA_PER_GROUP):
                    media_group = []
                    for media in media_files[i:i + Config.MAX_MEDIA_PER_GROUP]:
                        if media["type"] == "image":
                            media_group.append(
                                InputMediaPhoto(
                                    media=media["filename"]
                                )
                            )
                        else:
                            media_group.append(
                                InputMediaVideo(
                                    media=media["filename"],
                                    thumb=media["thumbnail"] if media["thumbnail"] else None,
                                    supports_streaming=True
                                )
                            )
                    
                    await SmartPyro.send_media_group(
                        chat_id=message.chat.id,
                        media=media_group
                    )
            else:
                media = media_files[0]
                if media["type"] == "video":
                    await SmartPyro.send_video(
                        chat_id=message.chat.id,
                        video=media["filename"],
                        thumb=media["thumbnail"] if media["thumbnail"] else None,
                        supports_streaming=True
                    )
                else:
                    await SmartPyro.send_photo(
                        chat_id=message.chat.id,
                        photo=media["filename"]
                    )
            
            await delete_messages(message.chat.id, progress_message.message_id)

Logs

Traceback (most recent call last):
  File "/root/SmartUtilBot/bot/modules/insta.py", line 220, in insta_handler
    await SmartPyro.send_media_group(
  File "/usr/local/lib/python3.10/dist-packages/pyrogram/methods/messages/send_media_group.py", line 549, in send_media_group
    raw.types.messages.Messages(
TypeError: Messages.init() missing 1 required keyword-only argument: 'topics'

Traceback (most recent call last):
  File "/root/SmartUtilBot/bot/modules/insta.py", line 233, in insta_handler
    await SmartPyro.send_media_group(
  File "/usr/local/lib/python3.10/dist-packages/pyrogram/sync.py", line 54, in async_to_sync_wrap
    coroutine = function(*args, **kwargs)
TypeError: SendMediaGroup.send_media_group() got an unexpected keyword argument 'topics'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions