Skip to main content

Invest bot (basic mechanics)

Searching how to create an investment bot in Telegram? In this article, we will tell you how to create an investment bot using @MenuBuilderBot. We will reveal the BASIC principles of the game mechanics of the user receiving profit on his contribution over time.

It is important to understand that the basic principles themselves are not enough to create a QUALITY "immersive" GAME, but by understanding the basics - you can apply them to your specific project in the form you need. To create the necessary entourage, the basic game mechanics must be surrounded and justified by a plot scenario, as well as auxiliary functionality (balance replenishment, the presence of different types of balances for different in-game currencies or items, the presence of various ways to formalize the basic mechanics in some scenario-based form, the ability for the user to HIMSELF specify or select individual parameters).

❖ Necessary skills

WARNING: This guide is NOT intended to teach beginners and assumes that you have basic skills in working with the constructor and are READY to create more complex projects. The guide reveals the PRINCIPAL SCHEME of operation of individual game mechanics, in particular the basic PRINCIPLES OF WORKING WITH TIME. If in the process of studying the presented material your basic knowledge turns out to be insufficient, we advise you to study the basics before continuing - we will not teach you "how to create buttons" in this guide.

Despite the fact that the manual is designed for knowledgeable admins, to simplify the initial understanding of the given schemes - they are given IN THEIR MOST BASIC FORM. In the future, having understood the principles of their work, you will be able to complicate them as necessary - such an approach will allow you YOURSELF to form the CORRECT PRINCIPLES OF WORK with new functionality and knowledge - will make it clear that YOU DO NOT NEED TO THOUGHTFULLY COPY the given approaches (and then come to support and say that nothing works and you do not understand anything) - you need to comprehend their principle using simple examples and then, as your understanding grows, move on to more complex application options.

List of required skills:

Creating Buttons and Messages
Variables
Macros
Balance in the bot
Conditions
Actions
Expressions
Working with Date and Time

❖ Basic scheme of the investing mechanics in a bot

In this scheme:
• The user invests a fixed amount (set by the admin) and receives a fixed profit per hour.
• The user can check the accumulated volume.
• The user can take (withdraw) the profit to the main Balance.
• The user can REinvest the accumulated funds to increase the profit per hour.
• The user can withdraw the entire amount of accumulated funds and finalize the investment process.

Preparatory actions

At this stage, we are preparing the functionality of our bot to create game mechanics.

● You already have the numeric variable «balance» - the user’s in-game funds are stored there.

● Create a Numeric variable «inv_balance» - it will store the investment amount.

● Create a Date and Time variable «inv_start» - it will store the time of the investment beginning.

Investment mechanism

Investment button - allows the user to write off funds from his in-game Balance to a separate Investment Balance and start the process of accumulating funds.

● Create an «Invest» button with Condition «{%inv_balance% == 0}» and error message «You have already invested».

● Add «Action of Numbers» (write off funds from the balance - 10 conventional coins) 
 Variable to change: balance
Operation type: Change Value
Value
: -10 (minus ten)
Condition: {%balance% >= 10}
Failure Message: «Not enough funds»
Success Message: optional

● Add «Action of Numbers» (we credit funds to the investment)
Variable to change: inv_balance
Operation type: Set Value
Value: 10 (ten)
Condition: none
Failure Message: none
Success Message: optional

● Add «Action of Numbers» (set the investment start time)
Variable to change: inv_start
Operation type: Set Value
Value
: {dt_now()} (time "now")
Condition: none
Failure Message: none
Success Message: optional

● Add a Message to the button: «Congratulations, you have invested %inv_balance% coins!»

Checking the amount of accumulated funds

Check button - will allow the user to find out the investment status (active or not), as well as the main parameters of the investment (start date, investment amount, duration, amount of accumulated funds) - if the investment is active.

It is important to understand that the given list of parameters is presented only to demonstrate the possibilities - in fact, you can use any mathematical derivatives that you need.

● Create a «Check» button with the Condition «{%inv_balance% != 0}» and the error message «You have not invested yet».

