{ 
    lib,
    python3Packages,
    hectic,
}: python3Packages.buildPythonPackage {
  pname = "dreamproxy-bot";
  version = "1.0";

  src = ./.;

  propagatedBuildInputs = (with python3Packages; [
    # Core bot framework
    aiogram
    magic-filter
    aiosqlite
    apscheduler
    
    # HTTP and web
    aiohttp
    aiofiles
    requests
    flask
    
    # Data validation and serialization
    pydantic
    
    # Utilities
    click
    jinja2
    blinker
    colorama
    certifi
    charset-normalizer
    urllib3
    attrs
    frozenlist
    multidict
    yarl
    propcache
    markupsafe
    itsdangerous
    werkzeug
    typing-extensions
    tzdata
    
    # Localization
    babel
    
  ]) ++ (with hectic; [
    py3-cryptomus
    py3-asyncpayments
    py3-payok
  ]);

  makeWrapperArgs = [
    "--set" "LOCALES_PATH" "$out/share/locales"
  ];

  # Create setup.py since the project doesn't have one
  postPatch = ''
    # Compile locales
    ${python3Packages.babel}/bin/pybabel compile -d locales -D messages
    
    cat > setup.py <<"EOF"
    from setuptools import setup, find_packages
    
    setup(
        name="dreamproxy-bot",
        version="1.0",
        package_data={
            "": ['locales/**/*'],
        },
        include_package_data=True,
        packages=[
          "handlers",
          "keyboards",
          "LightningProxiesAPI",
          "middlewares",
          "models",
          "states",
          "utils"
        ],
        py_modules=['app', 'config'],
        install_requires=[
          "aiofiles==24.1.0",
          "aiogram==3.17.0",
          "aiohappyeyeballs==2.4.4",
          "aiohttp==3.11.11",
          "aiosignal==1.3.2",
          "aiosqlite==0.20.0",
          "annotated-types==0.7.0",
          "APScheduler==3.11.0",
          "AsyncPayments==1.4.6",
          "attrs==25.1.0",
          "blinker==1.6.2",
          "certifi==2023.7.22",
          "charset-normalizer==3.2.0",
          "click==8.1.7",
          "colorama==0.4.6",
          "CryptomusAPI==1.0.1",
          "Flask==2.3.3",
          "frozenlist==1.5.0",
          "idna==3.4",
          "itsdangerous==2.1.2",
          "Jinja2==3.1.2",
          "magic-filter==1.0.12",
          "MarkupSafe==2.1.3",
          "multidict==6.1.0",
          "payok==1.2",
          "propcache==0.2.1",
          "pydantic==2.10.6",
          "pydantic_core==2.27.2",
          "pyTelegramBotAPI==4.13.0",
          "requests==2.31.0",
          "typing_extensions==4.12.2",
          "tzdata==2025.1",
          "tzlocal==5.2",
          "urllib3==2.0.4",
          "Werkzeug==2.3.7",
          "yarl==1.18.3"
        ],
        entry_points={
          "console_scripts": [
            "dreamproxy-bot=app:entrypoint",
          ],
        },
    )
    EOF
  '';

  postInstall = ''
    mkdir -p $out/share/locales
    cp -r locales/* $out/share/locales/
  '';

  meta = with lib; {
    description = "DreamProxy Telegram Bot";
    platforms = platforms.all;
  };
}