Update client.py
This commit is contained in:
@@ -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)
|
||||
@@ -154,6 +156,9 @@ def draw_chat_window(messages, chatname):
|
||||
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
|
||||
s.sendall(json.dumps({"action": "openchat", "chat_name": chatkeuze}).encode("utf-8"))
|
||||
|
||||
Reference in New Issue
Block a user