diff --git a/main.py b/main.py index 4476083..6bcc887 100755 --- a/main.py +++ b/main.py @@ -104,7 +104,7 @@ async def main(): logger.info(f'Log level is {l}') del l - if len(config_data['command'].keys()) == 1 and config_data['command'][list(config_data['command'].keys())[0]]['mode'] == 'local': + if len(config_data['command'].keys()) == 1 and config_data['command'][list(config_data['command'].keys())[0]].get('mode') == 'local': # Need the logger to be initalized for this logger.info('Running in local mode, OpenAI API key not required.') openai.api_key = 'abc123' @@ -173,7 +173,7 @@ async def main(): logger.error(f'Ratelimited, sleeping {wait}s...') time.sleep(wait) except: - logger.error('Could not parse M_LIMIT_EXCEEDED') + logger.error(f'Could not parse M_LIMIT_EXCEEDED: {login_response}') else: logger.error(f'Failed to login, retrying: {login_response}') time.sleep(5) diff --git a/matrix_gpt/matrix.py b/matrix_gpt/matrix.py index e67b4a5..533c799 100644 --- a/matrix_gpt/matrix.py +++ b/matrix_gpt/matrix.py @@ -9,6 +9,7 @@ from nio import LoginResponse logger = logging.getLogger('MatrixGPT') + class MatrixNioGPTHelper: """ A simple wrapper class for common matrix-nio actions. @@ -30,7 +31,7 @@ class MatrixNioGPTHelper: Path(self.store_path).mkdir(parents=True, exist_ok=True) self.device_name = device_name - self.client = AsyncClient(self.homeserver, self.user_id, config=self.client_config, store_path=self.store_path, device_id=device_id) + self.client = AsyncClient(homeserver=self.homeserver, user=self.user_id, config=self.client_config, store_path=self.store_path, device_id=device_id) async def login(self) -> tuple[bool, LoginError] | tuple[bool, LoginResponse | None]: try: