Skip to content

Latest commit

 

History

History
205 lines (145 loc) · 4.91 KB

File metadata and controls

205 lines (145 loc) · 4.91 KB

Helpful information

In this file, you can find answers to frequently asked questions and useful commands.


💬 Useful commands

Update Dependencies

First, run just outdated to check for outdated dependencies. Then, edit pyproject.toml file and run the following command to update dependencies:

just outdated

# Edit pyproject.toml

uv lock --upgrade
just sync

Check Dependencies Updates

just outdated

Linting

just lint

MyPy

just mypy

Formatting

just format

💢 The term 'just' is not recognized as the name of a cmdlet, function, script file, or operable program.

⚠️ You, as developer, MUST have just installed on your system to use Justfile commands.


❓ How to install UV?

[Windows] Answer:

  1. Open PowerShell
  2. Install UV using the following command:
    powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
  3. Restart PowerShell to apply changes.
  4. Verify the installation by running:
    uv --version

[Linux] Answer:

  1. Open your terminal.
  2. Install UV using the following command:
     curl -LsSf https://astral.sh/uv/install.sh | sh
  3. Restart your terminal to apply changes.
  4. Verify the installation by running:
    uv --version

❓ How to install Docker?

[Windows] Answer:

  1. Download Docker Desktop from the official Docker website: https://www.docker.com/products/docker-desktop
  2. Run the installer and follow the on-screen instructions.
  3. After installation, Docker Desktop should start automatically. If not, you can start it from the Start menu.
  4. Verify the installation by opening PowerShell and running:
    docker --version
  5. You may need to log in to Docker Desktop with your Docker Hub account or create a new one.
  6. Ensure that WSL 2 is enabled on your system for better performance.
  7. Restart your computer if prompted.

[Linux] Answer:

  1. Open https://docs.docker.com/engine/install
  2. Follow the instructions for your specific Linux distribution.
  3. After installation, you may need to start the Docker service:
    sudo systemctl start docker
  4. Enable Docker to start on boot:
    sudo systemctl enable --now docker
  5. Verify the installation by running:
    docker --version

❓ Why PyCharm marks import with red color?

I use "unique" project structure, where app directory contains code, but root directory contains configuration files.

In PyCharm, right-click on the bot directory and select Mark Directory as -> Sources Root. Also, unmark project root directory Unmark as Sources Root. This will fix the problem.

image

image

image


❓ Why You use __import__?

My inclinations make me do this to avoid some attack vector invented by my "paranoia"


❓ Why not use aiogram-cli?

It's a good library, but I prefer to use my own code 🤷‍♂️


❓ How to properly set up .env file?
  1. After cloning the repository, navigate to the project root.

  2. Copy the example file based on your development environment:

    • For local: cp env.example .env
  3. Open the new .env file in a text editor.

  4. Fill in the required variables:

    • DEV: Set to True for development environment, False for production. (If set to True - all connections will be to localhost)
    • BOT_TOKEN: Your Telegram bot token from BotFather.
    • POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB: PostgreSQL credentials.
    • REDIS_PASSWORD: Redis password (if using authentication).
    • WEBHOOKS: Set to True if using webhooks, otherwise False.
    • WEBHOOK_URL and WEBHOOK_SECRET_TOKEN: Required if webhooks are enabled.
  5. Save the file. Avoid committing .env to version control - add it to .gitignore if not already.


❓ How to enable and configure webhooks?
  1. In your .env file, set WEBHOOKS=True.
  2. Set WEBHOOK_URL to your bot's webhook endpoint (e.g., https://example.com/webhook).
  3. Set WEBHOOK_SECRET_TOKEN to a secure random string.
  4. Uncomment the caddy service in docker-compose.yml to enable Caddy.