Update app.py
Browse files
app.py
CHANGED
@@ -99,8 +99,7 @@ async def load_chat():
|
|
99 |
await asyncio.to_thread(lambda: open(CHAT_FILE, 'w').write(f"# {START_ROOM} Chat\n\nWelcome to the cosmic hub - start chatting! 🎤\n"))
|
100 |
with open(CHAT_FILE, 'r') as f:
|
101 |
content = await asyncio.to_thread(f.read)
|
102 |
-
|
103 |
-
return "\n".join(f"{i+1}. {line}" for i, line in enumerate(lines) if line.strip())
|
104 |
|
105 |
async def get_user_list(chat_content):
|
106 |
"""👥 - Crew Clue Brew - Spots who’s who in the crew!"""
|
@@ -299,7 +298,8 @@ async def create_streamlit_interface():
|
|
299 |
if 'client_id' not in st.session_state:
|
300 |
st.session_state.client_id = str(uuid.uuid4())
|
301 |
if 'username' not in st.session_state:
|
302 |
-
|
|
|
303 |
st.session_state.username = random.choice(available_names) if available_names else random.choice(FUN_USERNAMES)
|
304 |
|
305 |
# Session state initialization
|
|
|
99 |
await asyncio.to_thread(lambda: open(CHAT_FILE, 'w').write(f"# {START_ROOM} Chat\n\nWelcome to the cosmic hub - start chatting! 🎤\n"))
|
100 |
with open(CHAT_FILE, 'r') as f:
|
101 |
content = await asyncio.to_thread(f.read)
|
102 |
+
return content # Return the raw string, splitting handled where needed
|
|
|
103 |
|
104 |
async def get_user_list(chat_content):
|
105 |
"""👥 - Crew Clue Brew - Spots who’s who in the crew!"""
|
|
|
298 |
if 'client_id' not in st.session_state:
|
299 |
st.session_state.client_id = str(uuid.uuid4())
|
300 |
if 'username' not in st.session_state:
|
301 |
+
chat_content = await load_chat() # Await the coroutine here
|
302 |
+
available_names = [name for name in FUN_USERNAMES if not any(f"{name} has joined" in line for line in chat_content.split('\n'))]
|
303 |
st.session_state.username = random.choice(available_names) if available_names else random.choice(FUN_USERNAMES)
|
304 |
|
305 |
# Session state initialization
|