First Push

This commit is contained in:
Mechseroms 2026-05-06 15:34:08 -05:00
commit cb46b5ce9f
2 changed files with 40 additions and 0 deletions

Binary file not shown.

40
main.py Normal file
View File

@ -0,0 +1,40 @@
from fastapi import FastAPI, Request
from mastodon import Mastodon
app = FastAPI()
# Configure from environment variables (recommended)
MASTODON_API_BASE_URL = "https://mastodon.versi-tech.com"
MASTODON_ACCESS_TOKEN = "xQUR-poG42E_PVqYs6-vZ9WmWngfcG_h9vzXPJVlqQY"
# Initialize Mastodon client
mastodon = Mastodon(
access_token=MASTODON_ACCESS_TOKEN,
api_base_url=MASTODON_API_BASE_URL
)
@app.post("/bookstack")
async def receive_bookstack_webhook(request: Request):
payload = await request.json()
print("Received payload:", payload)
event = payload.get('event', 'BookStack update')
url = payload.get('url', None)
summary = payload.get('summary', '')
actor = payload.get('initiator', {}).get('name', 'Someone')
text = payload.get('text', 'Someone triggered on event on the Bookstack')
status = f"{text}.\n\n"
if summary:
status += f"Summary: {summary}\n"
if url:
status += f"{url}"
try:
mastodon.status_post(status)
pass
except Exception as ex:
print("Error posting to Mastodon:", ex)
return {"success": False, "error": str(ex)}
return {"success": True}