Skip to main content

Life-Hack #6: Custom captcha (Math expression)

This Life-Hack will allow you to create custom captchas based on mathematical expressions.

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!

 

Warning

This guide was created exclusively by the request of the admins. For our part, we must warn you that this type of captcha is NOT a reliable method of protection, however (for the reasons we do not understand), many of the bots creators prefer this particular option over the standard ones... Such captchas are more difficult to solve by people than by robots, due to information in them is presented in text form and is easily recognized automatically. We do not recommend using this captcha to protect any serious sections of the menu. We recommend using standard captchas, paid or free, which are present in the constructor's functionality.

This captcha can ONLY be set on the buttons of the lower menu. It cannot protect the "Main Menu" of the bot - because Forms are involved in its work - and Forms cannot be created in the "Main Menu".

 

You will need:

1. Numeric variables - 3 pieces
☞ 🔐Admin | 🧩Extensions | 📂Variables

2. Actions - 4 pieces (+1 Optional)
☞ 🔐Admin | 🧩Extensions | 📂Actions

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

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

5. (Optional) Invisible buttons
☞ 🔐Admin | 🧩Extensions | 📂Buttons

 

Create custom captcha

 

How it works

The button with the captcha function contains the functionality of a "Variable Input". Pre-Actions generates two numbers that are displayed in the message of the "Variable Input" Form. If the user correctly specifies the sum of two numbers, then "Post-Action of Commands" with a Condition, will transfer him to the hidden menu. If user specified the sum of the numbers incorrectly, then the second Post-Action with the Condition transfers them back to the "Variable Input" Form.

 

1. Creating numeric variables

Go to your bot:
☞ 🔐Admin | 🗄Variables | 📙Numeric | ➕Create Variable
Variable names: num1, num2, num3 (you can use your own).

 

2. Create a secured menu button

This is the button, the menu of which must be covered with captcha.

Click in your bot:
🎛Buttons Editor | ➕Add Button
The name of the button "Hidden Menu 999".

2.1. Assign her a Command (Example: /target)
Options: Move by Command
2.2. Assign Condition: {(%num1% + %num2%) == %num3%}
2.3. We make this button "Invisible" for Users and, if necessary, for admins as well.

Inside this button, you will create a menu that will be covered by the captcha.

 

3. Create a button for the captcha's function

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

3.1. Without leaving the Buttons Editor (if you left, go back) press the inline Settings button [*].

3.2. Assigns it a Command (for example: /capt)
Options: Move by Command

This button can be made hidden and the functionality can be accessed using an inline button with its command. Or you can give it the name of the menu button that you actually want to protect with this captcha.

In the basic version, the user will have to enter a captcha every time they try to enter the covered menu. If you need a "one-time captcha" input, then add the "Pre-Action of Commands" as the first Action (how to do this will be written below). You will need 1 additional Action.

● Select "Action Commands"
Command
: /target (we have created a button with this command earlier)
Condition: {(%num1% + %num2%) == %num3%}
Message: no
Options: Abort Execution

After that, continue to follow the instructions in the manual.

3.3. Add Pre-Actions for generating captcha expression numbers.
Without leaving the Buttons Editor and Settings (if exited, go again).
Click "Assign Pre-Action"

● Select "Action of Numbers"
Variable to change: "num1"
Operation type: Set Value
Value: {randi(A, B)}
Condition: no

● Select "Action of Numbers"
Variable to change: "num2"
Operation type: Set Value
Value: {randi(A, B)}
Condition: no

Where:
"A" - minimum number of Captcha's expression
"B" - maximum number of Captcha's expression

3.4. Exit the Pre-Action editor

3.5. Add Post-Action to the button you created.
Without leaving the Buttons Editor and  Settings (if exited, go again).
Click "Assign Post-Action"

● Select "Action of Commands"
Command
: /target (we have created a button with this command earlier)
Condition: {(%num1% + %num2%) == %num3%}
Options: Abort execution

● Select "Action of Commands"
Command
: /capt
Condition: {(%num1% + %num2%) != %num3%}
Message: "Captcha is not correct, try again..."
Options: Abort

You need to understand that in captcha you can use expressions of any kind (not only addition) and with any number of arguments, however, we do not recommend making the task too complicated for users - because for robots (for whom it should be designed), any such task does not present ANY difficulty.

3.6. Exit the Buttons Editor and go to the Message Editor.

 

4. Create an input form for the answer

In the created captcha button, add the "Variable Input" form.

Click in your bot:
📝Post Editor | ➕Add Variable Input

Variable: "num3"
Type: Single answer question
Message:
"Enter the sum of two numbers: %num1% +% num2% = ??? "

 

This life-hack describes the basic mechanics of the approach to the implementation of custom captcha. The final appearance of the functionality may differ for different projects. For example, you can generate a number for a captcha by throwing a dice sticker in Telegram, then the user will have to enter the number dropped on the dice.
To do this, you will need:

Advanced Forms.
To add, go in your bot:
☞ 🔐Admin | 🧩Extensions | 📂Forms