chore: update gitea-chat-bridge/main.py via opax-mcp
Some checks are pending
Check Python Version Consistency / Check Python Version (push) Waiting to run

This commit is contained in:
chris 2026-07-25 07:44:47 +00:00
parent 3f4765e352
commit f467e5bea6

24
gitea-chat-bridge/main.py Normal file
View File

@ -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)