From f467e5bea6d8deb0537789e09c12f059f5a4e6c1 Mon Sep 17 00:00:00 2001 From: chris Date: Sat, 25 Jul 2026 07:44:47 +0000 Subject: [PATCH] chore: update gitea-chat-bridge/main.py via opax-mcp --- gitea-chat-bridge/main.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 gitea-chat-bridge/main.py diff --git a/gitea-chat-bridge/main.py b/gitea-chat-bridge/main.py new file mode 100644 index 0000000..770620d --- /dev/null +++ b/gitea-chat-bridge/main.py @@ -0,0 +1,24 @@ +import functions_framework +import requests +import os + +CHAT_WEBHOOK = os.environ.get("CHAT_WEBHOOK_URL") + +@functions_framework.http +def handler(request): + try: + payload = request.get_json(silent=True) or {} + repo = payload.get("repository", {}).get("full_name", "unknown") + pusher = payload.get("pusher", {}).get("login", "unknown") + ref = payload.get("ref", "").replace("refs/heads/", "") + commits = payload.get("commits", []) + lines = [f"\U0001f500 *Push til {repo}* \u2014 branch {ref} av {pusher}"] + for c in commits[:5]: + sha = c.get("id","")[:7] + msg = c.get("message","").split("\n")[0][:80] + url = c.get("url","") + lines.append(f" \u2022 {sha}: {msg}\n {url}") + requests.post(CHAT_WEBHOOK, json={"text": "\n".join(lines)}, timeout=5) + return ("OK", 200) + except Exception as e: + return (str(e), 500)