Update app.py
Browse files
app.py
CHANGED
@@ -5,7 +5,7 @@ from collections import defaultdict
|
|
5 |
|
6 |
# Store all conversations and users
|
7 |
conversations = defaultdict(list)
|
8 |
-
usernames =
|
9 |
|
10 |
# Generate a random conversation ID
|
11 |
def generate_conversation_id():
|
@@ -14,12 +14,11 @@ def generate_conversation_id():
|
|
14 |
# Handle new chat creation
|
15 |
def new_chat():
|
16 |
conversation_id = generate_conversation_id()
|
|
|
17 |
return conversation_id
|
18 |
|
19 |
# Handle user joining the conversation
|
20 |
def join_chat(chat_id, username):
|
21 |
-
if chat_id not in usernames:
|
22 |
-
usernames[chat_id] = []
|
23 |
if username not in usernames[chat_id]:
|
24 |
usernames[chat_id].append(username)
|
25 |
return f"Welcome {username}! You have joined the chat."
|
|
|
5 |
|
6 |
# Store all conversations and users
|
7 |
conversations = defaultdict(list)
|
8 |
+
usernames = defaultdict(list)
|
9 |
|
10 |
# Generate a random conversation ID
|
11 |
def generate_conversation_id():
|
|
|
14 |
# Handle new chat creation
|
15 |
def new_chat():
|
16 |
conversation_id = generate_conversation_id()
|
17 |
+
conversations[conversation_id] = [] # Initialize the conversation in the dictionary
|
18 |
return conversation_id
|
19 |
|
20 |
# Handle user joining the conversation
|
21 |
def join_chat(chat_id, username):
|
|
|
|
|
22 |
if username not in usernames[chat_id]:
|
23 |
usernames[chat_id].append(username)
|
24 |
return f"Welcome {username}! You have joined the chat."
|