Compare commits

..

No commits in common. "07cf930328b4b08e2285521610289dcc820b1b4c" and "5d551b3dd8e506d92a59c16c9e6dfb9f32ee8064" have entirely different histories.

5 changed files with 5 additions and 61 deletions

View File

@ -13,4 +13,4 @@ RUN pip install --no-cache-dir -r requirements.txt
COPY . /app/
CMD ["sh", "-c", "aerich upgrade && python bot.py"]
CMD ["python", "bot.py"]

14
bot.py
View File

@ -21,15 +21,6 @@ log = logging.getLogger(__name__)
BASE_DIR = Path(__file__).resolve().parent
DATA_DIR = getenv("SPIFFO__DATA_FOLDER_PATH")
TORTOISE_ORM = {
"connections": { "default": f"sqlite://{str(DATA_DIR)}/db.sqlite" },
"apps": {
"models": {
"models": ["utils.models", "aerich.models"],
"default_connection": "default"
}
}
}
class DiscordBot(commands.Bot):
@ -126,7 +117,10 @@ async def main():
bot_token = get_bot_token()
# Open database connection
await Tortoise.init(config=TORTOISE_ORM)
await Tortoise.init(
db_url= f"sqlite://{str(DATA_DIR)}/db.sqlite",
modules={"models": ["utils.models"]}
)
await Tortoise.generate_schemas()
async with DiscordBot(debug_mode) as bot:

View File

@ -1,42 +0,0 @@
from tortoise import BaseDBAsyncClient
async def upgrade(db: BaseDBAsyncClient) -> str:
return """
CREATE TABLE IF NOT EXISTS "players" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"username" VARCHAR(20) NOT NULL UNIQUE,
"last_connection" TIMESTAMP,
"last_disconnection" TIMESTAMP,
"play_time_seconds" INT NOT NULL DEFAULT 0,
"is_dead" INT NOT NULL DEFAULT 0
) /* */;
CREATE TABLE IF NOT EXISTS "player_deaths" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"coordinate_x" INT NOT NULL,
"coordinate_y" INT NOT NULL,
"coordinate_z" INT NOT NULL,
"cause" VARCHAR(32) NOT NULL,
"timestamp" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
"player_id" INT NOT NULL REFERENCES "players" ("id") ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS "steam_profile_summary" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"steam_id" VARCHAR(20) NOT NULL UNIQUE,
"profile_name" VARCHAR(32) NOT NULL,
"url" VARCHAR(128) NOT NULL,
"avatar_url" VARCHAR(128) NOT NULL,
"last_update" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
"player_id" INT NOT NULL REFERENCES "players" ("id") ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS "aerich" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"version" VARCHAR(255) NOT NULL,
"app" VARCHAR(100) NOT NULL,
"content" JSON NOT NULL
);"""
async def downgrade(db: BaseDBAsyncClient) -> str:
return """
"""

View File

@ -1,4 +0,0 @@
[tool.aerich]
tortoise_orm = "bot.TORTOISE_ORM"
location = "./migrations"
src_folder = "./."

View File

@ -1,4 +1,3 @@
aerich==0.8.0
aiofiles==24.1.0
aiohappyeyeballs==2.4.4
aiohttp==3.11.9
@ -6,11 +5,9 @@ aiosignal==1.3.1
aiosqlite==0.20.0
annotated-types==0.7.0
anyio==4.7.0
asyncclick==8.1.7.2
attrs==24.2.0
bump2version==1.0.1
certifi==2024.8.30
dictdiffer==0.9.0
discord.py==2.4.0
frozenlist==1.5.0
h11==0.14.0
@ -27,7 +24,6 @@ python-dotenv==1.0.1
pytz==2024.2
rcon==2.4.9
sniffio==1.3.1
tomlkit==0.13.2
tortoise-orm==0.22.1
typing_extensions==4.12.2
yarl==1.18.3