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
2023-01-10 07:45:01 +04:00

37 lines
812 B
Python

import asyncio
from matrix import MatrixLoop
from mirrortea.abstract_source_platform.telegram import Telegram
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 = Telegram(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()