Update config_provider

This commit is contained in:
2023-07-19 21:04:05 +03:00
parent ea2d715cae
commit 2a2d55946e
8 changed files with 37 additions and 22 deletions

View File

@@ -1,8 +1,17 @@
import secrets
class Config:
Auth: dict
Game: dict
Server: dict
WebAPI: dict
def __init__(self, auth=None, game=None, server=None, options=None, web=None):
self.Auth = auth or {"key": None, "private": True}
self.Game = game or {"map": "gridmap_v2", "players": 8, "max_cars": 1}
self.Server = server or {"name": "KuiToi-Server", "description": "Welcome to KuiToi Server!",
"server_ip": "0.0.0.0", "server_port": 30814}
self.Options = options or {"language": "en", "encoding": "utf8", "speed_limit": 0, "use_queue": False,
"debug": False}
self.WebAPI = web or {"enabled": False, "server_ip": "127.0.0.1", "server_port": 8433,
"secret_key": secrets.token_hex(16)}
def __repr__(self):
return "%s(Auth=%r, Game=%r, Server=%r)" % (self.__class__.__name__, self.Auth, self.Game, self.Server)
class config (Config): ...

View File

@@ -1,9 +1,8 @@
# -*- coding: utf-8 -*-
# Developed by KuiToi Dev
# File modules.config_provider.config_provider.py
# Written by: SantaSpeen
# Version 1.0
# Version 1.1
# Licence: FPA
# (c) kuitoi.su 2023
import os
@@ -11,13 +10,14 @@ import secrets
import yaml
class Config:
def __init__(self, auth=None, game=None, server=None, web=None):
def __init__(self, auth=None, game=None, server=None, options=None, web=None):
self.Auth = auth or {"key": None, "private": True}
self.Game = game or {"map": "gridmap_v2", "players": 8, "max_cars": 1}
self.Server = server or {"name": "KuiToi-Server", "description": "Welcome to KuiToi Server!", "language": "en",
"server_ip": "0.0.0.0", "server_port": 30814, "debug": False}
self.Server = server or {"name": "KuiToi-Server", "description": "Welcome to KuiToi Server!",
"server_ip": "0.0.0.0", "server_port": 30814}
self.Options = options or {"language": "en", "encoding": "utf-8", "speed_limit": 0, "use_queue": False,
"debug": False}
self.WebAPI = web or {"enabled": False, "server_ip": "127.0.0.1", "server_port": 8433,
"secret_key": secrets.token_hex(16)}

View File

@@ -99,7 +99,7 @@ class PluginsLoader:
plugin.print = print
file_path = os.path.join(self.plugins_dir, file)
plugin.__file__ = file_path
with open(f'{file_path}', 'r', encoding="utf-8") as f:
with open(f'{file_path}', 'r', encoding=config.enc) as f:
code = f.read()
exec(code, plugin.__dict__)

View File

@@ -68,7 +68,9 @@ class i18n:
class MultiLanguage:
def __init__(self, language: str = None, files_dir="modules/i18n/files/", encoding="utf-8"):
def __init__(self, language: str = None, files_dir="modules/i18n/files/", encoding=None):
if encoding is None:
encoding = config.enc
if language is None:
language = "en"
self.__data = {}