From 94e4540a363c2ac4a3806833db6e0167368e3c32 Mon Sep 17 00:00:00 2001
From: Samuel MARTIN MORO <faust64@gmail.com>
Date: Wed, 26 May 2021 12:59:18 +0200
Subject: [PATCH] feat(chat-message): chat.py equivalent

---
 chat.py                                  | 11 +++++++++--
 examples/.env.chat_example               |  2 +-
 examples/docker-compose.yml.chat_example |  2 +-
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/chat.py b/chat.py
index 250916e..58aa170 100644
--- a/chat.py
+++ b/chat.py
@@ -85,8 +85,15 @@ def bbb_browser():
 
     element = EC.invisibility_of_element((By.CSS_SELECTOR, '.ReactModal__Overlay'))
     WebDriverWait(browser, selenium_timeout).until(element)
-    browser.find_element_by_id('message-input').send_keys("Viewers of the live stream can now send messages to this meeting")
-    browser.find_elements_by_css_selector('[aria-label="Send message"]')[0].click()
+
+    element = browser.find_element_by_id('message-input')
+    chat_send = browser.find_elements_by_css_selector('[aria-label="Send message"]')[0]
+    # ensure chat is enabled (might be locked by moderator)
+    if element.is_enabled() and chat_send.is_enabled():
+       tmp_chatMsg = os.environ.get('BBB_CHAT_MESSAGE', "Viewers of the live stream can now send messages to this meeting")
+       if not tmp_chatMsg in [ 'false', 'False', 'FALSE' ]:
+           element.send_keys(tmp_chatMsg)
+           chat_send.click()
 
     redis_r = redis.Redis(host=args.redis,charset="utf-8", decode_responses=True)
     redis_s = redis_r.pubsub()
diff --git a/examples/.env.chat_example b/examples/.env.chat_example
index 43a4c78..da0bd49 100644
--- a/examples/.env.chat_example
+++ b/examples/.env.chat_example
@@ -17,4 +17,4 @@ BBB_REDIS_CHANNEL=chat
 # Username for the chat (default: 'Chat')
 BBB_CHAT_NAME=Chat
 # Message to post in BBB Chat when joining a conference
-BBB_CHAT_MESSAGE=This meeting is streamed to
+BBB_CHAT_MESSAGE=Viewers of the live stream can now send messages to this meeting
diff --git a/examples/docker-compose.yml.chat_example b/examples/docker-compose.yml.chat_example
index 5b8346a..c58263e 100644
--- a/examples/docker-compose.yml.chat_example
+++ b/examples/docker-compose.yml.chat_example
@@ -21,7 +21,7 @@ services:
       # show chat in live stream
       - BBB_SHOW_CHAT=false
       # Message to post in BBB Chat when joining a conference
-      - BBB_CHAT_MESSAGE=This meeting is streamed to
+      - BBB_CHAT_MESSAGE=Viewers of the live stream can now send messages to this meeting
       # Set REDIS host (default: 'redis')
       - BBB_REDIS_HOST=redis
       # Set REDIS channel to subscribe (default: 'chat')
-- 
GitLab