Add OpenClaw, backup automation, health checks, Telegram notifications
Deploy Dashboard / deploy (push) Failing after 1m52s
Deploy Dashboard / deploy (push) Failing after 1m52s
Phase 6: OpenClaw docker-compose (port 3100) with health check Phase 9: Enhanced backup.sh with full DB/config coverage + Telegram alerts Phase 10: Health checks on all compose files, /api/system/notify endpoint
This commit is contained in:
@@ -1,11 +1,30 @@
|
||||
import os
|
||||
import shutil
|
||||
import psutil
|
||||
import platform
|
||||
import time
|
||||
import httpx
|
||||
from fastapi import APIRouter
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
TELEGRAM_BOT_TOKEN = os.environ.get("TELEGRAM_BOT_TOKEN", "")
|
||||
TELEGRAM_CHAT_ID = os.environ.get("TELEGRAM_CHAT_ID", "")
|
||||
|
||||
|
||||
@router.post("/notify")
|
||||
async def send_notification(body: dict):
|
||||
"""Send a Telegram notification. Body: {"message": "text"}"""
|
||||
msg = body.get("message", "")
|
||||
if not msg or not TELEGRAM_BOT_TOKEN or not TELEGRAM_CHAT_ID:
|
||||
return {"ok": False, "error": "missing message or Telegram config"}
|
||||
async with httpx.AsyncClient() as client:
|
||||
r = await client.post(
|
||||
f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/sendMessage",
|
||||
data={"chat_id": TELEGRAM_CHAT_ID, "text": msg, "parse_mode": "Markdown"},
|
||||
)
|
||||
return {"ok": r.status_code == 200}
|
||||
|
||||
|
||||
@router.get("/stats")
|
||||
def system_stats():
|
||||
|
||||
Reference in New Issue
Block a user