change notice to signal
This commit is contained in:
parent
4fdddc8c92
commit
e2c291c040
15
src/bot.js
15
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.`
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user