Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
50a3c5fa6b | ||
|
|
39875585ef | ||
|
|
7796ead644 | ||
|
|
531d2f3a0e | ||
|
|
8595a12f7f | ||
|
|
f76171ac84 | ||
|
|
63e77958fb | ||
|
|
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"]
|
||||
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
main file for highscores bot
|
||||
main file for agon
|
||||
"""
|
||||
|
||||
import logging
|
||||
@@ -6,6 +6,7 @@ from nextcord.ext import commands
|
||||
|
||||
from .create import CreateCog
|
||||
from .delete import DeleteCog
|
||||
from .help import HelpCog
|
||||
from .refresh import RefreshCog
|
||||
from .set import SetCog
|
||||
from .update import UpdateCog
|
||||
@@ -19,6 +20,7 @@ def setup(bot: commands.Bot):
|
||||
"""
|
||||
bot.add_cog(CreateCog(bot))
|
||||
bot.add_cog(DeleteCog())
|
||||
bot.add_cog(HelpCog())
|
||||
bot.add_cog(RefreshCog(bot))
|
||||
bot.add_cog(SetCog())
|
||||
bot.add_cog(UpdateCog(bot))
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
"""
|
||||
Commands for helping a user.
|
||||
"""
|
||||
|
||||
import nextcord
|
||||
from nextcord.ext import commands
|
||||
|
||||
|
||||
class HelpCog(commands.Cog, name="Help commands."):
|
||||
"""
|
||||
Class holds commands for getting help.
|
||||
"""
|
||||
|
||||
def __init__(self) -> None:
|
||||
"""
|
||||
Default constructor for HelpCog class. Does nothing.
|
||||
"""
|
||||
|
||||
@nextcord.slash_command()
|
||||
async def help(self, interaction: nextcord.Interaction):
|
||||
"""
|
||||
Parent slash command for help. Never called.
|
||||
"""
|
||||
|
||||
@help.subcommand(description="Describes how to get started with Agon.")
|
||||
async def setup(self, interaction: nextcord.Interaction):
|
||||
"""
|
||||
Sends a message describing how to get started with Agon.
|
||||
|
||||
Args:
|
||||
interaction (nextcord.Interaction): Interaction that invoked the command.
|
||||
"""
|
||||
|
||||
# I hate this but don't want indents in the string.
|
||||
# pylint: disable=line-too-long
|
||||
help_str: str = """Welcome to Agon! Three simple steps are needed to get started.
|
||||
1.) Set a channel to recieve submission verifications with "/set verify_channel."
|
||||
This channel is used to allow moderators to check if a submission is real/valid.
|
||||
|
||||
2.) Set a channel for submissions to be posted in with "/set submission_channel."
|
||||
This channel will be where all user submission messages are sent.
|
||||
|
||||
3.) Set up your highscore tables! Use "/create group" to first create a group message in the channel you would like and then use "/create category" to create a category in that group message!"""
|
||||
# pylint: enable=line-too-long
|
||||
print(help_str)
|
||||
|
||||
await interaction.response.send_message(content=help_str)
|
||||
@@ -48,7 +48,7 @@ class SetCog(commands.Cog, name="Set command."):
|
||||
Command function to register a CategoryGroup's output channel.
|
||||
|
||||
Args:
|
||||
interaction (nextcord.Interaction): Interaction that invoked the command
|
||||
interaction (nextcord.Interaction): Interaction that invoked the command.
|
||||
group_id (str): String representation of Group id to register channel to. Is SlashOption.
|
||||
channel (nextcord.abc.GuildChannel, optional): Channel to register
|
||||
Is a SlashOption. Limited to text channels, Defaults to None.
|
||||
|
||||
@@ -19,22 +19,13 @@ class GuildListener(commands.Cog, name="Guild Listener"):
|
||||
|
||||
@commands.Cog.listener()
|
||||
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)
|
||||
|
||||
with Session(engine) as session:
|
||||
session.add(new_guild)
|
||||
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.
|
||||
|
||||
@@ -11,7 +11,7 @@ from sqlalchemy.orm import Session
|
||||
|
||||
# pylint: disable=import-error
|
||||
from classes.submission import SubmissionState
|
||||
from highscores import submission_objects
|
||||
from agon import submission_objects
|
||||
from utilities.sql_data_classes import Category, Guild, engine
|
||||
|
||||
|
||||
@@ -45,7 +45,6 @@ class SubmissionListener(commands.Cog, name="Message Listener"):
|
||||
if message.channel.id == submission_channel_id:
|
||||
state = submission.submission_state
|
||||
if state == SubmissionState.SCORE and message.content:
|
||||
|
||||
stmt = select(Category.IsTimeRecord).where(Category.CategoryId == submission.category_id)
|
||||
|
||||
# check with regex if score matches correctly
|
||||
|
||||
@@ -9,7 +9,7 @@ from sqlalchemy.orm import Session, aliased
|
||||
|
||||
# pylint: disable=import-error
|
||||
from classes.submission import Submission, SubmissionState
|
||||
from highscores import submission_objects
|
||||
from agon import submission_objects
|
||||
from utilities.sql_data_classes import Category, CategoryGroup, Guild, engine
|
||||
|
||||
from .verification_view import VerificationView
|
||||
|
||||
+14
-1
@@ -2,7 +2,7 @@ version: "3"
|
||||
services:
|
||||
sqldb:
|
||||
restart: unless-stopped
|
||||
image: "highscores_db"
|
||||
image: mysql:latest
|
||||
container_name: "Highscores-DataBase"
|
||||
volumes:
|
||||
- highscores_data:/var/lib/mysql
|
||||
@@ -12,5 +12,18 @@ services:
|
||||
- MYSQL_ROOT_PASSWORD=${SQL_PASS}
|
||||
- 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:
|
||||
highscores_data:
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
FROM mysql:latest
|
||||
|
||||
COPY highscores_database.sql /docker-entrypoint-initdb.d/
|
||||
+3
-2
@@ -1,5 +1,6 @@
|
||||
nextcord>=2.3.2
|
||||
python-dotenv>=0.20.0
|
||||
pandas>=1.5.2
|
||||
sqlalchemy>=1.4.44
|
||||
mysqlclient>-2.1.1
|
||||
sqlalchemy<2.0
|
||||
pymysql>=1.0.2
|
||||
cryptography>=2.8
|
||||
@@ -8,7 +8,7 @@ from sqlalchemy.ext.automap import automap_base
|
||||
from utilities import config
|
||||
|
||||
# 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)
|
||||
Base = automap_base()
|
||||
Base.prepare(autoload_with=engine)
|
||||
|
||||
Reference in New Issue
Block a user