Add login message class.
This commit is contained in:
parent
b22deceb00
commit
bc6db177a8
1 changed files with 24 additions and 4 deletions
|
@ -329,6 +329,25 @@ class MatrixGenericMessage():
|
||||||
self.request = request_func(**func_args)
|
self.request = request_func(**func_args)
|
||||||
|
|
||||||
|
|
||||||
|
class MatrixLoginMessage(MatrixGenericMessage):
|
||||||
|
def __init__(self, client, user, password, device_name, device_id=None):
|
||||||
|
data = {
|
||||||
|
"user": user,
|
||||||
|
"password": password,
|
||||||
|
"device_name": device_name
|
||||||
|
}
|
||||||
|
|
||||||
|
if device_id:
|
||||||
|
data["device_id"] = device_id
|
||||||
|
|
||||||
|
MatrixGenericMessage.__init__(
|
||||||
|
self,
|
||||||
|
MessageType.LOGIN,
|
||||||
|
client.login,
|
||||||
|
data
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class MatrixSendMessage(MatrixGenericMessage):
|
class MatrixSendMessage(MatrixGenericMessage):
|
||||||
def __init__(self, client, room_id, formatted_message):
|
def __init__(self, client, room_id, formatted_message):
|
||||||
self.room_id = room_id
|
self.room_id = room_id
|
||||||
|
@ -389,9 +408,10 @@ def matrix_sync(server):
|
||||||
|
|
||||||
def matrix_login(server):
|
def matrix_login(server):
|
||||||
# type: (MatrixServer) -> None
|
# type: (MatrixServer) -> None
|
||||||
message = MatrixMessage(
|
message = MatrixLoginMessage(
|
||||||
server,
|
server.client,
|
||||||
OPTIONS,
|
server.user,
|
||||||
MessageType.LOGIN
|
server.password,
|
||||||
|
server.device_name
|
||||||
)
|
)
|
||||||
server.send_or_queue(message)
|
server.send_or_queue(message)
|
||||||
|
|
Loading…
Add table
Reference in a new issue