● Add a Message to the button:

Investment details
Started: %inv_start%.
Invested: %inv_balance% coins.
Duration: {dt_passed_hm("%inv_start%")} hours.
Profit: {round(%inv_balance% * 0.1 * dt_passed("%inv_start%")/24.2)} coins.

It is necessary to understand that there is NO ACTUAL CHANGE IN THE VARIABLE DATA. In the message, knowing the amount of investment and the volume of profit per hour, we calculate the accumulated profit each time, counting it IN HOURS from the investment start date. Technically, we multiply the investment amount by the percentage per hour (expressed as a fractional number) and multiply by the number of hours that have passed (also expressed as a fractional number).

No need to explain separately that if you have mastered the basic principle of calculating accumulated profit by time, then you can express savings not only through HOURS, but also through DAYS, indicating the percentage per day, and not per hour. In addition, you will also have the opportunity to set your own percentage.

Collecting profits and continuing investment

Profit collection button - will allow the user to withdraw accumulated profit to the main Balance without touching the initial investment amount.

● Create a «Take Profit» button with the Condition «{%inv_balance% != 0}» and the error message «You have not invested yet».

● Add «Action of Numbers» (pulling out the accumulated coins to the main balance)
Variable to change: balance
Operation type: Change Value
Value: {round(%inv_balance% * 0.1 * dt_passed("%inv_start%")/24,2)}
Condition: none
Failure Message: none
Success Message: optional

● Add «Action of Numbers» (set new investment start time)
Variable to change: inv_start
Operation type: Set Value
Value
: {dt_now()} (time "now")
Condition: none
Failure Message: none
Success Message: optional

● Add a Message to the button: «Investment continued - amount %inv_balance% coins!»

Profit collection and automatic reinvestment

Automatic reinvestment button - will allow the user to fix the profit and immediately add it in full to the investor's balance in order to obtain more profit per unit of time.

● Create a «Reinvest» button with the Condition «{%inv_balance% != 0}» and the error message «You have not invested yet».

● Add «Action of Numbers» (we credit the accumulated funds to the investment)
Variable to change: inv_balance
Operation type: Set Value
Value: {%inv_balance% + round(%inv_balance% * 0.1 * dt_passed("%inv_start%")/24,2)}
Condition: no
Failure Message: no
Success Message: optional

● Add «Action of Numbers» (set new investment start time)
Variable to change: inv_start
Operation type: Set Value
Value
: {dt_now()} (time "now")
Condition: none
Failure Message: none
Success Message: optional

● Add a Message to the button: «Congratulations, you have invested %inv_balance% coins!»

Collecting profits and finalizing the investment

The investment completion button allows the user to save the profit and take back the main body of the investment - transferring their total amount to the main Balance.

● Create a «Finish Invest» button with the Condition «{%inv_balance% != 0}» and the error message «You have not invested yet».

● Add «Action of Numbers» (we credit the accumulated funds on the main balance)
Variable to change: balance
Operation type: Change Value
Value: {%inv_balance% + round(%inv_balance% * 0.1 * dt_passed("%inv_start%")/24,2)}
Condition: none
Failure Message: none
Success Message: optional

● Add «Action of Numbers» (zero out the investor's balance)
Variable to change: inv_balance
Operation type: Set Value
Value: 0 (zero)
Condition: none
Failure Message: none
Success Message: optional

● Add a Message to the button: «Investment completed».

Once again, we remind you that the mechanics presented above are only a basic schema of the described functionality. To create a full-fledged project, you will need to fit these mechanics into your unique scenario of interaction with the user.

❖ Options for improving basic mechanics

Allow the user to specify the investment amount themselves

In order to set the initial investment amount, you can use, not only a fixed (predefined by Adimn) number, but the data from a Variable (must be created separately). The user, using the «Form with Variable Input», specifies the amount he wants to invest. After that, the verification in the Investment Action occurs not by the set number as in the basic mechanics, but by the Variable Macro.