Ekaropolus 8f10aebfa2
All checks were successful
continuous-integration/drone/push Build is passing
Telegram Bot configurable with handlers
2025-09-16 22:23:05 -06:00

37 lines
1.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# pxy_bots/api/views.py
import json
from django.http import JsonResponse, HttpResponse
from django.views.decorators.csrf import csrf_exempt
def health(request):
return JsonResponse({"ok": True, "service": "pxy_bots", "schema_ready": ["req.v1", "render.v1"]})
# pxy_bots/api/views.py
import json
from django.http import JsonResponse
def echo_render(request):
"""
Accepts req.v1 and returns a simple render_spec so you can validate the router.
"""
try:
data = json.loads(request.body.decode("utf-8") or "{}")
except Exception:
data = {}
text = (((data.get("input") or {}).get("text")) or "Hola 👋")
who = (((data.get("user") or {}).get("id")) or "user")
cmd = (((data.get("command") or {}).get("name")) or "none")
spec = {
"schema_version": "render.v1",
"messages": [
{"type": "text", "text": f"echo: user={who} cmd={cmd}"},
{"type": "text", "text": f"you said: {text}"},
],
"buttons": [
{"label": "Abrir Dashboard", "kind": "open_url", "url": "https://app.polisplexity.tech/"},
{"label": "Re-ejecutar 10", "kind": "callback_api", "action": "rerun", "params": {"minutes": 10}},
],
}
return JsonResponse(spec)