mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-11-14 18:11:23 +01:00
Implemented Bot Admin Blueprint
Todo and not yet fully functional yet Fix Titan Dev thing Fix Titan Dev thing Fix Titan Dev thing Fix Titan Dev thing Fix Titan Dev thing Fix Titan Dev thing Fix Titan Dev thing Fix Titan Dev thing Fix Titan Dev thing Fix Titan Dev thing Fix Titan Dev thing
This commit is contained in:
parent
bcfa4ae4e9
commit
dc7d825564
@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env python2
|
||||
from titanembeds.app import app
|
||||
import subprocess
|
||||
|
||||
def init_debug():
|
||||
import os
|
||||
@ -30,6 +31,14 @@ def init_debug():
|
||||
decoded = None
|
||||
return jsonify(session_cookie=decoded)
|
||||
|
||||
@app.route("/github-update", methods=["POST"])
|
||||
def github_update():
|
||||
try:
|
||||
subprocess.Popen("git pull", shell=True).wait()
|
||||
except OSError:
|
||||
return "ERROR"
|
||||
|
||||
return "OK"
|
||||
if __name__ == "__main__":
|
||||
init_debug()
|
||||
app.run(host="0.0.0.0",port=3000,debug=True,processes=3)
|
||||
|
@ -0,0 +1,2 @@
|
||||
global devs
|
||||
devs = [ "138881969185357825" , "197322731115642880", "193908323911860224" ]
|
@ -5,8 +5,10 @@ from flask_sslify import SSLify
|
||||
from titanembeds.utils import rate_limiter, discord_api, bot_alive
|
||||
import blueprints.api
|
||||
import blueprints.user
|
||||
import blueprints.admin
|
||||
import blueprints.embed
|
||||
import os
|
||||
from titanembeds import devs
|
||||
|
||||
|
||||
os.chdir(config['app-location'])
|
||||
@ -23,6 +25,7 @@ rate_limiter.init_app(app)
|
||||
sslify = SSLify(app, permanent=True)
|
||||
|
||||
app.register_blueprint(blueprints.api.api, url_prefix="/api", template_folder="/templates")
|
||||
app.register_blueprint(blueprints.admin.admin, url_prefix="/admin", template_folder="/templates")
|
||||
app.register_blueprint(blueprints.user.user, url_prefix="/user", template_folder="/templates")
|
||||
app.register_blueprint(blueprints.embed.embed, url_prefix="/embed", template_folder="/templates")
|
||||
|
||||
@ -42,4 +45,4 @@ def before_request():
|
||||
@app.context_processor
|
||||
def context_processor():
|
||||
bot_status = bot_alive()
|
||||
return {"bot_status": bot_status}
|
||||
return {"bot_status": bot_status, "devs": devs}
|
1
webapp/titanembeds/blueprints/admin/__init__.py
Normal file
1
webapp/titanembeds/blueprints/admin/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
from admin import admin
|
22
webapp/titanembeds/blueprints/admin/admin.py
Normal file
22
webapp/titanembeds/blueprints/admin/admin.py
Normal file
@ -0,0 +1,22 @@
|
||||
from flask import Blueprint, url_for, redirect, session, render_template
|
||||
from functools import wraps
|
||||
from titanembeds import devs
|
||||
|
||||
admin = Blueprint("admin", __name__)
|
||||
|
||||
def is_admin(f):
|
||||
def decorator(f):
|
||||
@wraps(f)
|
||||
def decorated_function(*args, **kwargs):
|
||||
if 'user_id' not in session:
|
||||
return redirect(url_for("index"))
|
||||
if session['user_id'] not in devs:
|
||||
return redirect(url_for("index"))
|
||||
return f(*args, **kwargs)
|
||||
return decorated_function
|
||||
return decorator(f)
|
||||
|
||||
@admin.route("/")
|
||||
@is_admin
|
||||
def index():
|
||||
return render_template("admin_index.html.j2")
|
@ -2,6 +2,7 @@ from titanembeds.database import db, Guilds, UnauthenticatedUsers, Unauthenticat
|
||||
from titanembeds.decorators import valid_session_required, discord_users_only
|
||||
from titanembeds.utils import check_guild_existance, guild_accepts_visitors, guild_query_unauth_users_bool, get_client_ipaddr, discord_api, rate_limiter, channel_ratelimit_key, guild_ratelimit_key
|
||||
from titanembeds.oauth import user_has_permission, generate_avatar_url, check_user_can_administrate_guild
|
||||
from titanembeds import devs
|
||||
from flask import Blueprint, abort, jsonify, session, request, url_for
|
||||
from sqlalchemy import and_
|
||||
import random
|
||||
@ -380,7 +381,6 @@ def post():
|
||||
userid = session["user_id"]
|
||||
content = format_everyone_mention(chan, content)
|
||||
webhook = get_channel_webhook_url(guild_id, channel_id)
|
||||
devs = [ "138881969185357825" , "197322731115642880" ]
|
||||
if userid in devs:
|
||||
oldcontent = content
|
||||
content = "(Titan Dev) " + oldcontent
|
||||
|
6
webapp/titanembeds/templates/admin_index.html.j2
Normal file
6
webapp/titanembeds/templates/admin_index.html.j2
Normal file
@ -0,0 +1,6 @@
|
||||
{% extends 'site_layout.html.j2' %}
|
||||
{% block title %}Admin{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
{% endblock %}
|
@ -24,6 +24,10 @@
|
||||
{% if session['unauthenticated'] is defined and not session['unauthenticated'] %}
|
||||
<ul id="menu_dropdown" class="dropdown-content">
|
||||
<li><a href="{{ url_for('user.dashboard') }}">Dashboard</a></li>
|
||||
{% if session['user_id'] is defined and session['user_id'] in devs %}
|
||||
<li class="divider"></li>
|
||||
<li><a href="{{ url_for('admin.index') }}">Admin</a></li>
|
||||
{% endif %}
|
||||
<li class="divider"></li>
|
||||
<li><a href="{{ url_for('user.logout') }}">Logout</a></li>
|
||||
</ul>
|
||||
|
Loading…
Reference in New Issue
Block a user