Move messengers to separate module #3

Merged
kotovalexarian merged 3 commits from move-messengers into master 2023-01-14 17:27:42 +00:00
3 changed files with 7 additions and 7 deletions
Showing only changes of commit 5c156e92f1 - Show all commits

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(