Variables in @MenuBuilderBot

Variables in @MenuBuilderBot

MegaHubTelegram

This guide will tell you about what variables are, what the principles and mechanics underlying are them, and will also describe all the possible ways to work with them in @MenuBuilderBot.


📜 The translation of this materials into your native language can be automatically done using the Google translator. Follow the link and select the desired language in the title:
https://translate.googleusercontent.com/translate_c?depth=1&sl=en&tl=es&u=https://telegra.ph/Variables-in-MenuBuilderBot-EN-09-09

⬛ Contents

Variables - what are they?

Variable management

Variables in expressions and conditions

Working with variable values

Tutorial for Working with Variables



⬛ Variables - what are they?


Variable - (in @MenuBuilderBot) is a kind of container for storing data (text or numeric).


INFO: If you are not familiar with the concept of variables in programming, you can read a little more about variables in
"Terminology and Definitions".


To add more variables in your project, go to your bot:
☞ 🔐Admin | 🧩Extensions | 📂 Variables
and purchase the required quantity.

Then go
☞ 🔐Admin | 🗄Variables
and after selecting the required Type of variable and adding its by giving Name - the new variable can be considered as completely created.

To edit a variable, go inside the button with its name. Waht you can edit:

Change the name (respectively, its macros)

Change displayed name (used in System messages that cannot be edited).

Enable user notification about data changes in a variable.

Enable "Top by Variable" (if this function is activated in the bot).

Add a comment (useful when you have a lot of variables in the bot).


Variable types

As for Today there are 4 types of variables in MB:

Text variable - is a container for text. It can contain both Letters, Emoji and Numbers (as text). This variable can contain individual user data (for example, his wallet address)

Numeric variable - can only contain numbers. This allows the contents of this variable to be manipulated like a regular number. (while taking a value, such a variable checks if the value is numeric). Balance is an example of a numeric variable.

Global variable - the main feature of that variable is that it has the same value for all users. Thus, changing its value once will simultaneously change it for all users of the bot.

Variable (Date) Time - contains date-time data recorded in a specific (text) format. Recording format: "17.05.2020 19:45:05".


Technically speaking, Time in this format can be stored in Text Variables, but you will not be able to fully work with such variables. In the Text variable, Time can only be stored, but no actions can be performed with any of such variables.


 • Data in variables can be individual for each user, as well as global - common to all.

  • Data in a variable can be changed: Only by Admin, Admin and User together, By pressing the buttons.

  • Each variable has a Name to refer to its data.

  • Each variable has a macros for displaying its value (to the user or administrator, for using in Expressions and Conditions) based on its name.

  • The size of the text variable is 200 characters.


⬛ Variable management


There are several ways to manipulate variables.

1. Admin Commands

2. User input

3. Variable Editor

4. Buttons and Actions


Using Commands for Working with Variables.

A manual value control module is connected to the variables, it receives composite commands.


In general, the command looks like this:

➠ /Command var_name user_id value

Where:

/ (Slash) - Any command starts with a "/".
Command - This is the command itself
var_name - Variable name
user_id - Telegram ID or User Code of the bot user.
value or delta - This is the value to use


❗️IMPORTANT: All arguments of a composite command must be separated by a SPACE (not on a new line).
❗️IMPORTANT: Commands work without confirmation and their actions are irreversible.


The package of commands for individual processing of variables:


REQUESTS (gets) the value of a variable. The bot will simply send the value of the variable. No changes will be made.


SETS the value of a variable. The bot will overwrite the old value in the variable regardless of the state.


ADDS value to the variable (use negative number to subtract). The bot will add the value specified in command to the existing one in the variable. Naturally works only with Numeric variables.


DELETES the value of the variable for the specified user. Will remove any existing value in the variable, bringing it back to its original state for one user.


TOTAL SUM of variable data for all users of the bot. Naturally works only with Numeric variables.


The package of commands for bulk processing of variables:


CLEARS DATA of this variable for ALL users.

❗️IMPORTANT: Be careful the action is irreversible and works without confirmation.


HOW MANY VALUES ARE IN TOTAL in this variable (for how many users variables are initialized)


ADDES "value" TO ALL VALUES, OF ALL users who have this variable initialized (use a negative value for subtraction).

❗️IMPORTANT: The command consumes "Tokens of Function". The number of tokens consumed is equal to the number of values ​​that will be changed. In order for deducted number of tokens does not come as a surprise - the number of values ​​can (and should) be found out using /varcountall command. It, first of all, was created for this purpose.


MULTIPLIES ALL VALUES, by "value" FOR ALL users who have this variable initialized.

❗️IMPORTANT: The command consumes "Tokens of Function". The number of tokens consumed is equal to the number of values ​​that will be changed. In order for deducted number of tokens does not come as a surprise - the number of values ​​can (and should) be found out using /varcountall command. It, first of all, was created for this purpose.


For those who are not into math: to add a percentage use /varmultall, and count value like this:
1 + percentage / 100.

For example, add 10% to all balances:
/varmultall balance 1.1


❗️ ONCE AGAIN: ALL commands of the package will work ONLY WITH THOSE USERS and THOSE VARIABLES THAT ARE INITIALIZED. If you have a thousand users, and the balance is initialized for three of them, it will work for these three ONLY!
❗️ ONCE AGAIN: NO, with the help of these commands you CANNOT assign any value to ALL users. Until their variable is initialized.


❗️IMPORTANT : Mass changes are NOT recorded in the variable's change logs.


Example of command:
• The name of the text variable is rank
• ID (UserCode) of the user - 111222333
• Variable data - "Editor"

