From b7d4a810e9f79fcd44a36ce65fc846e51b522867 Mon Sep 17 00:00:00 2001 From: Xevion Date: Sun, 7 Feb 2021 05:37:02 -0600 Subject: [PATCH] basic bot setup --- contest/__init__.py | 0 contest/client.py | 15 +++++++++++++++ contest/constants.py | 1 + contest/db.py | 27 +++++++++++++++++++++++++++ main.py | 7 +++++++ requirements.txt | 1 + 6 files changed, 51 insertions(+) create mode 100644 contest/__init__.py create mode 100644 contest/client.py create mode 100644 contest/constants.py create mode 100644 contest/db.py create mode 100644 main.py create mode 100644 requirements.txt diff --git a/contest/__init__.py b/contest/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/contest/client.py b/contest/client.py new file mode 100644 index 0000000..f220e0d --- /dev/null +++ b/contest/client.py @@ -0,0 +1,15 @@ +import discord as discord + + +class ContestClient(discord.Client): + def __init__(self, **options) -> None: + super().__init__(**options) + + async def on_message(self) -> None: + pass + + async def on_raw_reaction_add(self, payload) -> None: + pass + + async def on_raw_reaction_remove(self, payload) -> None: + pass diff --git a/contest/constants.py b/contest/constants.py new file mode 100644 index 0000000..c17ca14 --- /dev/null +++ b/contest/constants.py @@ -0,0 +1 @@ +DATABASE = 'database.db' diff --git a/contest/db.py b/contest/db.py new file mode 100644 index 0000000..f33f01b --- /dev/null +++ b/contest/db.py @@ -0,0 +1,27 @@ +import sqlite3 + +import aiosqlite + +from contest import constants + + +class ContestDatabase(object): + """ + A handler class for a SQLite3 database used by the bot with Async support. + """ + def __init__(self, conn: aiosqlite.Connection) -> None: + self.db = conn + + @classmethod + async def create(cls) -> 'ContestDatabase': + """ + Constructs a ContestDatabase object connecting to the default database location with the proper connection settings. + :return: A fully realized ContestDatabase object. + """ + conn = await aiosqlite.connect(constants.DATABASE, detect_types=sqlite3.PARSE_DELCTYPES) + db = ContestDatabase(conn) + await conn.commit() + return db + + async def is_setup(self): + pass diff --git a/main.py b/main.py new file mode 100644 index 0000000..8148e55 --- /dev/null +++ b/main.py @@ -0,0 +1,7 @@ +from contest import client + +if __name__ == "__main__": + bot = client.ContestClient() + + with open('token.dat', 'r') as file: + bot.run(file.read()) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..2d551de --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +discord~=1.0.1