Implement a history-based matching algorythm

The bot will attempt to keep producing groups with entirely unique matches based on the full history of matches until it can't. It'll then step forward and ignore a week of history and try again, ignoring more history until no history is left
This commit is contained in:
Marc Di Luzio 2024-08-10 15:12:14 +01:00
parent ed2375386b
commit 874a24dd1d
8 changed files with 388 additions and 104 deletions

View file

@ -2,11 +2,22 @@
from schema import Schema, And, Use
import files
FILE = "config.json"
_FILE = "config.json"
_SCHEMA = Schema(
{
# Discord bot token
"token": And(Use(str)),
# ids of owners authorised to use owner-only commands
"owners": And(Use(list[int])),
}
)
class Config():
def __init__(self, data: dict):
"""Initialise and validate the config"""
_SCHEMA.validate(data)
self.__dict__ = data
@property
@ -16,23 +27,12 @@ class Config():
@property
def owners(self) -> list[int]:
return self.__dict__["owners"]
def reload(self) -> None:
"""Reload the config back into the dict"""
self.__dict__ = load().__dict__
def load() -> Config:
"""Load the config and validate it"""
config = files.load(FILE)
Schema(
{
# Discord bot token
"token": And(Use(str)),
# ids of owners authorised to use owner-only commands
"owners": And(Use(list[int])),
}
).validate(config)
return Config(config)
"""Load the config"""
return Config(files.load(_FILE))