The /varset command will look like this:


❗️ Each parameter in a command must be separated with a SPACE, in ONE LINE, and not on a new line.


The user sets the value.

You can let the user himself to set the value of a particular variable. In other words: accept data from the user and store it in a variable. For example, to enter his crypto-wallet address, e-mail address or other personal data.


It works like a Question in QnA Chat, the only difference is that user's answer goes directly to the variable, and not to the admin (see the link for more details).

To use go:
☞ 📝 Post Editor - Add Variable Input

More info in manual on "Feedback Forms".


❗️IMPORTANT: The button to "Add Variable Input" will appear only if there is at least one variable other than "balance".


Changing the value of a variable using the Editor.

The value of any required variable can be changed using the editor identical to the Balance editor. This editor can be assigned to any button anywhere in the menu.

To "attach" an editor to a button, go to your bot:
☞ 🎛 Button Editor> Button Settings (* ️⃣)
"Assign Editor"
and specify the variable by selecting it from the list.


INFO: There can be several editors for one variable.
It is advisable to switch this button to "Admin only" mode. Of course, it won't let users in there, but they don't need to see it either.


Changing values ​​using Buttons and Actions

In @MenuBuilderBot there is a whole list of specialized buttons for working with variables, as well as the Actions which represent the most flexible tool for creating your bot functionality, which are a type of visual programming in a way.

To connect the Buttons, go to your bot:
☞ 🔐Admin | 🧩Extensions | 📂Buttons

To buy Actions, go to your bot:
☞ 🔐Admin | 🧩Extensions | 📂Actions


Bonus button

Bonus button - allows users to add a bonus (the number of conventional units specified by the admin) to the selected variable (for example, Balance).

The peculiarity of this button is that the Admin can set the Period for the user to receive the bonus. That is, the frequency with which the User can receive the Bonus by pressing the button (the gap between bonuses if you wish). The variable for accrual, Amount and Frequency (in hours - in integer or fractional numbers) is specified by the admin when creating the button itself. All parameters can be set by Macros.

The Bonus button can change ONE variable in one click.


Fix Exchange 1 buttons

It allows users to exchange a fixed amount in conventional units within the bot, transferring the amount preset by the administrator from one variable to another. The button SUBTRACTS a given amount from one variable and ADDS it to another - thereby carrying out the exchange of funds. All parameters can be set by Macros.

The "Fix Exchange 1" button changes TWO variables in one click.

INFO: This button can also be used in a different way. For example, despite the fact that one of the numbers is always subtracted, you can add two numbers to different variables. If you subtract a negative number, then in fact it will be added. Different interesting mechanics can be built on this trick.


Button Course Exchange 2

It allows users to exchange the amount at the rate in conventional units within the bot, transferring the amount from one variable to another, taking into account the predefined exchange rate specified by the Admin. The button SUBTRACTS a given amount from one variable and, after calculating using the rate, ADDS it to another - thereby carrying out the exchange of funds via rate. For calculations, the specified exchange rate is used, which can also be taken from a variable (the exchange rate can be updated automatically and modified using Expressions). All parameters can be set by Macros.

The "Exchange Rate 2" button changes TWO variables in one click.


Actions and variables

Action (as a term) in @MenuBuilderBot is a way to perform one action. One Action (as a term) - meas one action in fact. Actions can be different - change the value of a variable, check a condition, add percentage to the referral, etc. Actions in buttons can be combined to create unique algorithms and sequences of actions, thereby obtaining the desired functionality. The Action Guide is long, but worth reading.

A button with Actions has no limits in the ways of its use and can change as many variables as needed in one click.


⬛ Variables in expressions and conditions


The values of variables with the help of macros can be used in the calculation by substituting them into the Expressions, as well as in Conditions of buttons and Actions. Detailed descriptions of each of the cases are referenced in the text links. Expressions can be used both in bot messages and in button functions.

As a reminder, Variable Names are case sensitive. That is, the variables named "Var" and "var" are two different variables.


⬛ Working with variable values


Displaying values ​​to the user.

In order to show the variable value to the user, it is enough to insert a macros with the name of the variable in the desired message. Macros is a variable's name surrounded by percent "%" signs.

For example, the %wallet% macro will
show the value of the "wallet" variable.

You can use macros of particular variables in the text of another variable.


Export of variable values.

Variable data can be exported to a .csv file. To export, you need the user to have referrals, balance, or something else - bonuses, for example.


❗️ IMPORTANT: The data of those users who just came to have a look and press the menu buttons will not be exported - because not stored.
❗️ NOTICE: One exported file will contain ALL available data of ALL available users.
EXCEPT FOR THOSE MENTIONED ABOVE!!!!!!!!


To purchase exports, go to your bot:
☞ 🔐Admin | 🧩Extensions | 📂Logs and Data

Export is added to 1 bot.

An example of an export file in our news channel
https://t.me/MenuBuilderNews/296


Balance transactions log.

In order to improve the security and stability of data in the accrual system, and to resolve possible user disputes on the balance variables in the bot, it is possible to logging each transaction in a file, by sequentially recording in a spreadsheet all transactions for the variable balance in your bot.


For details and conditions of connection, see your bot:
☞ 🔐Admin | 🧩Extensions | 📂Logs and Data

Logging is connected to 1 bot.

An example of a Log export file in our news channel:
https://t.me/MenuBuilderNews/297


⬛ Tutorial for Working with Variables


https://telegra.ph/Menu-Builder---All-Help-Materials-02-22

Report Page