[Python] Not receiving message updates in a particular telegram channel

Discussão em 'Python' iniciado por Stack, Julho 9, 2025.

  1. Stack

    Stack Membro Participativo

    I'm not receiving message updates in a particular telegram channel ( using my pyrogram script )

    • Yes the channel ID is correct
    • Yes I've tried using both the channel username and changing to the channel ID
    • Yes my userbot( my account) is a member of the channel
    • Yes I can manually forward messages from the source channel to my destination channel
    • No the channel doesn't have "protected content" or "restrict forwarding" turned on

    What I've tried:

    • Edited my script so I can get a "new message received" for all messages in my account
    • It updates me for everyother messages received in many other channels groups and private messages except the main channel I'm particularly interested in

    What I want:

    • To get a "New message received" from that particular channel as seen in my program
    • Or to be able to extract a url from the message and / or forward the message

    But all of those can't work if I don't even get the message received update

    Pyrogram version 2.0.106 Python 3.12.10 This my code:

    from pyrogram import Client, filters
    from pyrogram.errors import RPCError

    app = Client("my_account") # my_account.session already initiated

    # TEMPORARILY REMOVE THE FILTERS.CHAT()
    @app.on_message() # No filter here so I can listen to everything

    async def debug_handler(client, message):
    chat_id = message.chat.id if message.chat else "No Chat"
    chat_title = message.chat.title if message.chat and message.chat.title else "No Title"

    print('')
    print(f"--- New Message Received ---")
    print(f"Message ID: {message.id}")
    print(f"Chat ID: {chat_id}")
    print(f"Chat Title: {chat_title}")
    print(f"From User: {message.from_user.username if message.from_user else 'N/A'}")
    print(f"Message Text: {message.text[:50] if message.text else 'N/A'}...") # Print first 50 chars
    print(f"Is from main: {message.chat and message.chat.id == -1001234567890}") #
    print(f"--------------------------")
    print('')

    # Now, try to forward ONLY if it's from the target channel
    target_channel_id = -1001234567890 # Replace with the actual numeric ID of my target/source channel

    if message.chat and message.chat.id == target_channel_id:
    try:
    await message.forward("@xyz")
    print(f"DEBUG: Successfully attempted to forward message {message.id} to @xyz.") # @xyz an example of my destination channel

    except RPCError as e:
    print(f"DEBUG: RPCError during forwarding message {message.id}: {e}")

    except Exception as e:
    print(f"DEBUG: Unexpected error during forwarding message {message.id}: {e}")

    else:
    print("DEBUG: Message not from target channel, skipping forward.")

    app.run()


    When I run this code, I get the expected "New message received, chat ID etc " for every other message coming in my account

    Except the main channel I'm targeting

    ( * The many prints in my code is for ease of debugging so I can find out if and at what stage my code is having problems interacting with the channel

    Continue reading...

Compartilhe esta Página