From 49b356f510c05cd39cee0a65bf0d8056a088412b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?poljar=20=28Damir=20Jeli=C4=87=29?= Date: Mon, 12 Feb 2018 14:17:36 +0100 Subject: [PATCH] Remove MatrixMessage class. --- main.py | 1 - matrix/api.py | 92 ---------------------------------------------- matrix/commands.py | 1 - 3 files changed, 94 deletions(-) diff --git a/main.py b/main.py index 51bfa54..bf3ae4b 100644 --- a/main.py +++ b/main.py @@ -32,7 +32,6 @@ from matrix.colors import Formatted from matrix.utf import utf8_decode from matrix.http import HttpResponse from matrix.api import ( - MatrixMessage, MessageType, matrix_login, MatrixSendMessage diff --git a/matrix/api.py b/matrix/api.py index ee3765c..c168fc3 100644 --- a/matrix/api.py +++ b/matrix/api.py @@ -216,98 +216,6 @@ class MatrixClient: return HttpRequest(RequestType.POST, self.host, path, content) -class MatrixMessage: - def __init__( - self, - server, # type: MatrixServer - options, # type: PluginOptions - message_type, # type: MessageType - **kwargs - ): - # type: (...) -> None - # pylint: disable=dangerous-default-value - self.type = message_type # type: MessageType - - for key, value in kwargs.items(): - setattr(self, key, value) - - self.request = None # type: HttpRequest - self.response = None # type: HttpResponse - self.decoded_response = None # type: Dict[Any, Any] - - self.creation_time = time.time() # type: float - self.send_time = None # type: float - self.receive_time = None # type: float - - if message_type == MessageType.LOGIN: - self.request = server.client.login( - server.user, - server.password, - server.device_name - ) - - elif message_type == MessageType.SYNC: - sync_filter = { - "room": { - "timeline": {"limit": options.sync_limit} - } - } - - self.request = server.client.sync(server.next_batch, sync_filter) - - elif message_type == MessageType.SEND: - assert self.room_id - assert self.formatted_message - - data = {"content": self.formatted_message.to_plain()} - - if self.formatted_message.is_formatted: - data["formatted_content"] = self.formatted_message.to_html() - - self.request = server.client.room_send_message( - self.room_id, - **data - ) - - elif message_type == MessageType.TOPIC: - assert self.room_id - assert self.topic - self.request = server.client.room_topic(self.room_id, self.topic) - - elif message_type == MessageType.REDACT: - assert self.room_id - assert self.event_id - - self.request = server.client.room_redact( - self.room_id, - self.event_id, - self.reason - ) - - elif message_type == MessageType.ROOM_MSG: - assert self.room_id - assert self.token - - self.request = server.client.room_get_messages( - self.room_id, - start_token=self.token, - limit=options.backlog_limit, - ) - - elif message_type == MessageType.JOIN: - assert self.room_id - self.request = server.client.room_join(self.room_id) - - elif message_type == MessageType.PART: - assert self.room_id - self.request = server.client.room_leave(self.room_id) - - elif message_type == MessageType.INVITE: - assert self.room_id - assert self.user_id - self.request = server.client.room_invite(self.room_id, self.user_id) - - class MatrixGenericMessage(): def __init__( self, diff --git a/matrix/commands.py b/matrix/commands.py index 0502af3..7ae6cd7 100644 --- a/matrix/commands.py +++ b/matrix/commands.py @@ -25,7 +25,6 @@ from matrix.globals import W, OPTIONS, SERVERS from matrix.utf import utf8_decode from matrix.api import ( - MatrixMessage, MessageType, MatrixTopicMessage, MatrixRedactMessage,