From 313221a2cfd6e50d741915b8adb458d77e78bde8 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Sun, 8 Jan 2023 01:05:21 +0400 Subject: [PATCH 1/3] Improve code --- mirrortea | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mirrortea b/mirrortea index 9c2fe2d..3ba27e6 100755 --- a/mirrortea +++ b/mirrortea @@ -3,8 +3,11 @@ import asyncio from nio import AsyncClient -async def main(): +def main(): + asyncio.get_event_loop().run_until_complete(loop()) + +async def loop(): print(123) if __name__ == '__main__': - asyncio.get_event_loop().run_until_complete(main()) + main() From 51754e363a240326cf4311ee578a3f2a4ce8759d Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Sun, 8 Jan 2023 01:13:27 +0400 Subject: [PATCH 2/3] Use aiogram --- mirrortea | 4 +++- requirements.txt | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/mirrortea b/mirrortea index 3ba27e6..366ed1b 100755 --- a/mirrortea +++ b/mirrortea @@ -1,7 +1,9 @@ #!/usr/bin/env python3 import asyncio -from nio import AsyncClient + +import aiogram as telegram +import nio as matrix def main(): asyncio.get_event_loop().run_until_complete(loop()) diff --git a/requirements.txt b/requirements.txt index d40c1e3..3f3c37f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ +aiogram==2.24 matrix-nio==0.20.1 From 9d3ff4f1a206fec63ca8657b84d84a10f7b7b786 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Sun, 8 Jan 2023 01:29:12 +0400 Subject: [PATCH 3/3] Use two loops --- mirrortea | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mirrortea b/mirrortea index 366ed1b..92b7fff 100755 --- a/mirrortea +++ b/mirrortea @@ -5,11 +5,14 @@ import asyncio import aiogram as telegram import nio as matrix -def main(): - asyncio.get_event_loop().run_until_complete(loop()) +async def main(): + await asyncio.gather(matrix_loop(), telegram_loop()) -async def loop(): +async def matrix_loop(): print(123) +async def telegram_loop(): + print(456) + if __name__ == '__main__': - main() + asyncio.run(main())