2ea41e1187
Co-authored-by: Alex Kotov <kotovalexarian@gmail.com> Reviewed-on: #3
36 lines
796 B
Python
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()
|