riderle commited on
Commit
3ea3799
·
1 Parent(s): 96fa7c0

Removing "_ has entered the chat" test (#1)

Browse files

- Removing "_ has entered the chat" test (cc69809f66802535932d209347b8530ac339ba3d)

Files changed (1) hide show
  1. chat_application/main.py +15 -0
chat_application/main.py CHANGED
@@ -216,6 +216,13 @@ def send_bot_joined(room_id, bot_name, delay):
216
  time.sleep(delay)
217
  socketio.emit("message", {"sender": "", "message": f"{bot_name} has entered the chat"}, to=room_id)
218
 
 
 
 
 
 
 
 
219
  # Trigger a round of bot calls if user has been inactive for a while
220
  def user_inactivity_tracker(room_id, timeout_seconds=120,randomNorm = (0,15)):
221
  print(f"Started user inactivity tracker for Room ID#{room_id}")
@@ -626,6 +633,7 @@ def handle_connect():
626
  join_room(room)
627
  if (room_doc.get("initialPostsSent", False)):
628
  return
 
629
  # Send the message that "watermelon" has already joined the chat
630
  send({
631
  "sender": "",
@@ -636,10 +644,17 @@ def handle_connect():
636
  "sender": "",
637
  "message": f"{name} has entered the chat"
638
  }, to=room)
 
639
  # Start background tasks for the bots to join after a short delay
 
 
 
 
 
640
  socketio.start_background_task(send_bot_joined, room, room_doc['CoolBot_name'], 3)
641
  socketio.start_background_task(send_bot_joined, room, room_doc['FroBot_name'], 7)
642
  socketio.start_background_task(send_bot_joined, room, room_doc['HotBot_name'], 13)
 
643
  # Start background task to send the initial watermelon post after a short delay
644
  socketio.start_background_task(send_initial_post, room, 10)
645
  # Start the background backup dataset task
 
216
  time.sleep(delay)
217
  socketio.emit("message", {"sender": "", "message": f"{bot_name} has entered the chat"}, to=room_id)
218
 
219
+ # Send message displaying all participant names
220
+ def send_bot_names_message(room_id, bot_names):
221
+ if len(bot_names) == 0:
222
+ return
223
+ # Wait 1 second before sending
224
+ socketio.emit("message", {"sender": "", "message": f"This chat currently contains {', '.join(bot_names)}, and watermelon."}, to=room_id)
225
+
226
  # Trigger a round of bot calls if user has been inactive for a while
227
  def user_inactivity_tracker(room_id, timeout_seconds=120,randomNorm = (0,15)):
228
  print(f"Started user inactivity tracker for Room ID#{room_id}")
 
633
  join_room(room)
634
  if (room_doc.get("initialPostsSent", False)):
635
  return
636
+ """ Removed and replaced with send_bot_joined() below
637
  # Send the message that "watermelon" has already joined the chat
638
  send({
639
  "sender": "",
 
644
  "sender": "",
645
  "message": f"{name} has entered the chat"
646
  }, to=room)
647
+ """
648
  # Start background tasks for the bots to join after a short delay
649
+ socketio.start_background_task(send_bot_names_message, room,
650
+ [room_doc['CoolBot_name'], room_doc['FroBot_name'],
651
+ room_doc['HotBot_name']])
652
+ """ Disabling "__Bot_Name_ has entered the chat" message for each bot.
653
+ Instead, displays a single message showing all the participants' names ^^
654
  socketio.start_background_task(send_bot_joined, room, room_doc['CoolBot_name'], 3)
655
  socketio.start_background_task(send_bot_joined, room, room_doc['FroBot_name'], 7)
656
  socketio.start_background_task(send_bot_joined, room, room_doc['HotBot_name'], 13)
657
+ """
658
  # Start background task to send the initial watermelon post after a short delay
659
  socketio.start_background_task(send_initial_post, room, 10)
660
  # Start the background backup dataset task