from flask import Flask app = Flask(__name__) def populate_webhook_lookup(): lookup = {} with open("./lookup.txt") as file: for line in file: split_line = line.split(",") lookup[split_line[0]]: split_line[1] return lookup UUID_TO_WEBHOOK_LOOKUP = populate_webhook_lookup() def convert_ghost_to_discord(ghost_payload): post = ghost_payload.get("post").get("current") return { "embeds": [{ "title": post.get("title"), "description": post.get("excerpt")[:200] + "...", "url": f"https://torrtle.co/{post.get('slug')}", "color": "0x00ff00", "thumbnail": { "url": post.get("feature_image") }, "fields": [ { "name": "Author", "value": post.get("primary_author").get("name"), "inline": True }, { "name": "Published", "value": post.get("published_at"), "inline": True, } ], }] } @app.route("/") def home(): return "This is a silly web util that converts the Ghost webhook payloads to Discord payloads" @app.route("/hook/