voidbar/forwardgram

Override message

csulit opened this issue · 2 comments

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

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

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)