Remove MatrixMessage class.
This commit is contained in:
parent
8b21e9957d
commit
49b356f510
3 changed files with 0 additions and 94 deletions
1
main.py
1
main.py
|
@ -32,7 +32,6 @@ from matrix.colors import Formatted
|
||||||
from matrix.utf import utf8_decode
|
from matrix.utf import utf8_decode
|
||||||
from matrix.http import HttpResponse
|
from matrix.http import HttpResponse
|
||||||
from matrix.api import (
|
from matrix.api import (
|
||||||
MatrixMessage,
|
|
||||||
MessageType,
|
MessageType,
|
||||||
matrix_login,
|
matrix_login,
|
||||||
MatrixSendMessage
|
MatrixSendMessage
|
||||||
|
|
|
@ -216,98 +216,6 @@ class MatrixClient:
|
||||||
return HttpRequest(RequestType.POST, self.host, path, content)
|
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():
|
class MatrixGenericMessage():
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -25,7 +25,6 @@ from matrix.globals import W, OPTIONS, SERVERS
|
||||||
|
|
||||||
from matrix.utf import utf8_decode
|
from matrix.utf import utf8_decode
|
||||||
from matrix.api import (
|
from matrix.api import (
|
||||||
MatrixMessage,
|
|
||||||
MessageType,
|
MessageType,
|
||||||
MatrixTopicMessage,
|
MatrixTopicMessage,
|
||||||
MatrixRedactMessage,
|
MatrixRedactMessage,
|
||||||
|
|
Loading…
Reference in a new issue