From 4e3266588228fb13abeaddbb5d27baf45d4d882c Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Sun, 8 Jan 2023 01:42:02 +0400 Subject: [PATCH] Create Matrix and Telegram clients --- mirrortea | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/mirrortea b/mirrortea index 92b7fff..81c4c7a 100755 --- a/mirrortea +++ b/mirrortea @@ -5,8 +5,23 @@ import asyncio import aiogram as telegram import nio as matrix +MATRIX_HOMESERVER_URL = 'https://matrix.org' +MATRIX_FULL_USER_ID = '@fckidiots:matrix.org' +MATRIX_PASSWORD = '...' +TELEGRAM_BOT_TOKEN = '5890667880:...' + async def main(): - await asyncio.gather(matrix_loop(), telegram_loop()) + try: + matrix_client = \ + matrix.AsyncClient(MATRIX_HOMESERVER_URL, MATRIX_FULL_USER_ID) + await matrix_client.login(MATRIX_PASSWORD) + + telegram_client = telegram.Bot(token=TELEGRAM_BOT_TOKEN) + + await asyncio.gather(matrix_loop(), telegram_loop()) + finally: + if matrix_client: + await matrix_client.close() async def matrix_loop(): print(123)