From 9c97b12c196f15193563698b4152f886aff2caa2 Mon Sep 17 00:00:00 2001 From: def Date: Tue, 10 Jan 2023 17:16:50 +0400 Subject: [PATCH] fix: env config --- .env.example | 4 ++-- config.yaml | 5 +++++ mirrortea/__main__.py | 2 +- mirrortea/config_dataclass.py | 8 +++++--- mirrortea/matrix.py | 4 ++-- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/.env.example b/.env.example index 2c7e888..c3a41f8 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,4 @@ -MATRIX_BOT_ID=@fckidiots:matrix.org MATRIX_HOMESERVER_URL=https://matrix.org -MATRIX_PASSWORD=... +MATRIX_FULL_BOT_ID=@fckidiots:matrix.org +MATRIX_BOT_PASSWORD=... TELEGRAM_BOT_TOKEN=5890667880:... diff --git a/config.yaml b/config.yaml index a5c0786..6206344 100644 --- a/config.yaml +++ b/config.yaml @@ -1,2 +1,7 @@ matrix_owner_id: "@dettlaff:inex.rocks" db_path: "data/database.sqlite3" + +matrix_homeserver_url: "{{ MATRIX_HOMESERVER_URL }}" +matrix_full_bot_id: "{{ MATRIX_FULL_BOT_ID }}" +matrix_bot_password: "{{ MATRIX_BOT_PASSWORD }}" +telegram_bot_token: "{{ TELEGRAM_BOT_TOKEN }}" diff --git a/mirrortea/__main__.py b/mirrortea/__main__.py index 37213e1..2dc2aba 100644 --- a/mirrortea/__main__.py +++ b/mirrortea/__main__.py @@ -25,7 +25,7 @@ class Application: await self.matrix_loop.prepare() await asyncio.gather( self.matrix_loop.run(), - self.telegram_loop.run(), + self.telegram.run(), ) finally: if self.matrix_loop: diff --git a/mirrortea/config_dataclass.py b/mirrortea/config_dataclass.py index 8d87eda..a636c4e 100644 --- a/mirrortea/config_dataclass.py +++ b/mirrortea/config_dataclass.py @@ -16,12 +16,14 @@ def render_env_template(raw_config: str) -> dict: class Config: db_path: Path - matrix_bot_id: str matrix_homeserver_url: str - matrix_password: str - matrix_owner_id: str + matrix_full_bot_id: str + matrix_bot_password: str + telegram_bot_token: str + matrix_owner_id: str + @classmethod def from_dict(config_class, dict): return config_class(**dict) diff --git a/mirrortea/matrix.py b/mirrortea/matrix.py index 9a2d18f..061b4a3 100644 --- a/mirrortea/matrix.py +++ b/mirrortea/matrix.py @@ -7,12 +7,12 @@ class MatrixLoop: self.app = app self.client = matrix.AsyncClient( app.config.matrix_homeserver_url, - app.config.matrix_bot_id, + app.config.matrix_full_bot_id, ) self.client.add_event_callback(self.on_message, matrix.RoomMessage) async def prepare(self): - await self.client.login(self.app.config.matrix_password) + await self.client.login(self.app.config.matrix_bot_password) async def finish(self): await self.client.close()