Use cases of replacements
Replaces allow you to automatically modify the text in the forwarded messages.
Thanks to the use of replacements, you can:
- add an arbitrary signature to the beginning, end, or middle of a message.
- remove unwanted content from a message.
- change text, links, emoticons in a message.
- add meta information about the original message to the forwarded message, such as: date and time of the message, link to the message, name, nickname, chat id and author of the message.
- stylization of existing and new message content.
Creating a simple replacement
Before creating a replacement, make sure that you already have the forward configured in copy mode.
To create replacement rules, follow these steps:
- Go to the Replacements page.
- Click Add.
- Enter the old content - the text you want to replace.
- Enter the new content - the text that the old content will be replaced with (you can leave it empty, in which case the old content will simply be deleted from the message).
- Specify when to apply the replacement - before or after processing (it can be useful for management when several replacements conflict with each other).
- If necessary, enter a description - it does not affect anything and is needed solely for the convenience of the user.
- Click OK.
- In the list of your forwards that appears, select the forward in which the replacement will be applied.
- Click OK.
After successful creation, the replacement will be displayed in the list. Now the created replacement will be automatically applied to the selected forwards.
If necessary, by clicking on the gear, you can:
- Change the replacement settings.
- Select other forwards for replacement.
- Duplicate the replacement for later modification.
- Remove the replacement.
Replacement with regular expression
Regular expressions are text templates that allow you to search for certain lines in the text according to specified conditions (numbers, links, the beginning or end of a line, and other patterns), which opens up incredible possibilities for configuring replacements.
To use regular expression syntax support, you need to tick the appropriate box under the old content field, after which the old content entered in the field will be accepted by the service as a regular expression to search for what needs to be replaced.
In this example, the replacement will find all numbers consisting of three or more digits in the message and replace them with an empty string (delete).
Replacement with meta information
To add meta information to the forwarded message, specify the appropriate special tag in the new content field:
- Message date: <message-date>
- Message time: <message-time>
- Message id: <message-id>
- Message link: <message-link>
- Message group id: <message-group-id>
- Chat id: <chat-id>
- Chat name: <chat-name>
- Chat username чата: <chat-username>
- Author id: <author-id>
- Author name: <author-name>
- Author username: <author-username>
- Old content: <content>
In this example, the replacement will add the name of the author of the original message and a link to the original message to the beginning of the forwarded message.
Replacement with styling
- New line: <br>
- Space: <space>
- Bold: <b>Жирный</b>
- Italics: <i>Курсивный</i>
Crossed out: <s>Crossed out</s>- Code: <code>Code</code>
- Underlined: <u>Underlined</u>
- Spoiler: <span class="tg-spoiler">Spoiler</span>
- Link: <a href="https://flowin.click">Link</a>
In this example, the replacement will hide all phone numbers starting with +7 or 8 in forwarded messages with a spoiler.
Replacement with premium emoticons
Premium emoticons cannot be copied and pasted outside of Telegram. In order to be able to customize the replacement using premium emojis you need to insert data from the bot @message_inspector_bot to the field new content. By the way, this bot can be used to generate a complex stylized replacement without premium emoticons.
- Go to the bot @message_inspector_bot.
- Send him the stylized text that you are going to use as new content.
- Copy the json code that the bot sent in response.
- Go to the dialog for creating a new replacement.
- Paste the copied json code into the new content field.
This example will add a signature with premium emoticons to the end of the forwarded messages.