Update client.py

This commit is contained in:
2026-02-21 14:37:14 +01:00
parent 791363810d
commit f277edfd9b

View File

@@ -67,7 +67,7 @@ def recv_json(sock):
return json.loads(buffer.decode("utf-8"))
except json.JSONDecodeError:
continue
return {} # fallback, lege dict als niks lukt
return {}
def login():
base_dir = Path(__file__).parent
@@ -140,6 +140,8 @@ chat_data = recv_json(s)
chat_names = list(chat_data.keys())
def draw_chat_window(messages, chatname):
current_input = readline.get_line_buffer() # bewaar wat je typt
clear()
w, h = term_size()
print(blauw_bg + wit + chatname.center(w) + reset)
@@ -153,6 +155,9 @@ def draw_chat_window(messages, chatname):
else:
print_white(f"[{user}] {text}")
print("-" * w)
readline.insert_text(current_input) # herstel input
readline.redisplay()
def chat_session(chatkeuze):
global chat_messages, chat_users