2024-07-10 23:16:19 +03:00

22 lines
619 B
Python

import json
from typing import Optional
class Config():
def __init__(self, filename: str) -> None:
self.__filename = filename
self.__config = {}
self.__read()
def get_on_message_for_chat_id(self, chat_id: int) -> Optional[dict]:
chat_id_str = str(chat_id)
if 'onMessage' in self.__config:
on_message = self.__config['onMessage']
if chat_id_str in on_message:
return on_message[chat_id_str]
return None
def __read(self) -> None:
with open(self.__filename, 'r') as f:
self.__config = json.load(f)