1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
from pathlib import Path
from datetime import timedelta
from ipaddress import IPv4Address
from .utils.yaml import load_yml
CONFIG_PATH = Path(".") / "config.yml"
config = load_yml(CONFIG_PATH)
class BotSelfConfig:
config: dict = config["BotSelfConfig"]
host: IPv4Address = IPv4Address(config.get("host", "127.0.0.1"))
port: int = int(config.get("port", 8080))
debug: bool = bool(config.get("debug", False))
superusers: set = set(config.get("superusers", ["1234567890"]))
nickname: set = set(config.get("nickname", ["ATRI", "Atri", "atri", "亚托莉", "アトリ"]))
command_start: set = set(config.get("command_start", [""]))
command_sep: set = set(config.get("command_sep", ["."]))
session_expire_timeout: timedelta = timedelta(
seconds=config.get("session_expire_timeout", 60)
)
class NetworkPost:
config: dict = config["NetworkPost"]
host: str = config.get("host", "127.0.0.1")
port: int = int(config.get("port", 8081))
class AdminPage:
config: dict = config["AdminPage"]
host: str = config.get("host", "127.0.0.1")
port: int = int(config.get("port", 8082))
class NsfwCheck:
config: dict = config["NsfwCheck"]
enabled: bool = bool(config.get("enabled", False))
passing_rate: int = int(config.get("passing_rate", 85))
host: str = config.get("host", "127.0.0.1")
port: int = int(config.get("port", 5000))
class SauceNAO:
config: dict = config["SauceNAO"]
key: str = config.get("key", "")
class Setu:
config: dict = config["Setu"]
key: str = config.get("key", "")
RUNTIME_CONFIG = {
"host": BotSelfConfig.host,
"port": BotSelfConfig.port,
"debug": BotSelfConfig.debug,
"superusers": BotSelfConfig.superusers,
"nickname": BotSelfConfig.nickname,
"command_start": BotSelfConfig.command_start,
"command_sep": BotSelfConfig.command_sep,
"session_expire_timeout": BotSelfConfig.session_expire_timeout,
}
|