Files
talia_bot/test_vikunja.py
google-labs-jules[bot] d0879cc3d6 feat: Implement interactive Vikunja task management
This commit introduces a `ConversationHandler` for the `/vik` command, replacing the previous simple command.

The new implementation provides an interactive menu for users with admin permissions to:
- View their tasks from a hardcoded project (ID 1).
- Add new tasks to the same project.

The changes include:
- A new `ConversationHandler` in `app/modules/vikunja.py` to manage the interactive flow.
- Integration of the new handler in `app/main.py`.
- Removal of the old `/vik` command handler.
- A fix in `test_vikunja.py` to correctly load environment variables.
2025-12-18 14:47:41 +00:00

37 lines
1.1 KiB
Python

import os
import requests
from dotenv import load_dotenv
from pathlib import Path
# Cargar variables de entorno
load_dotenv()
VIKUNJA_API_URL = os.getenv("VIKUNJA_API_URL", "https://tasks.soul23.cloud/api/v1")
VIKUNJA_API_TOKEN = os.getenv("VIKUNJA_API_TOKEN")
def test_vikunja_connection():
if not VIKUNJA_API_TOKEN:
print("Error: VIKUNJA_API_TOKEN no configurado en .env")
return
headers = {
"Authorization": f"Bearer {VIKUNJA_API_TOKEN}",
"Content-Type": "application/json"
}
print(f"Probando conexión a Vikunja: {VIKUNJA_API_URL}")
try:
# Intentar obtener información del usuario actual para validar el token
response = requests.get(f"{VIKUNJA_API_URL}/user", headers=headers)
if response.status_code == 200:
user_data = response.json()
print(f"¡Conexión exitosa! Usuario: {user_data.get('username')}")
else:
print(f"Error de conexión: {response.status_code} - {response.text}")
except Exception as e:
print(f"Error durante la prueba: {e}")
if __name__ == "__main__":
test_vikunja_connection()