mirror of
https://github.com/Xevion/contest-assistant.git
synced 2025-12-12 20:11:17 -06:00
basic bot setup
This commit is contained in:
0
contest/__init__.py
Normal file
0
contest/__init__.py
Normal file
15
contest/client.py
Normal file
15
contest/client.py
Normal file
@@ -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
|
||||||
1
contest/constants.py
Normal file
1
contest/constants.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
DATABASE = 'database.db'
|
||||||
27
contest/db.py
Normal file
27
contest/db.py
Normal file
@@ -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
|
||||||
7
main.py
Normal file
7
main.py
Normal file
@@ -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())
|
||||||
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
discord~=1.0.1
|
||||||
Reference in New Issue
Block a user