From 60728c0b35c551ae99db20619de0d0039c684729 Mon Sep 17 00:00:00 2001 From: Lynne Date: Mon, 20 Jan 2020 13:01:56 +1000 Subject: [PATCH] message generation for bot chat --- app/functions.py | 13 +++++++------ app/webui.py | 9 ++++++++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/functions.py b/app/functions.py index 8af304d..a620b32 100644 --- a/app/functions.py +++ b/app/functions.py @@ -63,12 +63,6 @@ def generate_output(handle): """, (handle,)) bot = dc.fetchone() - client = Mastodon( - client_id = bot['client_id'], - client_secret = bot['client_secret'], - access_token = bot['secret'], - api_base_url = "https://{}".format(handle.split("@")[2]) - ) # by default, only select posts that don't have CWs. # if learn_from_cw, then also select posts with CWs @@ -133,6 +127,13 @@ def make_post(args): acct = args[3] handle = args[0] + client = Mastodon( + client_id = bot['client_id'], + client_secret = bot['client_secret'], + access_token = bot['secret'], + api_base_url = "https://{}".format(handle.split("@")[2]) + ) + bot, post = generate_output(handle) # print(post) diff --git a/app/webui.py b/app/webui.py index d07d0bc..8ecbcf0 100644 --- a/app/webui.py +++ b/app/webui.py @@ -160,7 +160,14 @@ def bot_toggle(id): @app.route("/bot/chat/") def bot_chat(id): # return render_template("coming_soon.html") - return render_template("/bot/chat.html", bot = id) + if bot_check(id): + return render_template("/bot/chat.html", bot = id) + +@app.route("/bot/chat//message") +def bot_chat_message(id): + if bot_check(id): + _, message = functions.generate_output(id) + return message @app.route("/bot/blacklist/") def bot_blacklist(id):