-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
30 lines (24 loc) · 1.22 KB
/
bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import argparse
import json
from src.autoresponder import logger
from src.autoresponder import Configuration
from src.autoresponder import AutoResponder
from src.runtime_environment import CONFIG_PATH
# if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'):
# DEFAULT_CONFIG_LOCATION = f'{os.path.join(os.path.dirname(os.path.realpath(__file__)), "assets", "config.json")}'
# else:
# DEFAULT_CONFIG_LOCATION = f'{os.path.join(os.path.dirname(os.path.realpath(__file__)), "configs", "config.json")}'
_parser = argparse.ArgumentParser(description='Configuration details for the autoresponder')
_parser.add_argument('--config', '-C', help='Path to the configuration file (JSON format)', default=CONFIG_PATH)
_args = _parser.parse_args()
try:
with open(_args.config, 'r') as config_file:
logger.info(f'Loading configuration from {_args.config}')
config_data = config_file.read()
config = Configuration.from_json(config_data)
except FileNotFoundError:
logger.error(f'Configuration file not found at: {_args.config}')
except json.JSONDecodeError as e:
logger.error(f'Could not properly parse {_args.config}: {e}')
autoresponder = AutoResponder(config=config, logger=logger)
autoresponder.run()