[Python] pyrogram message.message_thread_id is not working

Discussão em 'Python' iniciado por Stack, Maio 4, 2025.

  1. Stack

    Stack Membro Participativo

    I have been trying to fetch the thread id from telegram using pyrogram so far I have been successful with fetching the chat ID itself but there are errors when i try to fetch the thread id (I am using the latest version of pyrogram)

    'Message' object has no attribute 'message_thread_id'
    Traceback (most recent call last):
    File "C:\Users\--\AppData\Roaming\Python\Python312\site-packages\pyrogram\dispatcher.py", line 240, in handler_worker
    await handler.callback(self.client, *args)
    File "c:\Users\--\Desktop\TelegramBot\ChatIdFinder.py", line 23, in show_chat_and_thread
    print(f"Thread (Topic) ID: {message.message_thread_id}")
    ^^^^^^^^^^^^^^^^^^^^^^^^^
    AttributeError: 'Message' object has no attribute 'message_thread_id'


    Below are my codes

    @app.on_message(filters.group| filters.channel| filters.private)
    async def show_chat_and_thread(client,message):

    print("=" * 40)
    print(f"Chat title : {message.chat.title if message.chat.title else 'Private Chat'}")
    print(f"Chat ID : {message.chat.id}")
    print(f"Sender : {message.from_user.first_name if message.from_user else 'N/A'}")
    #print(f"Is Topic Message: {message.is_topic_message}")
    print(f"Thread (Topic) ID: {message.message_thread_id}")
    print("=" * 40)

    Continue reading...

Compartilhe esta Página