2020-06-06 18:51:47 +02:00
|
|
|
import asyncio
|
2020-06-04 19:16:51 +02:00
|
|
|
import logging
|
2020-09-02 00:08:06 +02:00
|
|
|
from typing import List, Dict
|
|
|
|
from structured_config import (
|
|
|
|
ConfigFile,
|
|
|
|
Structure, IntField, StrField, BoolField
|
|
|
|
)
|
2020-06-03 01:07:43 +02:00
|
|
|
|
2020-06-04 19:16:51 +02:00
|
|
|
import discord
|
2020-06-03 01:07:43 +02:00
|
|
|
|
2020-06-04 19:16:51 +02:00
|
|
|
from tuxbot.core.data_manager import data_path
|
2020-06-03 01:07:43 +02:00
|
|
|
|
2020-06-06 02:00:16 +02:00
|
|
|
__all__ = ["Config"]
|
|
|
|
|
|
|
|
log = logging.getLogger("tuxbot.core.config")
|
2020-06-03 01:07:43 +02:00
|
|
|
|
|
|
|
|
2020-09-02 00:08:06 +02:00
|
|
|
class Server(Structure):
|
|
|
|
prefixes: List[str] = []
|
|
|
|
disabled_command: List[str] = []
|
|
|
|
locale: str = StrField("")
|
2020-06-04 19:16:51 +02:00
|
|
|
|
|
|
|
|
2020-09-02 00:08:06 +02:00
|
|
|
class User(Structure):
|
|
|
|
aliases: List[dict] = []
|
|
|
|
locale: str = StrField("")
|
2020-06-06 02:00:16 +02:00
|
|
|
|
2020-09-02 00:08:06 +02:00
|
|
|
|
|
|
|
class Config(Structure):
|
|
|
|
class Servers(Structure):
|
|
|
|
count: int = IntField(0)
|
|
|
|
all: List[Server] = []
|
|
|
|
|
|
|
|
class Users(Structure):
|
|
|
|
all: List[User] = []
|
|
|
|
|
|
|
|
class Core(Structure):
|
|
|
|
owners_id: List[int] = []
|
|
|
|
prefixes: List[str] = []
|
|
|
|
token: str = StrField("")
|
|
|
|
mentionable: bool = BoolField("")
|
|
|
|
locale: str = StrField("")
|
|
|
|
|
|
|
|
class Cogs(Structure):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
# =============================================================================
|
|
|
|
# Configuration of Tuxbot Application (not the bot)
|
|
|
|
# =============================================================================
|
|
|
|
|
|
|
|
class Instance(Structure):
|
|
|
|
path: str = StrField("")
|
|
|
|
active: bool = BoolField(False)
|
|
|
|
|
|
|
|
|
|
|
|
class AppConfig(Structure):
|
|
|
|
instances: Dict[str, Instance] = {}
|