forwardgram icon indicating copy to clipboard operation
forwardgram copied to clipboard

Override message

Open csulit opened this issue 2 years ago • 2 comments

Is there a way to override (update) incoming messages before sending to my channel?

csulit avatar Jun 03 '22 19:06 csulit

I am also interested in this and dont know how to modify the code. I want to add a delay and then check the same message again

mo-tech55 avatar Aug 31 '23 19:08 mo-tech55

You can add a function like this and specify the desired conditions within this function:

# This function processes incoming messages and makes modifications
def process_message(message):
    # Example of modifying the message content
    new_content = message.text.replace("old word", "new word")
    # This part can be customized according to the needs.
    return new_content

@client.on(events.NewMessage(chats=input_channels_entities))
async def handler(event):
    # Process the incoming message
    processed_message = process_message(event.message)

    # Forward the processed message to output channels
    for output_channel in output_channel_entities:
        await client.send_message(output_channel, processed_message)

mert-donmez avatar Jan 19 '24 20:01 mert-donmez