-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutilities.py
More file actions
53 lines (42 loc) · 1.88 KB
/
utilities.py
File metadata and controls
53 lines (42 loc) · 1.88 KB
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
import json
import platform
from dataclasses import dataclass
from os import getenv
from typing import List, Dict, Any, Optional, Final
from discord.app_commands import Choice
from dotenv import load_dotenv
# Load the local environment
load_dotenv()
# Dataclasses
@dataclass(frozen=True)
class Response:
message: Optional[str] = None
is_number: Optional[bool] = False
is_valid_number: Optional[bool] = False
zero_division: Optional[bool] = False
# Secrets
TOKEN: Final[Optional[str]] = getenv('TOKEN')
MYSQL_USER: Final[Optional[str]] = getenv('MYSQL_USER')
MYSQL_PASSWORD: Final[Optional[str]] = getenv('MYSQL_PASSWORD')
# Checking IP
IS_NAS: Final[bool] = platform.system() == 'Linux'
HOST_IP: Final[Optional[str]] = '172.17.0.1' if IS_NAS else getenv('SYNOLOGY_IP')
# Constants
with open('config/constants.json', 'r', encoding='utf-8') as file:
config: Dict[str, Any] = json.load(file)
LOGGING_FORMAT: Final[str] = config.get('logging_format')
DATABASE: Final[str] = config.get('database')
LEADERBOARD_COUNT: Final[int] = config.get('leaderboard_count')
MODERATORS: Final[List[int]] = config.get('moderators')
SUPPORTED_CHARACTERS: Final[str] = config.get('supported_characters')
REPLACEMENT_SYMBOLS: Final[Dict[str, float]] = config.get('replacement_symbols')
LEADERBOARD_ORDER_CHOICES: Final[List[Choice]] = [Choice(name=name, value=value) for value, name in
config.get('leaderboard_order_choices').items()]
# Emojis
CORRECT_EMOJI: Final[str] = config.get('emojis').get('correct')
INCORRECT_EMOJI: Final[str] = config.get('emojis').get('incorrect')
FIRE_EMOJI: Final[str] = config.get('emojis').get('fire')
# Information
DEVELOPER_ID: Final[int] = config.get('developer_id')
with open('config/info_template.md', 'r', encoding='utf-8') as file:
INFORMATION: Final[str] = file.read().format(leaderboard_count=LEADERBOARD_COUNT, developer_id=DEVELOPER_ID)