mirror of
https://code.lenaisten.de/Lenaisten/lenaverse-bot.git
synced 2024-11-22 15:03:01 +00:00
51 lines
1 KiB
Python
51 lines
1 KiB
Python
import os
|
|
import tomllib
|
|
from typing import Self
|
|
|
|
import discord
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class Post(BaseModel):
|
|
# users authorized to posts
|
|
users: list[int]
|
|
# where to put posts
|
|
channel: int
|
|
|
|
def get_channel(
|
|
self,
|
|
client: discord.Client,
|
|
) -> discord.Thread | discord.TextChannel:
|
|
"""
|
|
Zielkanal für Posts finden
|
|
"""
|
|
|
|
channel = client.get_channel(self.channel)
|
|
assert isinstance(channel, discord.Thread | discord.TextChannel)
|
|
|
|
return channel
|
|
|
|
|
|
class ClubInfo(BaseModel):
|
|
linktree: str = ""
|
|
join_file: str = "Aufnahmeantrag.pdf"
|
|
join_message: str = ""
|
|
|
|
|
|
class Config(BaseModel):
|
|
discord_token: str
|
|
post: Post
|
|
ev_info: ClubInfo
|
|
|
|
@classmethod
|
|
def get(cls) -> Self:
|
|
cfg_path = os.getenv(
|
|
key="CONFIG_PATH",
|
|
default="/usr/local/etc/lenaverse-bot/lenaverse-bot.toml",
|
|
)
|
|
|
|
with open(cfg_path, "rb") as cfg_file:
|
|
return cls.model_validate(tomllib.load(cfg_file))
|
|
|
|
|
|
CONFIG = Config.get()
|