Move Matrix loop
This commit is contained in:
parent
f212a8d411
commit
5c156e92f1
|
@ -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
|
||||
|
|
1
mirrortea/messengers/__init__.py
Normal file
1
mirrortea/messengers/__init__.py
Normal file
|
@ -0,0 +1 @@
|
|||
from .matrix import Matrix
|
|
@ -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(
|
Reference in a new issue