diff --git a/chat.py b/chat.py index 4ed10d56c3110eaff5e3590f6851e52e004dba93..b19ebd1a4f77246f82b4916b91f162f10fabf743 100644 --- a/chat.py +++ b/chat.py @@ -45,11 +45,15 @@ async def echo(websocket): room_id = name[websocket]['room_id'] #历史记录数量 if "history_num" in event["type"]: + r = { + "type": "history_num", + "content": "{}", + } if room_id in history : h = len(history[room_id]) else : h = 0 - r = {'type':'history_num','content':str(h)} + r['content'] = r['content'].format(h) message = json.dumps(r,ensure_ascii=False) await websocket.send(message) #历史记录 diff --git a/websockets/__pycache__/__init__.cpython-312.pyc b/websockets/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5a82c9d1d3debeaa887ae905f6ee6b13d14677f6 Binary files /dev/null and b/websockets/__pycache__/__init__.cpython-312.pyc differ diff --git a/websockets/__pycache__/imports.cpython-312.pyc b/websockets/__pycache__/imports.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..458e17b5f9d81f94c13a7e48d3c24c3ba0fd3eff Binary files /dev/null and b/websockets/__pycache__/imports.cpython-312.pyc differ diff --git a/websockets/__pycache__/version.cpython-312.pyc b/websockets/__pycache__/version.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5b8bdd41ca624917363e83298962964d02934f55 Binary files /dev/null and b/websockets/__pycache__/version.cpython-312.pyc differ