pythonpython-telegram-botaiogram

how to find users who forwarded messages to a group using aiogram 3


how to find users who forwarded messages to a group using aiogram 3. that is, if someone forwards messages in the group, the bot should alert the admin. is it possible to do so? I can't identify the messages forwarded by the bot written in aiogram

I could not identify forwarded messages in aiogram. that is, I could not monitor the messages in this way. Help me Pleeeeeeeease!!!


Solution

  • You did not post any code about what you have tried, but here's a very minimal example how to detect if a message was forwarded. If it does not make sense to you, I suggest that you start by reading the simple example on aiogram documentation front page.

    from aiogram import Dispatcher, types
    
    dp = Dispatcher()
    
    @dp.message()
    async def message_handler(message: types.Message):
        if message.forward_origin is not None:
            message_sender = message.from_user.username or message.from_user.full_name
    
            # Rest of the code to alert the admin about the forwarded message
    

    Also take a look at the Message.forward_origin documentation.