Skip to content

Configuration File

Amin Mahmoudi edited this page Oct 5, 2024 · 5 revisions

Configuration File

The configuration file is a Python file that contains the settings for the MasterCryptoFarmBot. This file is located in the MasterCryptoFarmBot directory and is named config.py.

πŸ“„ How to Create a Configuration File

To create a configuration file, copy the config.py.sample file and rename it to config.py. This file will contain the configuration settings for the MasterCryptoFarmBot.

πŸ”΄ Important: Keep the original config.py.sample file intact. Do not rename, delete, or edit config.py.sample, as it is required for updates. Make your changes in config.py after creating a copy of config.py.sample.

🌳 Configuration File Structure

config.py contains the following settings:

  • web_server: The settings for the web server, which is a dictionary containing the following keys:
    • host: The IP address of the web server.
      • Default value: 127.0.0.1, meaning the web server will be accessible only from the same machine (localhost) and not from the network or the internet.
      • To access the web server from the network or the internet, change it to 0.0.0.0 or the specific IP address of the machine within the private network or the internet.
      • Example values: 192.168.1.1 (private network) or 200.200.100.100 (public internet).
      • Setting it to a private IP address restricts access to the web server from within the private network only.
      • Setting it to a public IP address allows access to the web server from the internet.
      • For a Linux VPS without a GUI, set it to 0.0.0.0 to access the web server from the internet.
    • port: The port number of the web server.
      • Default value: 3232. This means you can access the control panel at: http://YOUR-IP:3232.
      • You can use integer values between 1 and 65535.
      • Ensure the port is not being used by other programs.
      • For internet-facing projects, use a random port between 10000 and 64000.
      • If you want to access it from a private network or the internet, ensure the selected port is open and allowed by the firewall.
      • For example, if you change the port to 54321, you can access the control panel at: http://YourIP:54321.
  • telegram_api: This setting configures your Pyrogram settings. If you are not planning to use Pyrogram, this part is not required. For more information about this part, please visit HowTo: Get Telegram API_ID & API_HASH.
  • auto_update: This setting enables or disables the automatic update feature. If set to True, the bot will automatically check for and download updates. If set to False, the bot will not check for updates for the MasterCryptoFarmBot (modules will still be updated). If you enable this feature, make sure to run the project with start_windows.cmd or start_linux.sh, as they will restart the project if it closes due to updates.
  • auto_update_modules: This setting enables or disables the automatic update feature for the modules. If set to True, the bot will automatically check for and download updates for the modules. If set to False, the bot will not check for updates for the modules.
  • update_check_interval: The interval in seconds at which the bot checks for updates. The default value is 3600 seconds (1 hour). You can change this value to check for updates more or less frequently.
  • run_delay: The delay in seconds before the bot starts running modules. The default value is 60 seconds. You can change this value to start the modules sooner or later after launching MasterCryptoFarm.
  • display_module_logs_in_console: This setting enables or disables displaying the module logs in the console. If set to True, the logs will be displayed in the console. If set to False, the logs will not be displayed in the console, but you can still view logs on the modules section of WebPanel.
  • auto_setup_accounts: This setting automates the setup of your Telegram accounts by adding a last name and profile picture. Note that adding a username is mandatory and enabled by default, and it cannot be disabled.

πŸ““ Example Configuration File

Here is an example of a configuration file:

config = {
        "web_server": {
                "host": "0.0.0.0",
                "port": 54321,
        },
        "telegram_api": {
                "api_id": 123456789, # Must be integer/number, no " at start and end
                "api_hash": "00000ceeaeeeeeeeeeeeaaaaaaaaa", # Must be string, don't forget " at start and end
        },
        "auto_update": True,
        "auto_update_modules": True,
        "update_check_interval": 3600,
        "run_delay": 30,
        "display_module_logs_in_console": False,
}

You can check the config.py.sample file for more information.

πŸ“ How to Edit the Configuration File

To edit the configuration file, open the config.py file in a text editor. You can change the settings according to your requirements. After making the changes, save the file.

  • Windows users can use Notepad or Notepad++ to edit the file.
  • Linux users can use Nano or Vim to edit the file.

πŸ”„οΈ How to Apply the Configuration Changes

After editing the configuration file, you need to restart the bot for the changes to take effect. If the bot is running, stop it and start it again.

πŸ”ƒ How to Reset the Configuration File

If you want to reset the configuration file to its default settings, you can delete the config.py file and copy the config.py.sample file again. After copying the config.py.sample file, rename it to config.py.

πŸ›‘οΈ Open Firewall Port

If you are using a firewall, you need to open the port you set in the configuration file. For example, if you set the port to 54321, you need to open port 54321 in your firewall settings.

πŸͺŸ Windows:

  1. Open the Windows Defender Firewall settings.
  2. Click on "Advanced settings" on the left side.
  3. Click on "Inbound Rules" on the left side.
  4. Click on "New Rule" on the right side.
  5. Select "Port" and click "Next".
  6. Select "TCP" and enter the port number you set in the configuration file (e.g., 54321).
  7. Click "Next" and select "Allow the connection".
  8. Click "Next" and select the network types you want to allow the connection on.
  9. Click "Next" and enter a name for the rule (e.g., MasterCryptoFarmBot).
  10. Click "Finish" to create the rule.

For more detailed steps, refer to this guide on how to open a port in Windows Firewall.

🐧 Linux:

First, determine which firewall you are using. The most common firewalls are UFW, Firewalld, and nftables. Check the firewall status to identify which one you are using.

Add firewall rules if your firewall is enabled. If your firewall is disabled, you can skip this step.

πŸ›‘οΈ UFW:

  1. Check the status of UFW:

    sudo ufw status
  2. Allow the port:

    sudo ufw allow 54321
  3. Check the status again:

    sudo ufw status

πŸ›‘οΈ Firewalld:

  1. Check the status of Firewalld:

    sudo firewall-cmd --state
  2. Allow the port:

    sudo firewall-cmd --zone=public --add-port=54321/tcp --permanent
  3. Reload the firewall:

    sudo firewall-cmd --reload
  4. Check the status again:

    sudo firewall-cmd --list-all

πŸ›‘οΈ nftables:

  1. Check the status of nftables:

    sudo nft list ruleset
  2. Allow the port:

    sudo nft add rule inet filter input tcp dport 54321 accept
  3. Save the rules:

    sudo nft list ruleset > /etc/nftables.conf
  4. Reload nftables:

    sudo systemctl reload nftables

For more detailed steps, refer to these guides on opening a port in UFW, Firewalld, and nftables.