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()