refactor quotes

This commit is contained in:
Lexi / Zoe 2018-11-24 03:45:12 +01:00
parent 733a537f58
commit fd6a40cb0d
2 changed files with 18 additions and 16 deletions

View file

@ -31,6 +31,8 @@ async def parse_client_message(websocket, message_text):
async def handle_client_init(websocket, message):
"""Handle client 'init' message."""
# TODO input check for nickname
print(f"< init: chat_id='{message['chat_id']}', nickname='{message['nickname']}'")
await send_client_init_response(websocket)
await send_client_previous_messages(websocket)
@ -40,7 +42,7 @@ async def send_client_init_response(websocket):
"""Send an init response message to a newly connected client."""
response = json.dumps({
'type': 'init'
"type": "init"
})
print(f"> {response}")
await websocket.send(response)
@ -52,9 +54,9 @@ async def send_client_previous_messages(websocket):
# For now: send test messages
for i in range(1, 4):
testmsg = json.dumps({
'type': 'message',
'from': 'Alice',
'text': f"Message number {i}, hello!"
"type": "message",
"from": "Alice",
"text": f"Message number {i}, hello!"
})
print(f"> {testmsg}")
await websocket.send(testmsg)