33 lines
1.2 KiB
Python
33 lines
1.2 KiB
Python
import os
|
|
import appdirs
|
|
|
|
|
|
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()
|