document TruthSeekerApp

This commit is contained in:
Thomas Rubini 2023-01-13 10:05:12 +01:00
parent f7c300785d
commit 4c8e8e3dbe
No known key found for this signature in database
GPG Key ID: C7D287C8C1CAC373

View File

@ -5,6 +5,14 @@ import os
from truthseeker import discord_bot
class TruthSeekerApp(flask.Flask):
"""
Main class of the app
A single instance 'APP' of this class will be created and shared across the files
The class itself is a child class of flask.Flask and has property representing other services
:attr SocketIO socketio_app: the SocketIO service
:attr DiscordBot discord_bot: the Discord Bot service
"""
def __init__(self):
super().__init__("truthseeker")
@ -26,7 +34,10 @@ class TruthSeekerApp(flask.Flask):
def run_app(self):
self.socketio_app.run(self)
def set_app_secret(self):
def set_app_secret(self) -> None:
"""
Set the secret used by flask
"""
if os.path.isfile("instance/secret.txt"):
f = open("instance/secret.txt", "r")
self.config["SECRET_KEY"] = f.read()
@ -41,7 +52,10 @@ class TruthSeekerApp(flask.Flask):
f.close()
print("Generated secret and wrote to secret.txt !")
def get_discord_bot_token(self):
def get_discord_bot_token(self) -> str:
"""
Get the token used by the discord bot
"""
if os.path.isfile("instance/discord_bot_token.txt"):
f = open("instance/discord_bot_token.txt", "r")
token = f.read()