39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
"""RSS Feed Statistik Tool."""
|
|
|
|
import requests as _req
|
|
from core import config
|
|
|
|
TOOLS = [
|
|
{
|
|
"type": "function",
|
|
"function": {
|
|
"name": "get_feed_stats",
|
|
"description": "RSS Feed-Statistik: Wieviele Artikel wurden heute gesammelt? Welche Quellen sind aktiv?",
|
|
"parameters": {"type": "object", "properties": {}, "required": []},
|
|
},
|
|
},
|
|
]
|
|
|
|
|
|
def handle_get_feed_stats(**kw):
|
|
cfg = config.parse_config()
|
|
ct_109 = config.get_container(cfg, vmid=109)
|
|
if not ct_109 or not ct_109.tailscale_ip:
|
|
return "RSS Manager nicht erreichbar."
|
|
try:
|
|
r = _req.get(f"http://{ct_109.tailscale_ip}:8080/api/feed-stats", timeout=10)
|
|
if not r.ok:
|
|
return "RSS Manager API Fehler."
|
|
stats = r.json()
|
|
lines = [f"Artikel heute: {stats['today']}, gestern: {stats['yesterday']}"]
|
|
for f in stats.get("feeds", []):
|
|
if f["posts_today"] > 0:
|
|
lines.append(f" {f['name']}: {f['posts_today']} heute")
|
|
return "\n".join(lines)
|
|
except Exception as e:
|
|
return f"RSS Manager Fehler: {e}"
|
|
|
|
|
|
HANDLERS = {
|
|
"get_feed_stats": handle_get_feed_stats,
|
|
}
|