Skip to main content

How to add a link to the TOP by variable

In this tutorial we will tell you how to add a link to the user name in the message of TOP by variable (the method is equally applicable to both the TOP referrals function and, basically, to any similar cases).

CASE: Create a TOP by variable and add an arbitrary link to the user name - at the discretion of the user.

Acquiring of functionality

All functionality is purchased IN YOUR BOT, for this go to your bot:
☞ 🔐Admin | 🧩Extensions

IMPORTANT: The purchase of functionality for the bot is available only to the Creator (owner) of the bot. Admins CANNOT buy functionality!

You will need:

1. Variable - 1 piece (in addition to the existing one balance) (OPTIONAL)
☞ 🔐Admin | 🧩Extensions | 📂Variables

2. Tokens of Functions Pack (monthly ones will be enough to start) (OPTIONAL)
☞ 🔐Admin | 🧩Extensions | 📂Actions

3. Conditions of Forms (OPTIONAL)
☞ 🔐Admin | 🧩Extensions | 📂Forms

4. Basic TOP by Variable (OPTIONAL)
☞ 🔐Admin | 🧩Extensions | 📂Variables


❖ Creating a TOP with a link

Short description

1. We acquire a TOP by variable. 
2. We create a variable for storing the link.
 3. We compose the necessary Expression using functions link() and bool_symb()
4. We create a form for the user to enter the link.

1. Acquiring of TOP by variable

We acquire TOP by variable (or TOP referrals).

Or we don’t buy anything at all - if the link simply needs to be added to some arbitrary text.

The function «Basic TOP by Variable» allows you to display (compose) TOPs for any numeric Variable. The function also has plugins that expand its capabilities. 
39. Basic TOP by Variable
To connect, go to your bot:
☞ 🔐Admin | 🧩Extensions | 📂Variables

15. Basic TOP Referrals
To connect, go to your bot:
☞ 🔐Admin | 🧩Extensions | 📂Referrals

IMPORTANT: Don't forget to enable TOP for the variable you selected following the instructions in the feature description.

In this guide, we will look at creating a TOP by balance variable. Thus, after purchasing the «TOP by Variable» function, its macros become available to you: the user name macro and the variable value for this user. We will add the link to the user name and the macros (first level) will look like this: %topbalance1u%.


2. Creating a variable for a link

Create a TEXT variable in the bot to store the link.

It is important to understand that using a variable in this case is not mandatory. It is needed so that the user can arbitrarily specify a link that will be hidden under his name in the message with the TOP. If, in your case, there is no need to allow the user to specify his own link, you may not use a variable, but specify it yourself directly in the message (will be described below).

Go to your bot:
☞ 🔐Admin | 🗄Variables | 📙Text | ➕Create Variable
Name the variable: " ulink" (you can choose any name).

See Guide to Variables.

3. Creating an expression to set a link under the user name

To add a link, we'll use the function link() from the Expressions guide.

IMPORTANT: We understand that most likely you will want to place a link to the user's profile under the user's name.

We STRONGLY DO NOT RECOMMEND you to do this(!!!).

The users presented in the TOP did not give you permission to place their addresses in the public space and doing this without their permission IS NOT ETHICAL. You yourself would not want your data to be published in random places and any of the thousands of users (and spammers) to find out how to contact to you. For this reason, we WILL NOT describe the method of adding a link to a profile in this manual - and if, despite our warning, you still want to do this, then you will need to figure out how to do it yourself. Anyone, after reading this manual, who comes with a similar question to support - will be upset with the result.

In most cases, a link under a user's name is needed so that users can contact them, and the only ethical way to do this is to let the USER decide for themselves whether they want to be contacted or not, and to let them choose the method for such contact (it does not necessarily have to be a private message).

Thus, allowing the user to specify the contact link themselves is the only correct solution.

As the link's text, we will use the macros of the user's name %topbalance1u% from the TOP by variable, and as the link itself, we will use the macros of the text variable %ulink% (that we have created before), in which the user will (or will not) save the link he wants. The function itself will look like this:

link("%topbalance1u%", "%ulink%")

If you use the expression in this particular form, then, if there is no link specified by the user, in the TOP by variable - there will be an empty space, because the function link() will not work. If you YOURSELF specify the link in the variable, then you can use this notation, but for our case, where the user himself determines whether he needs a link or not, we will additionally add processing for the case when the user did not specify this link. In the case of no link, we will simply show the user name from the macros using the function bool_symb().

{bool_symb("%ulink%"=="", "%topbalance1u%", link("%topbalance1u%", "%ulink%"))}

The condition in the above Expression only checks for the presence of data in the variable. That is, if there is data, then the function will attempt to display the username with a link, if there is no data, then the username will be shown as plain text.

It is clear that the current expression can be further complicated by adding, for example, validation of the link for the presence of the https:// by function such as startswith(), but in our opinion the link should be validated upon entry and moderated immediately after addition, so additional validations in the expression itself are not necessary.

4. Creating a Form for the user input of a variable

To save a link in a variable, you need to create a Form for the user in the "variable input" mode.

See the guide on Forms.

This functionality solves two problems:
1. Allows the user to decide for himself whether he wants to be contacted or not (he wants to - if the link is specified and he does not want to - if it is not specified)
2. And also allows him to specify the link itself if necessary.

In your form description, convey this message to your user.

To validate the user's input of a link, you can use the function startswith() from the Expressions guide. For this, you will need an extension:

64. Conditions of Forms
To connect, go to your bot:
☞ 🔐Admin | 🧩Extensions | 📂Referrals

In this case, the Form Condition may look like this:
startswith("%answer%", "%http%")

In addition to entering a link, it would be nice to have the ability for the user to delete a previously entered link. For this, you can create a separate button with the Action of Clearing from the Actions Guide.

Good idea as well would be to moderate the user input and check if the correct link is added to the variable. For this you can use Post-Action of Message and pass all the links saved in variables to a separate group for the moderation.
See guide on Actions
See guide on Groups

Thus, we have a TOP by variable balance, in the message of which (under the user name) we can have a link specified by this user, as well as a Form for entering this link.