This repository has been archived on 2023-01-19. You can view files and clone it, but cannot push or open issues or pull requests.
MirrorTea/mirrortea/__main__.py
kotovalexarian 2ea41e1187 Move messengers to separate module (#3)
Co-authored-by: Alex Kotov <kotovalexarian@gmail.com>
Reviewed-on: #3
2023-01-14 20:27:41 +03:00

36 lines
796 B
Python

import asyncio
from messengers import Matrix as MatrixLoop, Telegram as TelegramLoop
from config_dataclass import Config
CONFIG_FILE_NAME = "config.yaml"
def main():
config = Config.from_yaml_config(CONFIG_FILE_NAME)
asyncio.run(Application(config).run())
class Application:
def __init__(self, config):
self.config = config
self.matrix_loop = MatrixLoop(self)
self.telegram_loop = TelegramLoop(self)
async def run(self):
try:
await self.matrix_loop.prepare()
await asyncio.gather(
self.matrix_loop.run(),
self.telegram_loop.run(),
)
finally:
if self.matrix_loop:
await self.matrix_loop.finish()
if __name__ == "__main__":
main()