Еbot Server

Материал из боты telegram - ebot.one - редактор ботов
Перейти к: навигация, поиск

Ebot Server is a server library for processing of users’ phrases.

If you use External scripts in the development of bots on the Ebot.one Editor, then this framework was created to work with them as conveniently as possible. Before you start working with any bot that will use external scripts in more than one piece it makes sense to put Ebot Server - it can facilitate logging, show you which variables are not enough for work and what data you are taking from the editor.

In addition, files can be used as a basic set of admin files for the client (for example, he or she will be able to view the activity of users, since the system keeps this information automatically). This guide will show you how to quickly create additional pages. The library was written exactly as a universal starter kit, not the final product.


Ebot server w logo.png

Installation

To install, you must:

  • Download files of the latest version of the library.
  • Unpack the archive and put the files on the server that will handle the response. Example path for files: YOUR_SERVER/public_html/all/ebot_server/ (If you want to choose a different path - do not forget then change the value of the variable $ dir_project of the main configuration file settings.php in the root of the file structure along the path all/ebot_server/)
  • Specify the database connection details in the configuration file settings.php
  • Open the start page of the framework on the path http://vash_server/all/ebot_server/index.php and click on the Create tables button:


Ebot server w init.png


Next, the installation scripts will create the necessary tables in the database for the work of the framework:

Ebot server w init done.png

After installation, the following tables appear in your database:

Ebot server w init tables.png

If it is necessary, you can specify a prefix for the framework tables in the main configuration file settings.php in the variable $ db_pre.

Signing in

After installation, the system offers to be authorized.

You can log in as a user with the root status

login admin

password ebot

After authorization in the system, you will be able to change the password in the Profile

If you forget the password, you can manually set the new login values (the variable $ admin_login_new) and the password (the variable $ admin_password_new) in the configuration file settings.php directory login

Admin panel

After authorization under the administrator (the default administrator has the status root in the user database), you will be transferred to the module (page), which is in the settings.php in the array $ modules_list the user with the status root is indicated as the starting one. This '"startup'" is specified in the key modules_list. In our case, this is the page (module) admin. In other words, after authorization, you will be redirected to the page index.php? Module = admin

Module (page) admin displays the number of users of the system and the list of the last few users added. The admin user is added by the system during the initialization of the user table, while the others are added as soon as the bot interacts automatically.

Ebot server admin 1.png

By clicking on the user's link you can see his dialog with the bot. For example:

Ebot server admin 2.png

Modules

Modules are the same type of structure in the framework, which have:

  • folder in the root folder modules
  • description in the form of a set of properties in the array $ modules_list of the main configuration file settings.php (root of the framework)
  • the name in the file locale_data.php in the root folder locale

All visible pages of the framework are related in one way or another to one of the modules. For example, if the system does not find the requested module in the link, it will load the module 404 (its folder can be found among the modules in the root directory modules). And if, for example, the module is found, but not available to the user with the current status - then the module 401 will be loaded.

Structure of the framework modules:

Ebot server w init dirs.png

To add a new module to the system you need to:

  • copy the structure in the "modules" directory from the most suitable module (for internal pages, the "'page module is best suited, and for the external scripts the demo module);
  • describe as a set of properties in the array $ modules_list of the main configuration file settings.php (root of the framework). In the same place, you can install an icon for the module, it is displayed in the top panel and which users (their status = level of access) will have access to the module.
  • name the module (this name will be displayed in the title of the page) by analogy with others in the file locale_data.php in the root folder locale;
  • rename the function in the file locale_data.php in the folder locale of your new module (obligatory inside (!), because each module has its own folder locale) so that it looks like function getModuleMas (), where Module is the name of your module with a capital letter (uppercase).
  • open the module page in the browser by the link http://YOUR_SERVER/all/ebot_server/index.php? Module = your_module, where your_module is the name of the module folder in the modules.

It may be enough for one module for external scripts, but you also can allocate a new module for each external script.

Demo examples

After installing the framework, several demo examples will be available on the system. For their correct work, you need to fill in the required variables in the file settings.phpand import the command structure file in the bots editor. The file is located in the root directory of the demos framework.

Change the path to the demo scripts after import in the Bots editor in the command structure. Modify the value of URL Resp of the following commands:

  • Demo
  • Demo2
  • Order

External scripts (Demo 1)

Once you have installed the system and are authorized in the startup file set of the framework on the main page, you will be able to link to several demo modules.

Ebot server w logo.png

What is the demo module? For users of the Bots’ Editor who are already know about the concept of external script it will be the easiest - the demo module is an external script wrapped in the module's shell. This is the usual external script (it is in the scripts folder of the module's directory), to which is connected a pair of files with logging functions, localization (languages), etc.

