Skip to main content

Life-Hack #7: Bonus with custom cool-down

This Life-Hack allows you to create custom bonus buttons with cool-down, (delay) between accruals, of your choice.

Life-Hack - involves the use of existing functionality in non-obvious and rather ingenious ways, creating functions in your bot, that were not originally built by the constructors’s developers.

In this section, we publish various options and turnkey solutions for what can be created using the capabilities that are already available in the @MenuBuilderBot constructor. When creating such manuals, it is assumed that you, to one degree or another, are already familiar with the basic functions of the constructor and the basic mechanisms for working with it. If in the process of studying the presented material your basic knowledge is not enough, we advise you to study the basics before continuing.

 

❖ 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. Variables - 1 piece
☞ 🔐Admin | 🧩Extensions | 📂Variables

2. Actions - 3 pieces
☞ 🔐Admin | 🧩Extensions | 📂Actions

3. Conditions for buttons
☞ 🔐Admin | 🧩Extensions | 📂Buttons

4. Macros and expressions for buttons
☞ 🔐Admin | 🧩Extensions | 📂Buttons

 

Create custom bonus buttons

 

How it works

You create your own button for adding a Bonus to your users, but instead of connecting to it the usual Bonus functionality (the maximum accrual time gap for which is limited to 24 hours), you create your own button - with any time gap - using Variables and Actions.

 

1. Create variables

Variable (Date and Time) - Go to your bot:
☞ 🔐Admin | 🗄Variables | 📕Time | ➕Create Variable
Variable name: timer (you can use your own).

We assume that the bonus is credited to a variable balance (which is available to everyone initially and for this reason it is not necessary to create it separately). If you intend to add a bonus to another variable, then it will need to be purchased as described above and created as Numeric.
Variable 2 (Numeric) - Go to your bot:
☞ 🔐Admin | 🗄Variables | 📙Numeric | ➕Create Variable
Variable name: bonus (you can use your own).

 

2. Create your own button for the bonus

This is the menu button, that will add 10 bonuses once in every 30 days.

Obviously, you replace these numbers with the ones you need or use Variables.

2.1 Add Button

Click in your bot:
🎛Buttons Editor | ➕Add Button
Name of the button is "Get Bonus".

2.2 Assign Actions

Without leaving the Buttons Editor (if you left, go back) press the inline Settings button [*].
Click "Assign Pre-Action"

● Select "Action of Initialization"
Variable to change: timer
Value: {dt_add(dt_now(), -30*24)}

Here we initialize the Time variable (which, by default, always contains the time "now" and for this reason, it is almost impossible to work with it without initialization. We initialize it with a time 30 days earlier than "now". More info on working with time in "Date and Time" manual.

● Select "Action of Numbers"
Variable to change: balance
Operation type: Change Value
Value: 10 (ten)
Condition: {dt_passed("%timer%", "d") >= 30}
Failure message: "30 days have not passed yet! Come back in: {floor (30 - (dt_passed ("% timer%" , "d")))} days."
Success message: "You have received:%balance_v% bonuses! "

Here we create a bonus accrual, with conditions, 30 days has passed, that since the last bonus was received, the time of which we stored in timer variable during initialization.

Read more about the function floor() used in the failure message in manual for "Expressions".
The macros %balance_v% will show the amount by which the variable has changed balance. Basically, this is necessary if you will set the size of the bonus through a variable.

About "_v" from %balance_v% notation read in Action of Number manual.

● Select "Action of Numbers"
Variable to change: timer
Operation type: Set Value
Value: {dt_now()}
Condition: {dt_passed("%timer%", "d") >= 30}
Failure message: "➖ Set to Empty".
Success Message: "Next bonus in 30 days."

With this Action, we set the time when the last bonus was received by the user. Using this time marl, in the future, there will be a countdown to the next one, in the Conditions.

 

Additional information

 

The use of Variables

As you understand, it is more convenient for the size of the bonus and the number of days until the next one, to be stored in variables. In this case, besides the fact that it will be easier for you to change them, if necessary (if you used Global Variables), you can also set individual sizes of bonuses and the time of their receipt for each user (if you use individual Numeric Variables).

• • •

Referral matrix creation

If you set the data using an expression, using the number of referrals of a particular user, then you can change these parameters depending on the number of users invited by him. Also, having different levels of participants indicated in the variables, of the project, you can use them as arguments to calculate the size of the bonus and the frequency of its receipt. We hope you understand the concept and can adapt it for your project.

• • •

Button's information message

With such an architecture of the bonus receiving functionality, any messages (for example, data from the user's account) can be added to the bonus button itself - they will be displayed regardless of whether the user received the bonus or the time has not come yet.

• • •

Cheaper option

If instead of the time "now" in a variable timer, you save not the time of pressing, but the time of the next receipt of the bonus in the future, then the use of Action of Initialization can be avoided, this will save you one Action, but at the same time it will make your system less flexible, not convenient for making changes, and it may also make it difficult to use options with a dynamic bonus time, which are changing depending on the user's activity, those ones described above. Since this type of bonus is mostly intended for complex projects, we will not describe in detail, such a less flexible option.