diff --git a/truthseeker/__init__.py b/truthseeker/__init__.py index 909bb11..87a0a1d 100644 --- a/truthseeker/__init__.py +++ b/truthseeker/__init__.py @@ -1,9 +1,11 @@ -import flask -from flask_socketio import SocketIO import os +import flask +from flask_socketio import SocketIO + from truthseeker import discord_bot + class TruthSeekerApp(flask.Flask): """ Main class of the app @@ -26,14 +28,10 @@ class TruthSeekerApp(flask.Flask): self.discord_bot = discord_bot.DiscordBot() token = os.getenv("DISCORD_BOT_TOKEN") if token: - pass self.discord_bot.start(token) else: print("No token set. Not starting discord bot") - def run_app(self): - self.socketio_app.run(self) - APP = TruthSeekerApp() from truthseeker.routes import routes_api, routes_ui, routes_socketio diff --git a/truthseeker/discord_bot.py b/truthseeker/discord_bot.py index 9a9a354..3205de6 100644 --- a/truthseeker/discord_bot.py +++ b/truthseeker/discord_bot.py @@ -1,14 +1,17 @@ -import discord import threading -import truthseeker import asyncio +import discord +import truthseeker + + class DiscordBot: """ Wrapper around a discord bot, providing utility methods to interact with it :attr Client bot: the underlying discord bot from discord.py :attr TextChannel __channel__: the channel used by the bot to send messages + :attr event_loop: event_loop used by discord.py. Used to schedule tasks from another thread """ def __init__(self): diff --git a/truthseeker/logic/data_persistance/tables.py b/truthseeker/logic/data_persistance/tables.py index 26bebca..f8960ab 100644 --- a/truthseeker/logic/data_persistance/tables.py +++ b/truthseeker/logic/data_persistance/tables.py @@ -1,8 +1,8 @@ from sqlalchemy import Column, Integer, Text, ForeignKey, VARCHAR from sqlalchemy.orm import declarative_base, relationship -Base = declarative_base() +Base = declarative_base() class Locale(Base): __tablename__ = 'T_LOCALE' diff --git a/truthseeker/logic/game_logic.py b/truthseeker/logic/game_logic.py index 62717fd..8764b77 100644 --- a/truthseeker/logic/game_logic.py +++ b/truthseeker/logic/game_logic.py @@ -1,9 +1,9 @@ import string import random +from typing import Union + from truthseeker.logic.data_persistance.data_access import * -from datetime import datetime, timedelta from truthseeker import APP -from typing import Union, Optional def random_string(length: int) ->str: """ diff --git a/truthseeker/routes/routes_api.py b/truthseeker/routes/routes_api.py index 74548f9..af56efc 100644 --- a/truthseeker/routes/routes_api.py +++ b/truthseeker/routes/routes_api.py @@ -1,5 +1,7 @@ -import flask import json + +import flask + from truthseeker import APP from truthseeker.logic import game_logic diff --git a/truthseeker/routes/routes_socketio.py b/truthseeker/routes/routes_socketio.py index d94816e..8288d4a 100644 --- a/truthseeker/routes/routes_socketio.py +++ b/truthseeker/routes/routes_socketio.py @@ -1,9 +1,11 @@ -from flask_socketio import join_room import socketio +from flask_socketio import join_room + from truthseeker import APP from truthseeker.logic import game_logic + @APP.socketio_app.on('connect') def connect(auth): if not (auth and "game_id" in auth): diff --git a/truthseeker/routes/routes_ui.py b/truthseeker/routes/routes_ui.py index a439b70..63a0e47 100644 --- a/truthseeker/routes/routes_ui.py +++ b/truthseeker/routes/routes_ui.py @@ -1,7 +1,5 @@ import flask -from truthseeker.logic import game_logic - routes_ui = flask.Blueprint("ui", __name__)