diff --git a/images/test.png b/images/test.png new file mode 100644 index 0000000..e69de29 diff --git a/images/water-willow.png b/images/water-willow.png new file mode 100644 index 0000000..367e3cb Binary files /dev/null and b/images/water-willow.png differ diff --git a/page copy.html b/page copy.html index 0091ae7..b841f8f 100644 --- a/page copy.html +++ b/page copy.html @@ -11,7 +11,7 @@ { "component": { "type": 17, - "accent_color": 16711680, + "accent_color": {{Color}}, "components": [ { "type": 10, diff --git a/page.html b/page.html index 008201b..b5d3983 100644 --- a/page.html +++ b/page.html @@ -11,20 +11,32 @@ { "component": { "type": 17, - "accent_color": 16711680, + "accent_color": {{Color}}, "components": [ { - "type": 10, - "content": "{{CurrText}}\n{{Choices}}" + "type": 9, + "components": [ + { + "type": 10, + "content": "## {{CurrText}}" + } + ], + "accessory": { + "type": 11, + "media": { + "url": "https://adventure.lockeshor.com/img/{{StoryName}}.png" + } + } }, + {{Choices}} { "type": 14, - "spacing": 1, - "divider": true + "divider": false, + "spacing": 2 }, { "type": 10, - "content": "type s/0/[choice] where [choice] is your selected option to choose your path!" + "content": "-# send \"s/0/[choice]\" where [choice] is your selected option to choose your path!" } ] } @@ -35,7 +47,7 @@ -

test

+

you should not see this. contact lockeshor@lockeshor.com

\ No newline at end of file diff --git a/server.py b/server.py index 82d32bf..e295e89 100644 --- a/server.py +++ b/server.py @@ -1,5 +1,5 @@ import json -from flask import Flask, request, render_template +from flask import Flask, request, send_file app = Flask(__name__) @@ -12,8 +12,11 @@ def mainPage(): def game(path): if "Discord" not in str(request.user_agent): return mainPage() + gameName = request.path.split("/")[1] + if gameName == "img": + print("returning image", "images/" + request.path.split("/")[-1].replace(".", "")[:-3] + ".png") + return send_file("images/" + request.path.split("/")[-1].replace(".", "")[:-3] + ".png", mimetype="image/png") gamecode = request.args.get('code')[:-1] - gameName = request.path[1:] print(gameName) return buildHTML(gamecode,gameName) @@ -31,11 +34,22 @@ def buildHTML(gamecode, gameName): choices = "" for i in range(len(info["choices"])): choice = info["choices"][i] - choices += f"{(i + 1) * 10}: " + choice["text"] + "\\n" - print(str(request.user_agent) + "\n",currText,choices) + choiceText = f"{(i + 1) * 10}: " + choice["text"].replace('"', '\\"') + "\\n" + choices += f"""{{ + "type": 10, + "content": "{choiceText}" + }},""" + color = story["SPECIAL-color"] if "SPECIAL-color" in story.keys() else "0" + print(str(request.user_agent) + "\n",currText,choices,color) with open('page.html', "r") as page: - return page.read().replace("{{CurrText}}", currText.replace('"', '\\"')).replace("{{Choices}}", choices.replace('"', '\\"')) + page = page.read() + page = page.replace("{{CurrText}}", currText.replace('"', '\\"')) + page = page.replace("{{Choices}}", choices) + page = page.replace("{{Color}}", color) + page = page.replace("{{StoryName}}", gameName.replace(".", "")) + print(page) + return page if __name__ == '__main__': app.run(debug=True, port=1387) diff --git a/stories/water-willow.json b/stories/water-willow.json index b2611ff..ca8c519 100644 --- a/stories/water-willow.json +++ b/stories/water-willow.json @@ -1,4 +1,5 @@ { + "SPECIAL-color": "8388863", "start": { "text": "Willow wants water. She screams at the top of her lungs. What do you do?", "choices": [