def read_config() -> dict: try: with open('config.json', 'r', encoding='utf-8') as file: return json.loads(file.read()) except FileNotFoundError: write_config(DEFAULT_CONFIG) warnings.warn("ДБ не найдена, создал новую") return DEFAULT_CONFIG
def dispatch(payload: str) -> dict: try: return json.loads(payload) except json.decoder.JSONDecodeError: return dict()