From 8b21e9957d27942678b79b2545fe659ff3024493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?poljar=20=28Damir=20Jeli=C4=87=29?= Date: Mon, 12 Feb 2018 14:15:08 +0100 Subject: [PATCH] Add invite message class. --- matrix/api.py | 15 +++++++++++++++ matrix/commands.py | 9 ++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/matrix/api.py b/matrix/api.py index 021816d..ee3765c 100644 --- a/matrix/api.py +++ b/matrix/api.py @@ -478,6 +478,21 @@ class MatrixPartMessage(MatrixGenericMessage): ) +class MatrixInviteMessage(MatrixGenericMessage): + def __init__(self, client, room_id, user_id): + self.room_id = room_id + + data = {"room_id": self.room_id, + "user_id": user_id} + + MatrixGenericMessage.__init__( + self, + MessageType.INVITE, + client.room_invite, + 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 f388435..0502af3 100644 --- a/matrix/commands.py +++ b/matrix/commands.py @@ -31,7 +31,8 @@ from matrix.api import ( MatrixRedactMessage, MatrixBacklogMessage, MatrixJoinMessage, - MatrixPartMessage + MatrixPartMessage, + MatrixInviteMessage ) from matrix.utils import key_from_value, tags_from_line_data from matrix.plugin_options import DebugType @@ -264,10 +265,8 @@ def matrix_command_invite_cb(data, buffer, command): _, invitee = split_args room_id = key_from_value(server.buffers, buf) - message = MatrixMessage( - server, - OPTIONS, - MessageType.INVITE, + message = MatrixInviteMessage( + server.client, room_id=room_id, user_id=invitee )