From d0c695dc09f375bb28ae447106dbca448251664e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?poljar=20=28Damir=20Jeli=C4=87=29?= Date: Mon, 12 Feb 2018 12:51:33 +0100 Subject: [PATCH] Add topic message class. --- matrix/api.py | 18 ++++++++++++++++++ matrix/commands.py | 8 +++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/matrix/api.py b/matrix/api.py index 80eff8d..003e0c6 100644 --- a/matrix/api.py +++ b/matrix/api.py @@ -392,6 +392,24 @@ class MatrixSendMessage(MatrixGenericMessage): ) +class MatrixTopicMessage(MatrixGenericMessage): + def __init__(self, client, room_id, topic): + self.room_id = room_id + self.topic = topic + + data = { + "room_id": self.room_id, + "topic": self.topic + } + + MatrixGenericMessage.__init__( + self, + MessageType.TOPIC, + client.room_topic, + data + ) + + class MatrixUser: def __init__(self, name, display_name): self.name = name # type: str diff --git a/matrix/commands.py b/matrix/commands.py index cd3d268..1d7cf59 100644 --- a/matrix/commands.py +++ b/matrix/commands.py @@ -24,7 +24,7 @@ import matrix.globals from matrix.globals import W, OPTIONS, SERVERS from matrix.utf import utf8_decode -from matrix.api import MatrixMessage, MessageType +from matrix.api import MatrixMessage, MessageType, MatrixTopicMessage from matrix.utils import key_from_value, tags_from_line_data from matrix.plugin_options import DebugType from matrix.server import MatrixServer @@ -907,10 +907,8 @@ def matrix_command_topic_cb(data, buffer, command): return W.WEECHAT_RC_OK_EAT - message = MatrixMessage( - server, - OPTIONS, - MessageType.TOPIC, + message = MatrixTopicMessage( + server.client, room_id=room_id, topic=topic )