Filter

Replace text in messages

What It Does

The /filter command allows you to modify the content of messages being forwarded. Specifically, it replaces specific words or phrases in the incoming messages with new text before they are forwarded to the outgoing chat.

Prerequisite

  • Incoming and Outgoing Chats Configured: Both the source (incoming) and target (outgoing) chats must be set up using the /incoming and /outgoing commands. Without these, the filter won't have any messages to modify.

How to Use It

  • Send the filter command in this format: Text to replace==Replacement text Example: @oldusername==@newusername or /filter "sale"=="promotion".

  • The filter will be applied to all incoming messages before they are forwarded.

  • Start forwarding messages using the /work command, and the filter will be applied to all future forwarded messages.

    Set filter on Auto_Forwarder_Bot

Note: This uses regular expressions (regex) by default. So make sure that your query is a valid regex expression. You can search for regex for many text types such as URL, telegram username, email etc by search on Google "regex for MY_QUERY". Make sure that your regex is optimized for speed otherwise it will lead to delay in your messages (by a few milliseconds)

Real-Life Use Cases

  • Replacing Usernames: You want to protect privacy by replacing specific usernames in messages with anonymized ones. Example: replace @john with @user123.

  • Language Customization: You’re part of a group with users who speak different languages. Use the filter to replace certain English terms with their local language equivalent.

  • Branding Consistency: Automatically replace terms like "discount" with "special offer" to maintain consistent messaging across multiple channels.

Removing a Filter

If you want to remove a filter:

  • Send the /remove_filter command.

  • A list of your active filters will appear, each with a number.

  • Select the filter you want to remove by typing its corresponding number.

After removal, the filter will no longer modify incoming messages.

Last updated