From e2c291c04054868117b1182cb76613f9f45dbb48 Mon Sep 17 00:00:00 2001 From: Sharon Kennedy Date: Fri, 11 Sep 2020 16:12:01 -0400 Subject: [PATCH] change notice to signal --- src/bot.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/bot.js b/src/bot.js index c675be2..66432ab 100644 --- a/src/bot.js +++ b/src/bot.js @@ -12,6 +12,7 @@ import logger from "./logger"; import encrypt from "./encrypt-attachment"; const BOT_SIGNAL_END_CHAT = 'END_CHAT' +const BOT_SIGNAL_CHAT_OFFLINE = 'CHAT_OFFLINE' class OcrccBot { @@ -130,7 +131,7 @@ class OcrccBot { this.localStorage.setItem(`${roomId}-invitations`, invitations) } else { logger.log('info', "NO FACILITATORS ONLINE") - this.sendNotice(roomId, "CHAT_OFFLINE") + this.sendBotSignal(roomId, BOT_SIGNAL_CHAT_OFFLINE) } } catch(err) { @@ -596,9 +597,14 @@ class OcrccBot { } setTimeoutforFacilitator(roomId) { - setTimeout(() => { + setTimeout(async() => { const stillWaiting = this.localStorage.getItem(`${roomId}-waiting`) if (stillWaiting) { + logger.log("info", `FACILITATOR DID NOT JOIN CHAT WITHIN TIME LIMIT, SENDING SIGNAL TO END CHAT`); + await this.sendTextMessage( + roomId, + this.config.CHAT_NOT_AVAILABLE_MESSAGE + ); this.sendBotSignal(roomId, BOT_SIGNAL_END_CHAT) } }, this.config.MAX_WAIT_TIME) @@ -611,8 +617,9 @@ class OcrccBot { clearTimeout(oldTimeout); } - const newTimeout = setTimeout(() => { - this.sendTextMessage( + const newTimeout = setTimeout(async() => { + logger.log("info", `CHAT IS INACTIVE, SENDING SIGNAL TO END CHAT`); + await this.sendTextMessage( roomId, `This chat has been closed due to inactivity.` );