Merge branch 'master' of github.com:nomadic-labs/ocrcc-bot

This commit is contained in:
Sharon Kennedy 2020-09-11 16:12:07 -04:00
commit b7da515969
2 changed files with 13 additions and 4 deletions

View File

@ -1,6 +1,9 @@
FROM node:10-alpine
RUN apk add g++ make python
RUN apk add tzdata
ENV TZ America/Montreal
RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app

14
dist/bot.js vendored
View File

@ -27,6 +27,7 @@ var _encryptAttachment = _interopRequireDefault(require("./encrypt-attachment"))
global.Olm = require("olm");
const BOT_SIGNAL_END_CHAT = 'END_CHAT';
const BOT_SIGNAL_CHAT_OFFLINE = 'CHAT_OFFLINE';
class OcrccBot {
constructor(botConfig) {
@ -149,7 +150,7 @@ class OcrccBot {
} else {
_logger.default.log('info', "NO FACILITATORS ONLINE");
this.sendNotice(roomId, "CHAT_OFFLINE");
this.sendBotSignal(roomId, BOT_SIGNAL_CHAT_OFFLINE);
}
} catch (err) {
this.handleBotCrash(roomId, err);
@ -574,10 +575,13 @@ class OcrccBot {
}
setTimeoutforFacilitator(roomId) {
setTimeout(() => {
setTimeout(async () => {
const stillWaiting = this.localStorage.getItem(`${roomId}-waiting`);
if (stillWaiting) {
_logger.default.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);
@ -590,8 +594,10 @@ class OcrccBot {
clearTimeout(oldTimeout);
}
const newTimeout = setTimeout(() => {
this.sendTextMessage(roomId, `This chat has been closed due to inactivity.`);
const newTimeout = setTimeout(async () => {
_logger.default.log("info", `CHAT IS INACTIVE, SENDING SIGNAL TO END CHAT`);
await this.sendTextMessage(roomId, `This chat has been closed due to inactivity.`);
this.sendBotSignal(roomId, BOT_SIGNAL_END_CHAT);
}, this.config.MAX_INACTIVE);
this.inactivityTimers[roomId] = newTimeout;