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

37 lines
797 B
Python
Raw Normal View History

2023-01-07 20:11:46 +00:00
import asyncio
from matrix import MatrixLoop
2023-01-10 12:33:52 +00:00
from abstract_source_platform.telegram import Telegram
2023-01-10 00:48:55 +00:00
from config_dataclass import Config
2023-01-10 00:48:55 +00:00
CONFIG_FILE_NAME = "config.yaml"
2023-01-08 22:13:27 +00:00
2023-01-08 19:28:13 +00:00
def main():
2023-01-10 00:48:55 +00:00
config = Config.from_yaml_config(CONFIG_FILE_NAME)
2023-01-08 19:31:11 +00:00
asyncio.run(Application(config).run())
2023-01-08 19:28:13 +00:00
class Application:
2023-01-08 19:31:11 +00:00
def __init__(self, config):
self.config = config
self.matrix_loop = MatrixLoop(self)
2023-01-10 00:48:55 +00:00
self.telegram = Telegram(self)
2023-01-08 19:28:13 +00:00
async def run(self):
try:
await self.matrix_loop.prepare()
await asyncio.gather(
self.matrix_loop.run(),
2023-01-10 13:16:50 +00:00
self.telegram.run(),
2023-01-08 19:28:13 +00:00
)
finally:
if self.matrix_loop:
await self.matrix_loop.finish()
2023-01-08 18:43:37 +00:00
2023-01-08 13:54:22 +00:00
if __name__ == "__main__":
2023-01-08 19:28:13 +00:00
main()