Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0bae0ea5ff | ||
|
|
c67e9ae617 | ||
|
|
7e23ac14ff | ||
|
|
a0a7e37921 |
+21
@@ -0,0 +1,21 @@
|
|||||||
|
FROM python:3.8.10-slim
|
||||||
|
|
||||||
|
# install dependencies for mysqlclient
|
||||||
|
# RUN apt-get update && apt-get -y upgrade && apt-get -y install python3-dev default-libmysqlclient-dev build-essential
|
||||||
|
|
||||||
|
RUN pip install --upgrade pip
|
||||||
|
|
||||||
|
WORKDIR /home
|
||||||
|
|
||||||
|
COPY classes classes/
|
||||||
|
COPY cogs cogs/
|
||||||
|
COPY utilities utilities/
|
||||||
|
COPY highscores.py highscores.py
|
||||||
|
COPY requirements.txt requirements.txt
|
||||||
|
|
||||||
|
RUN pip install -r requirements.txt
|
||||||
|
|
||||||
|
# remove build deps that aren't needed to run
|
||||||
|
# RUN apt-get -y remove python3-dev build-essential && apt-get -y autoremove
|
||||||
|
|
||||||
|
CMD ["python3", "./highscores.py"]
|
||||||
@@ -19,22 +19,13 @@ class GuildListener(commands.Cog, name="Guild Listener"):
|
|||||||
|
|
||||||
@commands.Cog.listener()
|
@commands.Cog.listener()
|
||||||
async def on_guild_join(self, guild: nextcord.Guild):
|
async def on_guild_join(self, guild: nextcord.Guild):
|
||||||
"""Listener for Guild Join. Creates skeleton for new guild joined and saves it."""
|
"""Listener for Guild Join. Adds guild to database."""
|
||||||
|
|
||||||
new_guild = Guild(GuildId=guild.id)
|
new_guild = Guild(GuildId=guild.id)
|
||||||
|
|
||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
session.add(new_guild)
|
session.add(new_guild)
|
||||||
session.commit()
|
session.commit()
|
||||||
# This add config will be removed eventually. Config adding will have to be controlled by commands.
|
|
||||||
add_preset_configuration(guild.id, "runescape")
|
|
||||||
|
|
||||||
welcome_message: str = "Hello, I keep track of Highscores for you!"
|
|
||||||
welcome_message += " Currently only supporting RuneScape boss highscores,"
|
|
||||||
welcome_message += " but will be more dynamic support in future."
|
|
||||||
welcome_message += ' For assistance on getting started, use "?register help".'
|
|
||||||
|
|
||||||
await guild.system_channel.send(content=welcome_message)
|
|
||||||
|
|
||||||
|
|
||||||
# This function will be called when this extension is loaded.
|
# This function will be called when this extension is loaded.
|
||||||
|
|||||||
+14
-3
@@ -2,15 +2,26 @@ version: "3"
|
|||||||
services:
|
services:
|
||||||
sqldb:
|
sqldb:
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
image: "highscores_db"
|
image: mysql:latest
|
||||||
container_name: "Highscores-DataBase"
|
container_name: "Highscores-DataBase"
|
||||||
volumes:
|
volumes:
|
||||||
- highscores_data:/var/lib/mysql
|
- highscores_data:/var/lib/mysql
|
||||||
ports:
|
|
||||||
- 3306:3306
|
|
||||||
environment:
|
environment:
|
||||||
- MYSQL_ROOT_PASSWORD=${SQL_PASS}
|
- MYSQL_ROOT_PASSWORD=${SQL_PASS}
|
||||||
- MYSQL_ROOT_USERNAME=${SQL_USER}
|
- MYSQL_ROOT_USERNAME=${SQL_USER}
|
||||||
|
|
||||||
|
bot:
|
||||||
|
restart: unless-stopped
|
||||||
|
build: .
|
||||||
|
container_name: "Highscores-Bot"
|
||||||
|
depends_on:
|
||||||
|
- sqldb
|
||||||
|
environment:
|
||||||
|
- DISCORD_TOKEN=${DISCORD_TOKEN}
|
||||||
|
- SQL_DB=${SQL_DB}
|
||||||
|
- SQL_HOST=${SQL_HOST}
|
||||||
|
- SQL_PASS=${SQL_PASS}
|
||||||
|
- SQL_USER=${SQL_USER}
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
highscores_data:
|
highscores_data:
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
FROM mysql:latest
|
|
||||||
|
|
||||||
COPY highscores_database.sql /docker-entrypoint-initdb.d/
|
|
||||||
+2
-1
@@ -2,4 +2,5 @@ nextcord>=2.3.2
|
|||||||
python-dotenv>=0.20.0
|
python-dotenv>=0.20.0
|
||||||
pandas>=1.5.2
|
pandas>=1.5.2
|
||||||
sqlalchemy>=1.4.44
|
sqlalchemy>=1.4.44
|
||||||
mysqlclient>-2.1.1
|
pymysql>=1.0.2
|
||||||
|
cryptography>=2.8
|
||||||
@@ -8,7 +8,7 @@ from sqlalchemy.ext.automap import automap_base
|
|||||||
from utilities import config
|
from utilities import config
|
||||||
|
|
||||||
# connect with sql alchemy and autoload schema
|
# connect with sql alchemy and autoload schema
|
||||||
url = f"mysql://{config.SQL_USER}:{config.SQL_PASS}@{config.SQL_HOST}/{config.SQL_DB}"
|
url = f"mysql+pymysql://{config.SQL_USER}:{config.SQL_PASS}@{config.SQL_HOST}/{config.SQL_DB}"
|
||||||
engine = create_engine(url)
|
engine = create_engine(url)
|
||||||
Base = automap_base()
|
Base = automap_base()
|
||||||
Base.prepare(autoload_with=engine)
|
Base.prepare(autoload_with=engine)
|
||||||
|
|||||||
Reference in New Issue
Block a user