Move Matrix loop

This commit is contained in:
Alex Kotov 2023-01-14 21:17:31 +04:00
parent f212a8d411
commit 5c156e92f1
No known key found for this signature in database
GPG Key ID: 553C0EBBEB5D5F08
3 changed files with 7 additions and 7 deletions

View File

@ -1,6 +1,6 @@
import asyncio
from matrix import MatrixLoop
from messengers import Matrix as MatrixLoop
from abstract_source_platform.telegram import Telegram
from config_dataclass import Config

View File

@ -0,0 +1 @@
from .matrix import Matrix

View File

@ -1,15 +1,14 @@
import nio as matrix
import nio
import sys
class MatrixLoop:
class Matrix:
def __init__(self, app):
self.app = app
self.client = matrix.AsyncClient(
self.client = nio.AsyncClient(
app.config.matrix_homeserver_url,
app.config.matrix_full_bot_id,
)
self.client.add_event_callback(self.on_message, matrix.RoomMessage)
self.client.add_event_callback(self.on_message, nio.RoomMessage)
async def prepare(self):
await self.client.login(self.app.config.matrix_bot_password)
@ -24,7 +23,7 @@ class MatrixLoop:
print(room, event, file=sys.stderr)
def upgrade_room(self, room, telegram_nickname):
event_dict = matrix.event_builders.event_builder.EventBuilder(
event_dict = nio.event_builders.event_builder.EventBuilder(
name=telegram_nickname
).as_dict()
client.room_send(