ConfluxBot: How to use Alter Text feature?

ConfluxBot: How to use Alter Text feature?

ak4zh
It suports RegEx which makes Alter Text super powerful but great powers always comes great responsibility so plan your regex patterns very carefully.

For help you can always ask in our discussion handle @ConfluxChat

Basic Information

In hurry? Skip this part and jump to examples below.

Let's suppose you have ten different channels and you want to track sales/traffic of each channel seperately but making separate tracking urls for each channel is a pain so you have dropped the idea of having separate reports and compromised with a single consolidated report.

This might work when these are all channels you own, but what if you are a social media manager and you handle channels of ten or fifty clients and you need to post some sommon info in all channels but with their own UTM / affiliate trackings. Create same content 'n' number of times?

Well we do not want you to compromise with anything lesser than you deserve or repeat a task 'n' number of times more than you should.
That is why we have made @ConfluxBot


So let's dive deeper into Alter text powers.

Alter text accepts two parameters,

  • first is original text or pattern to match and,
  • second is the resulting or output text.

Both the parameters should be seperated with an equal sign "=" or a comma ","

Here's some examples:

app=bot
(t|telegram).me/\w+=t.me/ConfluxBot
efg[hij]=klmn
url:tag=conflux-20
apples, bananas and oranges=fruits
"My text is, 2 \+ 2 = 2","Replaced text is, 4 + 4 = 8"

Let's try to understand each individual component of above example:

  1. app=bot --> this tell the bot to replace any presence of `app` in message to `bot`
    *Note: this will also replace `apple` to `botle`, to tackle that use regex word boundary character `\b`
  2. \bapp\b=bot --> this will alter 'app' to 'bot', but leave apple to apple.
  3. gr[ae]y=red --> so this finds both spellings of the word gray in one operation and change it to 'red'
  4. \b@\w+\b=@ConfluxBot --> this will look for any word starting with a @ symbol (usually usernames in telegram) and change it to @ConfluxBot
    *Note: because we are using word boundary it will not replace for example an email id.
  5. (t|telegram).me/\w+=t.me/ConfluxBot --> Here we look for both variations of telegram links t.me and telegram.me followed by a slash and then any word character and replace it with your desired link.
  6. apples, bananas and oranges=fruits --> If your phrase has comma in them use = separator.
  7. "My text is, 2 \+ 2 = 2","Replaced text is 4 + 4 = 8" --> This one is quite interesting, the original phrase has both ',' and '=' sign. To tackle this we wrap out paramters in double quotes and use comma as separator.
    *Notice the escaping of '+' sign, otherwise it will be treated as regex quantifier and will match 'n' number of spaces between 2 and = sign


Possibilities as endless, there is no one way to do things with regex. You can perform same task in many different ways and each can be the correct way.

Some Advanced Usage Example and Extra Commands:

URL params

Back to our ten clients example. You are handling Online Shopping Deals campaigns of ten deals sharing websites now you saw an amazing Amazon deal that came in a flash sale. You want to share that deal in all your client channels but you cannot use a single affiliate tag, and the flash sale may even end until the time you create ten different tracking urls.

Now this is how ConfluxBot can help you.

  • url:tag=client1 --> For URL params replacement we use a special pattern that starts with 'url:' so @ConfluxBot can understand to perform the alteration in URLs. The bot will now look for 'tag' parameter in each urls found in the message and change it to client1's affiliate tag.

For each individual channel you set the affiliate tags just once, and connect them together with your master channel. Now when you post in your master channel each connected channel get's the same post at same time but with their own affiliate tags. Amazing isn't it?


Did I tell you that the Alterations take place in the sequence in which you add them?

So you can decide which regex operation to happen first and when to start procssing URL altertions.

By default url parameters are replace only, which means it will only alter the parameter if it exists in expanded url otherwise ignore it. But there might be some situations when you want to force add parameters to urls. We have 'urlAdd:' to get this covered.

Here's list of all available commands for URL operations:
  • url:key=value --> replace params only if it exists in expanded url
  • urlAdd:key=value --> force add these params to each url
  • urlExpand --> by default urls are expanded immediately before the url alteration operation, but you can force urls to expand at any time. For ease of understanding you can set your first alteration as 'urlExpand' to expand urls first and then perform other operations
  • urlExpandFalse --> don't want ConfluxBot to expand your urls? just set your first alteration as 'urlExpandFalse' and the bot not expand url for any alteration, you can again use 'urlExpand' at some later sequence to force expand urls.
  • urlDel:key1,key2,key3,key4 --> this can be used to clean any unwanted url params. The sequence is very importat, if you set url:key=value and then urlDel:key, your urls will never be able to have key params as urlDel will delete it being in the next sequence.
  • urlShort --> this will short all existing urls in the text using your shortening access token (example: bitly), if added to bot. This parameter should usually be the last one in sequence but you can use it at any point.

Other bots you may like:

  • Patronto - a membership management bot for telegram.

Report Page