2020-08-04 12:03:56 +02:00
|
|
|
import os
|
2020-08-06 17:16:43 +02:00
|
|
|
|
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'
|
2020-08-06 17:16:43 +02:00
|
|
|
CHAT_PREFIX = '!mbot'
|
2020-08-05 23:13:23 +02:00
|
|
|
|
|
|
|
@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
|
|
|
|
|
|
|
|
|
|
|
|
Config.init()
|