For those who know nothing about such a concept of the bots editor as external script you should spend some time and read our Wiki. In a few words, it is a script that will process the user's response. Those, it is a script that lies on the server, and which the editor will contact if it is specified in the editor structure as responding to some particular command. Suppose there is a command Demo and the bot user enters it to the bot (or presses the button with the inscription Demo). If the command with the name Demo in the editor is specified in the URL Resp http field, the editor will receive the text Demo will call the specified script and give the user what it received from the script. This way you can create dynamic and interactive bots, and not give out boring unchanged phrases.

Ebot server demo 1.png

An example of calling the command '"Demo'" (the structure of the demo bot can be found among the framework files in the root directory "'demos'" file export_2018-06-09_00-27-33.ebot). You can read about importing bots in the section «Import of Bots».

The result of communicating with the external script is modules/demo/scripts/get_demo.php (this script is written with http in the editor structure in the Demo command settings) will be fixed in the system log and reflected on the module page.

Also, on the page you can see the data received from the editor in the last query. You can configure this log type in the configuration file settings.php of the module itself.

Ebot server log data from file.png


If for the operation of the module is not sufficient a determination of any variables in the configuration file settings.php, the system will let you know about it:

Ebot server errors.png

Sending multiple messages to the user (Demo 2)

The second demo demonstrates the work of mailing mechanisms, namely, sending a casual message to the user. To do this, use the class sys_sender, whose file is in the root folder of the sys framework.

The demo module checks the connection to the mailing list (it is paid) and checks whether the variables responsible for the library's "'sys_sender" operation are not empty.

Ebot server demo2 1.png
Ebot server demo2 2.png

Module of Question

The question module simplifies sequential data entry from the user. Even if there are 100 questions in your question chain, not 100 files will be processed but only one. The current constraint of this mechanism is that the user's response can only be a string (currently). Those. Neither the image nor the file, the mechanism cannot accept. In the future, the mechanism may be supplemented with these capabilities.

After installing the framework from the top panel, you will have the module Questions and a demo group of questions with an example of the settings of what files are involved in the responses:

Ebot server questions 1.png


Ebot server questions 2.png


For each question, the system will create a field in the user table and there will add answers if the user activates a chain of questions.


Ebot server questions 3.png

Users

By installation into the created user table the system will automatically add an administrator with the status root. This user has his own login and password for authorization in the system.

Also in the user table will be added all those who communicate with the bot. They are added to the table without logins and passwords and have the status user.

Since version 1.1.2:

If you need to people can registrate in your system and log in with their login and password, change the value of the variable $ registration in the main configuration file settings.php to true, then two modules (registration and remind) will be available in the system. In this case, you will also have to specify the bot name through which you plan to register users. This can be done in the variable $Registration_bot_name of the same configuration file.

To get the bot registration code or password recovery code for users, you need to add 2 commands to bot. Their names do not really matter, the main thing is that they referred to the necessary scripts. For example:

Command name: Get the key

Url Resp: http://YOUR_SERVER/all/ebot_server/modules/registration/scripts/get_hash.php

and

Command name: Password recovery

Url Resp: http://YOUR_SERVER/all/ebot_server/modules/remind/scripts/get_remind.php

Languages

The list of languages you want to have in the system should be specified in locale_utils.php in the function getLangs.

Basic words of the system (and their translation), such as the names of the base modules (sections), are stored in the file locale_data.php of the root directory locale.

Module phrases are stored in locale_data.php along the path modules/MODULE NAME

Russian- (and other languages) module names are in the file locale_data.php of the root directory locale.

Icons

By default, icon files are loaded from fontawesome.com, but you can allocate space on the hosting (19, 4 Mb) for the speed of loading icons and download them (the entire library) fonts. zip (see download page Ebot Server). In this case, the folder fonts should be put in the root of the project and set in the configuration file settings.php in the variable $fonts_local = true.

Read in other languages: rus / deu