feat(mcp): validation humaine telegram, apercu mp3, journal tunis (nyora-2026-10-216-b)
This commit is contained in:
1 parent
5f274df47d
commit
1d6c3a157d
6 files changed
+416
-49
No files matched your search
Executable
+72
@@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""CLI pour la gestion et l'audit de la validation humaine Treblo MCP (Ticket nyora-2026-10-216-b)."""
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import datetime
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
TUNIS_TZ = ZoneInfo("Africa/Tunis")
|
||||
|
||||
def get_path():
|
||||
p = "/app/data/validations.json"
|
||||
if not os.path.exists(os.path.dirname(p)):
|
||||
p = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data", "validations.json")
|
||||
return p
|
||||
|
||||
def load():
|
||||
p = get_path()
|
||||
if not os.path.exists(p):
|
||||
return {"validations": []}
|
||||
try:
|
||||
with open(p, "r", encoding="utf-8") as f:
|
||||
return json.load(f)
|
||||
except Exception:
|
||||
return {"validations": []}
|
||||
|
||||
def save(data):
|
||||
p = get_path()
|
||||
os.makedirs(os.path.dirname(p), exist_ok=True)
|
||||
with open(p, "w", encoding="utf-8") as f:
|
||||
json.dump(data, f, indent=2, ensure_ascii=False)
|
||||
|
||||
def list_validations():
|
||||
data = load()
|
||||
vals = data.get("validations", [])
|
||||
if not vals:
|
||||
print("Aucune demande de validation enregistrée.")
|
||||
return
|
||||
print(f"{'ID':<10} {'SPHÈRE':<8} {'STATUT':<10} {'EXPIRATION':<20} {'TAGS'}")
|
||||
print("-" * 65)
|
||||
for v in vals:
|
||||
tags = ", ".join(v.get("details", {}).get("tags", []))[:30]
|
||||
print(f"{v.get('id'):<10} {v.get('sphere'):<8} {v.get('status'):<10} {v.get('expires_at')[:19]:<20} {tags}")
|
||||
|
||||
def update_status(val_id: str, new_status: str):
|
||||
data = load()
|
||||
found = False
|
||||
for v in data.get("validations", []):
|
||||
if v.get("id") == val_id:
|
||||
v["status"] = new_status
|
||||
v["updated_at"] = datetime.datetime.now(TUNIS_TZ).isoformat()
|
||||
found = True
|
||||
break
|
||||
if found:
|
||||
save(data)
|
||||
print(f"Demande #{val_id} mise à jour avec le statut {new_status}.")
|
||||
else:
|
||||
print(f"Demande #{val_id} introuvable.")
|
||||
|
||||
def main():
|
||||
if len(sys.argv) < 2 or sys.argv[1] == "list":
|
||||
list_validations()
|
||||
elif sys.argv[1] == "approve" and len(sys.argv) > 2:
|
||||
update_status(sys.argv[2], "APPROVED")
|
||||
elif sys.argv[1] == "reject" and len(sys.argv) > 2:
|
||||
update_status(sys.argv[2], "REJECTED")
|
||||
else:
|
||||
print("Usage: python validation_cli.py [list | approve <id> | reject <id>]")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user