#!/usr/bin/env bash
set -euo pipefail

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT_DIR"

export PYTHONUNBUFFERED=1
export KUBY_PROJECT_ROOT="$ROOT_DIR"

echo "[run_kuby_bot] Using project root: $ROOT_DIR" >&2

if [ -x "$ROOT_DIR/venv/bin/python" ]; then
  exec "$ROOT_DIR/venv/bin/python" "$ROOT_DIR/kuby.py"
elif command -v python3 >/dev/null 2>&1; then
  exec python3 "$ROOT_DIR/kuby.py"
else
  echo "python3 introuvable" >&2
  exit 1
fi
