mirror of
https://github.com/Noettore/lagomareGateKeeperBot.git
synced 2025-10-14 19:16:40 +02:00
48 lines
1.4 KiB
Python
48 lines
1.4 KiB
Python
import json
|
|
from telegram import BotCommand
|
|
|
|
class BotConfig:
|
|
def __init__(self, bot_username: str, json_path: str = "./data/config.json"):
|
|
self._json_path = json_path
|
|
self._bot_username = bot_username
|
|
self._token: str = ""
|
|
self._name: str = ""
|
|
self._description: str = ""
|
|
self._short_description: str = ""
|
|
self._commands: list[BotCommand] = []
|
|
self._load_config()
|
|
|
|
def _load_config(self):
|
|
try:
|
|
with open(self._json_path, "r") as f:
|
|
config = json.load(f).get(self._bot_username, {})
|
|
self._token = config.get("token", "")
|
|
self._name = config.get("name", "")
|
|
self._description = config.get("description", "")
|
|
self._short_description = config.get("short_description", "")
|
|
self._commands = [
|
|
BotCommand(command, description)
|
|
for command, description in config.get("commands", {}).items()
|
|
]
|
|
except Exception:
|
|
pass
|
|
|
|
@property
|
|
def token(self) -> str:
|
|
return self._token
|
|
|
|
@property
|
|
def name(self) -> str:
|
|
return self._name
|
|
|
|
@property
|
|
def description(self) -> str:
|
|
return self._description
|
|
|
|
@property
|
|
def short_description(self) -> str:
|
|
return self._short_description
|
|
|
|
@property
|
|
def commands(self) -> list[BotCommand]:
|
|
return self._commands |