From f4465219d0d64663dbb5c9a165d7577267d6444b Mon Sep 17 00:00:00 2001 From: Lynne Date: Mon, 2 Sep 2019 20:26:45 +1000 Subject: [PATCH] list accounts bot is learning from --- templates/bot_accounts.html | 9 ++++++--- webui.py | 17 +++++++++++++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/templates/bot_accounts.html b/templates/bot_accounts.html index b1f09ce..43eae1c 100644 --- a/templates/bot_accounts.html +++ b/templates/bot_accounts.html @@ -17,16 +17,19 @@
+ {% for user in users %}
-
+
-
@user@instan.ce
-
12345 posts stored
+ {% set handle_list = user['fedi_id'].split('@') %} +
@{{ handle_list[1] }}@{{ handle_list[2] }}
+
{{ "Active" if user['enabled'] else "Inactive" }}
+ {% endfor %}
{% include 'footer.html' %} diff --git a/webui.py b/webui.py index 63feddb..0f7b5e9 100644 --- a/webui.py +++ b/webui.py @@ -78,7 +78,7 @@ def settings(): @app.route("/bot/edit/") def bot_edit(id): - return render_template("bot_edit.html") + return render_template("coming_soon.html") @app.route("/bot/delete/", methods=['GET', 'POST']) def bot_delete(id): @@ -119,7 +119,20 @@ def bot_blacklist(id): def bot_accounts(id): if bot_check(id): session['bot'] = id - return render_template("bot_accounts.html") + c = mysql.connection.cursor() + c.execute("SELECT COUNT(*) FROM `bot_learned_accounts` WHERE `bot_id` = %s", (id,)) + user_count = c.fetchone()[0] + users = {} + + if user_count > 0: + dc = mysql.connection.cursor(MySQLdb.cursors.DictCursor) + dc.execute("SELECT `fedi_id`, `enabled` FROM `bot_learned_accounts` WHERE `bot_id` = %s", (id,)) + users = dc.fetchall() + dc.close() + + c.close() + + return render_template("bot_accounts.html", users = users) @app.route("/bot/accounts/add", methods = ['GET', 'POST']) def bot_accounts_add():