Skip to content

'MessageReplyStoryHeader' object has no attribute 'forum_topic' #22

Closed
@makarovstas

Description

Checklist

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

Description

When I trying to get messages history, if message contain reply_to field with reference to MessageReplyStoryHeader, it cause an error 'MessageReplyStoryHeader' object has no attribute 'forum_topic'

Steps to reproduce

  1. Init hydrogram Client
  2. Try to load chat messages history
  3. If message object have reply_to field with reference to MessageReplyStoryHeader, you catch has no attribute 'forum_topic' error

Code example

from hydrogram import Client

async with Client('login', session_string=session_string, in_memory=True) as app:
    async for message in app.get_chat_history(dialog.chat.id):
        ....

Logs

AttributeError: 'MessageReplyStoryHeader' object has no attribute 'forum_topic'
  File "telegram/tasks.py", line 683, in get_dialogs
    async for message in app.get_chat_history(dialog.chat.id, limit=0):
  File "hydrogram/methods/messages/get_chat_history.py", line 103, in get_chat_history
    messages = await get_chunk(
  File "hydrogram/methods/messages/get_chat_history.py", line 51, in get_chunk
    return await utils.parse_messages(client, messages, replies=0)
  File "hydrogram/utils.py", line 107, in parse_messages
    parsed_messages = [
  File "hydrogram/utils.py", line 108, in <listcomp>
    await types.Message._parse(
  File "hydrogram/types/messages_and_media/message.py", line 990, in _parse
    if message.reply_to.forum_topic:

---------------
Variables:
"from_id":"None"
"is_scheduled":"False"                                                                                      
"message":"hydrogram.raw.types.Message(id=339206, peer_id=hydrogram.raw.types.PeerUser(user_id=5973756389), date=1695579441, message='Text message sample with reply to stories', out=False, mentioned=False, media_unread=False, silent=False, post=False, from_scheduled=False, legacy=False, edit_hide=False, pinned=False, noforwards=False, invert_media=False, reply_to=hydrogram.raw.types.MessageReplyStoryHeader(peer=hydrogram.raw.types.PeerUser(user_id=5204243573), story_id=105), entities=[], restriction_reason=[])"
"peer_id":"5973756389"
"replies":"0"
"topics":"None"
"user_id":"5973756389"

Metadata

Assignees

No one assigned

    Labels

    bugSomething is wrong

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions