Update client.py
This commit is contained in:
22
client.py
22
client.py
@@ -65,8 +65,8 @@ def login():
|
||||
data = json.load(f)
|
||||
except:
|
||||
data = {}
|
||||
user = input(wit + "Gebruikersnaam: " + reset)
|
||||
password = getpass.getpass(wit + "Wachtwoord: " + reset)
|
||||
user = input(wit + "user: " + reset)
|
||||
password = getpass.getpass(wit + "password: " + reset)
|
||||
password_hash = hashlib.sha256(password.encode("utf-8")).hexdigest()
|
||||
if user in data and data[user] == password_hash:
|
||||
return user
|
||||
@@ -100,11 +100,11 @@ while not current_user:
|
||||
print()
|
||||
|
||||
print( groen + "========================================")
|
||||
print("Welkom bij De Terminal Chat")
|
||||
print(" Welcome to the Terminal Chat")
|
||||
print("========================================" + reset)
|
||||
print()
|
||||
print_white("1. inloggen")
|
||||
print_white("2. nieuw account")
|
||||
print_white("1. Login")
|
||||
print_white("2. Sign up")
|
||||
print()
|
||||
keuze = input(wit + " > " + reset)
|
||||
print()
|
||||
@@ -170,7 +170,7 @@ def chat_session(chatkeuze):
|
||||
if isinstance(decoded, dict) and decoded.get("type") == "users_list":
|
||||
users = decoded.get("users", [])
|
||||
print("\nUsers:", ", ".join(users))
|
||||
print(wit + "Typ je bericht: " + reset, end="", flush=True)
|
||||
print(wit + "> " + reset, end="", flush=True)
|
||||
continue
|
||||
|
||||
# normale chat update
|
||||
@@ -180,7 +180,7 @@ def chat_session(chatkeuze):
|
||||
chat_users = decoded[chatkeuze].get("users", [])
|
||||
|
||||
draw_chat_window(chat_messages, chatkeuze)
|
||||
print(wit + "Typ je bericht: " + reset, end="", flush=True)
|
||||
print(wit + "> " + reset, end="", flush=True)
|
||||
|
||||
except Exception:
|
||||
break
|
||||
@@ -189,7 +189,7 @@ def chat_session(chatkeuze):
|
||||
|
||||
while True:
|
||||
draw_chat_window(chat_messages, chatkeuze)
|
||||
bericht = input(wit + "Typ je bericht: " + reset)
|
||||
bericht = input(wit + "> " + reset)
|
||||
|
||||
if bericht.lower() == "/quit":
|
||||
exit()
|
||||
@@ -229,14 +229,14 @@ def chat_session(chatkeuze):
|
||||
}).encode("utf-8"))
|
||||
|
||||
while True:
|
||||
print_white(" --- Beschikbare chats: --- ")
|
||||
print_white(" --- Available chats: --- ")
|
||||
for i, chat in enumerate(chat_names, start=1):
|
||||
print_white(f"{i}. {chat}")
|
||||
print_white(f"{len(chat_names)+1}. Nieuwe chat aanmaken")
|
||||
print_white(f"{len(chat_names)+1}. New chat")
|
||||
keuze = input(wit + " > " + reset)
|
||||
|
||||
if keuze.isdigit() and int(keuze) == len(chat_names)+1:
|
||||
nieuwe_chat = input("Naam van nieuwe chat: ")
|
||||
nieuwe_chat = input("Name of new chat: ")
|
||||
s.sendall(json.dumps({"action": "new_chat", "chat_name": nieuwe_chat}).encode("utf-8"))
|
||||
data = s.recv(4096)
|
||||
chat_data = json.loads(data.decode("utf-8"))
|
||||
|
||||
Reference in New Issue
Block a user