Add join/part message class.
This commit is contained in:
parent
dbf7df2e84
commit
7be29e2b3f
2 changed files with 35 additions and 9 deletions
|
@ -450,6 +450,34 @@ class MatrixBacklogMessage(MatrixGenericMessage):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class MatrixJoinMessage(MatrixGenericMessage):
|
||||||
|
def __init__(self, client, room_id):
|
||||||
|
self.room_id = room_id
|
||||||
|
|
||||||
|
data = {"room_id": self.room_id}
|
||||||
|
|
||||||
|
MatrixGenericMessage.__init__(
|
||||||
|
self,
|
||||||
|
MessageType.JOIN,
|
||||||
|
client.room_join,
|
||||||
|
data
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class MatrixPartMessage(MatrixGenericMessage):
|
||||||
|
def __init__(self, client, room_id):
|
||||||
|
self.room_id = room_id
|
||||||
|
|
||||||
|
data = {"room_id": self.room_id}
|
||||||
|
|
||||||
|
MatrixGenericMessage.__init__(
|
||||||
|
self,
|
||||||
|
MessageType.PART,
|
||||||
|
client.room_leave,
|
||||||
|
data
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class MatrixUser:
|
class MatrixUser:
|
||||||
def __init__(self, name, display_name):
|
def __init__(self, name, display_name):
|
||||||
self.name = name # type: str
|
self.name = name # type: str
|
||||||
|
|
|
@ -29,7 +29,9 @@ from matrix.api import (
|
||||||
MessageType,
|
MessageType,
|
||||||
MatrixTopicMessage,
|
MatrixTopicMessage,
|
||||||
MatrixRedactMessage,
|
MatrixRedactMessage,
|
||||||
MatrixBacklogMessage
|
MatrixBacklogMessage,
|
||||||
|
MatrixJoinMessage,
|
||||||
|
MatrixPartMessage
|
||||||
)
|
)
|
||||||
from matrix.utils import key_from_value, tags_from_line_data
|
from matrix.utils import key_from_value, tags_from_line_data
|
||||||
from matrix.plugin_options import DebugType
|
from matrix.plugin_options import DebugType
|
||||||
|
@ -190,10 +192,8 @@ def matrix_command_join_cb(data, buffer, command):
|
||||||
return
|
return
|
||||||
|
|
||||||
_, room_id = split_args
|
_, room_id = split_args
|
||||||
message = MatrixMessage(
|
message = MatrixJoinMessage(
|
||||||
server,
|
server.client,
|
||||||
OPTIONS,
|
|
||||||
MessageType.JOIN,
|
|
||||||
room_id=room_id
|
room_id=room_id
|
||||||
)
|
)
|
||||||
server.send_or_queue(message)
|
server.send_or_queue(message)
|
||||||
|
@ -231,10 +231,8 @@ def matrix_command_part_cb(data, buffer, command):
|
||||||
rooms = rooms.split(" ")
|
rooms = rooms.split(" ")
|
||||||
|
|
||||||
for room_id in rooms:
|
for room_id in rooms:
|
||||||
message = MatrixMessage(
|
message = MatrixPartMessage(
|
||||||
server,
|
server.client,
|
||||||
OPTIONS,
|
|
||||||
MessageType.PART,
|
|
||||||
room_id=room_id
|
room_id=room_id
|
||||||
)
|
)
|
||||||
server.send_or_queue(message)
|
server.send_or_queue(message)
|
||||||
|
|
Loading…
Add table
Reference in a new issue