1
0
Fork 0
mirror of https://github.com/Lynnesbian/FediBooks/ synced 2024-11-25 16:48:58 +00:00

implemented bot toggle

This commit is contained in:
Lynne Megido 2019-09-02 17:38:29 +10:00
parent 3b7b479b1b
commit 913b5ed338
2 changed files with 15 additions and 2 deletions

View file

@ -45,7 +45,7 @@ body {
.panel-icon { .panel-icon {
width: 100px; width: 100px;
height: 100px; height: 100px;
background: center/contain url("https://cloud.lynnesbian.space/s/JZCPTs3DzMLAspC/preview"); background: center/contain url("/img/bot_generic.png");
} }
.panel-icon.large { .panel-icon.large {
width: 150px; width: 150px;

View file

@ -1,4 +1,4 @@
from flask import Flask, render_template, session, request, redirect, url_for from flask import Flask, render_template, session, request, redirect, url_for, send_file
from flask_mysqldb import MySQL from flask_mysqldb import MySQL
from mastodon import Mastodon from mastodon import Mastodon
import requests import requests
@ -81,6 +81,15 @@ def bot_delete(id):
instance = id.split("@")[2] instance = id.split("@")[2]
return render_template("bot_delete.html", instance = instance) return render_template("bot_delete.html", instance = instance)
@app.route("/bot/toggle/<id>")
def bot_toggle(id):
if bot_check(id):
c = mysql.connection.cursor()
c.execute("UPDATE `bots` SET `enabled` = NOT `enabled` WHERE `handle` = %s", (id,))
mysql.connection.commit()
c.close()
return redirect(url_for("home"), 303)
@app.route("/bot/chat/<id>") @app.route("/bot/chat/<id>")
def bot_chat(id): def bot_chat(id):
return render_template("coming_soon.html") return render_template("coming_soon.html")
@ -251,6 +260,10 @@ def do_login():
else: else:
return "invalid login" return "invalid login"
@app.route("/img/bot_generic.png")
def img_bot_generic():
return send_file("static/bot_generic.png", mimetype="image/png")
def bot_check(bot): def bot_check(bot):
c = mysql.connection.cursor() c = mysql.connection.cursor()
c.execute("SELECT COUNT(*) FROM `bots` WHERE `handle` = %s AND `user_id` = %s", (bot, session['user_id'])) c.execute("SELECT COUNT(*) FROM `bots` WHERE `handle` = %s AND `user_id` = %s", (bot, session['user_id']))