Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
687dfa84e9 | ||
|
|
b7da515969 | ||
|
|
e2c291c040 | ||
|
|
87f2c5290f |
@@ -1,6 +1,9 @@
|
|||||||
FROM node:10-alpine
|
FROM node:10-alpine
|
||||||
|
|
||||||
RUN apk add g++ make python
|
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
|
RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app
|
||||||
|
|
||||||
|
|||||||
14
dist/bot.js
vendored
14
dist/bot.js
vendored
@@ -27,6 +27,7 @@ var _encryptAttachment = _interopRequireDefault(require("./encrypt-attachment"))
|
|||||||
|
|
||||||
global.Olm = require("olm");
|
global.Olm = require("olm");
|
||||||
const BOT_SIGNAL_END_CHAT = 'END_CHAT';
|
const BOT_SIGNAL_END_CHAT = 'END_CHAT';
|
||||||
|
const BOT_SIGNAL_CHAT_OFFLINE = 'CHAT_OFFLINE';
|
||||||
|
|
||||||
class OcrccBot {
|
class OcrccBot {
|
||||||
constructor(botConfig) {
|
constructor(botConfig) {
|
||||||
@@ -149,7 +150,7 @@ class OcrccBot {
|
|||||||
} else {
|
} else {
|
||||||
_logger.default.log('info', "NO FACILITATORS ONLINE");
|
_logger.default.log('info', "NO FACILITATORS ONLINE");
|
||||||
|
|
||||||
this.sendNotice(roomId, "CHAT_OFFLINE");
|
this.sendBotSignal(roomId, BOT_SIGNAL_CHAT_OFFLINE);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.handleBotCrash(roomId, err);
|
this.handleBotCrash(roomId, err);
|
||||||
@@ -574,10 +575,13 @@ class OcrccBot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setTimeoutforFacilitator(roomId) {
|
setTimeoutforFacilitator(roomId) {
|
||||||
setTimeout(() => {
|
setTimeout(async () => {
|
||||||
const stillWaiting = this.localStorage.getItem(`${roomId}-waiting`);
|
const stillWaiting = this.localStorage.getItem(`${roomId}-waiting`);
|
||||||
|
|
||||||
if (stillWaiting) {
|
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.sendBotSignal(roomId, BOT_SIGNAL_END_CHAT);
|
||||||
}
|
}
|
||||||
}, this.config.MAX_WAIT_TIME);
|
}, this.config.MAX_WAIT_TIME);
|
||||||
@@ -590,8 +594,10 @@ class OcrccBot {
|
|||||||
clearTimeout(oldTimeout);
|
clearTimeout(oldTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
const newTimeout = setTimeout(() => {
|
const newTimeout = setTimeout(async () => {
|
||||||
this.sendTextMessage(roomId, `This chat has been closed due to inactivity.`);
|
_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.sendBotSignal(roomId, BOT_SIGNAL_END_CHAT);
|
||||||
}, this.config.MAX_INACTIVE);
|
}, this.config.MAX_INACTIVE);
|
||||||
this.inactivityTimers[roomId] = newTimeout;
|
this.inactivityTimers[roomId] = newTimeout;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "private-safesupport-bot",
|
"name": "private-safesupport-bot",
|
||||||
"version": "2.0.1",
|
"version": "2.0.2",
|
||||||
"description": "Chatbot to manage interactions on Safe Support Chat",
|
"description": "Chatbot to manage interactions on Safe Support Chat",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
15
src/bot.js
15
src/bot.js
@@ -12,6 +12,7 @@ import logger from "./logger";
|
|||||||
import encrypt from "./encrypt-attachment";
|
import encrypt from "./encrypt-attachment";
|
||||||
|
|
||||||
const BOT_SIGNAL_END_CHAT = 'END_CHAT'
|
const BOT_SIGNAL_END_CHAT = 'END_CHAT'
|
||||||
|
const BOT_SIGNAL_CHAT_OFFLINE = 'CHAT_OFFLINE'
|
||||||
|
|
||||||
|
|
||||||
class OcrccBot {
|
class OcrccBot {
|
||||||
@@ -130,7 +131,7 @@ class OcrccBot {
|
|||||||
this.localStorage.setItem(`${roomId}-invitations`, invitations)
|
this.localStorage.setItem(`${roomId}-invitations`, invitations)
|
||||||
} else {
|
} else {
|
||||||
logger.log('info', "NO FACILITATORS ONLINE")
|
logger.log('info', "NO FACILITATORS ONLINE")
|
||||||
this.sendNotice(roomId, "CHAT_OFFLINE")
|
this.sendBotSignal(roomId, BOT_SIGNAL_CHAT_OFFLINE)
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
@@ -596,9 +597,14 @@ class OcrccBot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setTimeoutforFacilitator(roomId) {
|
setTimeoutforFacilitator(roomId) {
|
||||||
setTimeout(() => {
|
setTimeout(async() => {
|
||||||
const stillWaiting = this.localStorage.getItem(`${roomId}-waiting`)
|
const stillWaiting = this.localStorage.getItem(`${roomId}-waiting`)
|
||||||
if (stillWaiting) {
|
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.sendBotSignal(roomId, BOT_SIGNAL_END_CHAT)
|
||||||
}
|
}
|
||||||
}, this.config.MAX_WAIT_TIME)
|
}, this.config.MAX_WAIT_TIME)
|
||||||
@@ -611,8 +617,9 @@ class OcrccBot {
|
|||||||
clearTimeout(oldTimeout);
|
clearTimeout(oldTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
const newTimeout = setTimeout(() => {
|
const newTimeout = setTimeout(async() => {
|
||||||
this.sendTextMessage(
|
logger.log("info", `CHAT IS INACTIVE, SENDING SIGNAL TO END CHAT`);
|
||||||
|
await this.sendTextMessage(
|
||||||
roomId,
|
roomId,
|
||||||
`This chat has been closed due to inactivity.`
|
`This chat has been closed due to inactivity.`
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user