4. Configuring the bot

4.1. The .env file

After the process of building the binary application from source code, the installer ran the bot. At the first start, the bot checks for the presence of the .env file in the location from which it was launched and if there is no such file, it will be created automatically.

This file contains the basic program settings of the bot, which are critical for its correct operation. Let's take a look at these settings, since you will need to make certain edits here:

4.1.1. BLUECOSMO_USERNAME is your login with BlueCosmo (usually your e-mail).

4.1.2. BLUECOSMO_PASSWORD is your password with BlueCosmo.

4.1.3. TG_AUTHORIZED_USERS is an ACL (Access Control List), a list of Telegram user IDs that are allowed to access your bot. To figure out your own ID, please contact the @userinfobot via Telegram.

If you want to grant several Telegram users access to your bot, you can list their IDs in this parameter, separated by commas with no spaces.

4.1.4. TG_BOT_TOKEN is a token saved by you before (refer here 2. Creating the bot)

4.1.5. To start editing an .env file run this command:

nano /etc/bluecosmo/.env

4.1.6. To save the file please press Control+X and then «Y».

4.2. The Supervisor

Since your bot is a binary executable application, you must ensure that it is always running. The best way to do this is with free software called Supervisor. After checking the .env file successfully, the bot will detect the presence of a supervisor on the system. If there is no supervisor, it will be installed into the system automatically. After that, the bot will also create the necessary supervisor configuration files and restart itself with it.

4.2.1. The configuration file for the supervisor created by the bot is located here: /etc/supervisor/conf.d/bluecosmo-tg.conf. I do not recommend editing this file without understanding exactly what you are doing, as this can cause problems with the main bot process.

4.2.2. While performing updates, or any other work on the bot and/or its configuration on the server, it is recommended to disable the bot by running the command:

supervisorctl stop bluecosmo-tg

4.2.3. The start and restart commands are also available:

supervisorctl [start|restart] bluecosmo-tg

4.2.4. If something happens to the bot, refer to the log file: /var/log/bluecosmo-tg.log.

Last updated