matrix-bot/matrix_bot/config.py

33 lines
1.2 KiB
Python
Raw Normal View History

2020-08-04 12:03:56 +02:00
import os
2020-08-05 23:13:23 +02:00
import appdirs
2020-08-04 12:03:56 +02:00
2020-08-05 23:13:23 +02:00
class Config:
APP_NAME = 'matrix-bot'
# Default Homeserver URL
HOMESERVER_URL = 'https://matrix.gaja-group.com'
@classmethod
def init(cls, botname: str = 'default', loglevel: int = 40) -> None:
cls.LOGLEVEL = loglevel
cls.CONFIG_DIRECTORY = os.path.join(appdirs.user_config_dir(),
cls.APP_NAME, botname)
cls.DATA_DIRECTORY = os.path.join(appdirs.user_data_dir(),
cls.APP_NAME, botname)
if not os.path.exists(cls.CONFIG_DIRECTORY):
os.makedirs(cls.CONFIG_DIRECTORY)
if not os.path.exists(cls.DATA_DIRECTORY):
os.makedirs(cls.DATA_DIRECTORY)
cls.CONFIG_FILE = os.path.join(cls.CONFIG_DIRECTORY, 'config.json')
# directory to store persistent data for end-to-end encryption
cls.STORE_PATH = os.path.join(cls.DATA_DIRECTORY,
'store') # local directory
cls.NEXT_BATCH_PATH = os.path.join(cls.DATA_DIRECTORY,
'next_batch') # local directory
print(cls.CONFIG_DIRECTORY)
Config.init()