voidbar / forwardgram

Forward messages from multiple Telegram channels to one of your own!
156 stars 183 forks source link

Override message #43

Open csulit opened 2 years ago

csulit commented 2 years ago

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

mo-tech55 commented 1 year ago

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

mert-donmez commented 10 months ago

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)