Split out state messages, for now only topic messages are implemented.
This commit is contained in:
parent
ce718a9259
commit
90c63c197c
3 changed files with 7 additions and 7 deletions
|
@ -38,7 +38,7 @@ class MessageType(Enum):
|
|||
LOGIN = 0
|
||||
SYNC = 1
|
||||
SEND = 2
|
||||
STATE = 3
|
||||
TOPIC = 3
|
||||
REDACT = 4
|
||||
ROOM_MSG = 5
|
||||
JOIN = 6
|
||||
|
@ -247,7 +247,7 @@ class MatrixMessage:
|
|||
elif message_type == MessageType.SEND:
|
||||
self.request = server.client.room_send_message(room_id, data)
|
||||
|
||||
elif message_type == MessageType.STATE:
|
||||
elif message_type == MessageType.TOPIC:
|
||||
if extra_id == "m.room.topic":
|
||||
self.request = server.client.room_topic(room_id, data)
|
||||
else:
|
||||
|
|
|
@ -910,7 +910,7 @@ def matrix_command_topic_cb(data, buffer, command):
|
|||
message = MatrixMessage(
|
||||
server,
|
||||
OPTIONS,
|
||||
MessageType.STATE,
|
||||
MessageType.TOPIC,
|
||||
data=topic,
|
||||
room_id=room_id,
|
||||
extra_id="m.room.topic"
|
||||
|
|
|
@ -743,8 +743,8 @@ def matrix_handle_message(
|
|||
|
||||
room.prev_batch = response['end']
|
||||
|
||||
# Nothing to do here, we'll handle state changes and redactions in the sync
|
||||
elif (message_type == MessageType.STATE or
|
||||
# Nothing to do here, we'll handle topic changes and redactions in the sync
|
||||
elif (message_type == MessageType.TOPIC or
|
||||
message_type == MessageType.REDACT):
|
||||
pass
|
||||
|
||||
|
@ -810,12 +810,12 @@ def handle_http_response(server, message):
|
|||
server.timer_hook = None
|
||||
|
||||
server.disconnect()
|
||||
elif message.type == MessageType.STATE:
|
||||
elif message.type == MessageType.TOPIC:
|
||||
response = decode_json(server, message.response.body)
|
||||
reason = ("." if not response or not response["error"] else
|
||||
": {r}.".format(r=response["error"]))
|
||||
|
||||
error_message = ("{prefix}Can't set state{reason}").format(
|
||||
error_message = ("{prefix}Can't set topic{reason}").format(
|
||||
prefix=W.prefix("network"),
|
||||
reason=reason)
|
||||
server_buffer_prnt(server, error_message)
|
||||
|
|
Loading…
Add table
Reference in a new issue