mirror of
https://github.com/Lynnesbian/FediBooks/
synced 2024-11-25 08:38:59 +00:00
implemented bot toggle
This commit is contained in:
parent
3b7b479b1b
commit
913b5ed338
2 changed files with 15 additions and 2 deletions
|
@ -45,7 +45,7 @@ body {
|
|||
.panel-icon {
|
||||
width: 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 {
|
||||
width: 150px;
|
||||
|
|
15
webui.py
15
webui.py
|
@ -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 mastodon import Mastodon
|
||||
import requests
|
||||
|
@ -81,6 +81,15 @@ def bot_delete(id):
|
|||
instance = id.split("@")[2]
|
||||
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>")
|
||||
def bot_chat(id):
|
||||
return render_template("coming_soon.html")
|
||||
|
@ -251,6 +260,10 @@ def do_login():
|
|||
else:
|
||||
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):
|
||||
c = mysql.connection.cursor()
|
||||
c.execute("SELECT COUNT(*) FROM `bots` WHERE `handle` = %s AND `user_id` = %s", (bot, session['user_id']))
|
||||
|
|
Loading…
Reference in a new issue