From c50b73477c0859b9682ea9d56fc1938752964327 Mon Sep 17 00:00:00 2001 From: Thomas Rubini <74205383+ThomasRubini@users.noreply.github.com> Date: Thu, 16 Feb 2023 08:28:58 +0100 Subject: [PATCH] Remove last occurences of 'APP' --- truthinquiry/app.py | 1 - truthinquiry/ext/discord_bot.py | 3 ++- truthinquiry/routes/routes_api.py | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/truthinquiry/app.py b/truthinquiry/app.py index bdfc02a..cfd8324 100644 --- a/truthinquiry/app.py +++ b/truthinquiry/app.py @@ -7,7 +7,6 @@ from truthinquiry.ext import discord_bot class TruthInquiryApp(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 diff --git a/truthinquiry/ext/discord_bot.py b/truthinquiry/ext/discord_bot.py index 0b277fb..18c58ed 100644 --- a/truthinquiry/ext/discord_bot.py +++ b/truthinquiry/ext/discord_bot.py @@ -4,6 +4,7 @@ import asyncio import discord import truthinquiry.app as app +import truthinquiry.logic.game_logic class DiscordBot: @@ -65,7 +66,7 @@ class DiscordBot: """ Update the bot's status using the app's current context """ - games_n = len(app.APP.games_list) + games_n = len(app.game_logic.games_list) activity_name = f"Handling {games_n} game{'' if games_n==1 else 's'} !" activity = discord.Activity(name=activity_name, type=discord.ActivityType.watching) await self.bot.change_presence(activity=activity) diff --git a/truthinquiry/routes/routes_api.py b/truthinquiry/routes/routes_api.py index 4337ee7..b2d5f76 100644 --- a/truthinquiry/routes/routes_api.py +++ b/truthinquiry/routes/routes_api.py @@ -102,7 +102,7 @@ def start_game(): return {"error": 1, "msg": "this game is already started"} game.generate_data() game.has_started = True - APP.socketio_app.emit("gamestart", {}, room="game."+game.game_id) + socket_io.emit("gamestart", {}, room="game."+game.game_id) return {"error": 0} @routes_api.route("/getGameData", methods=["GET", "POST"]) @@ -168,7 +168,7 @@ def game_progress(): username = flask.session["username"] game.get_member(username).progress += 1 - APP.socketio_app.emit("gameprogress", [flask.session["username"]], room="game."+game.game_id) + socket_io.emit("gameprogress", [flask.session["username"]], room="game."+game.game_id) return {"error": 0} @@ -200,7 +200,7 @@ def check_anwser(): member.results = results if game.has_finished(): json_game_results = game.generate_game_results() - APP.socketio_app.emit("gamefinished", json_game_results, room="game."+game.game_id) + socket_io.emit("gamefinished", json_game_results, room="game."+game.game_id) del game response = {"error": 0} return response