send notice if chat is offline so chatbox can stop waiting
This commit is contained in:
parent
18d96af731
commit
38d22f8aed
27
src/bot.js
27
src/bot.js
@ -39,6 +39,31 @@ class OcrccBot {
|
||||
this.sendMessage(roomId, content);
|
||||
}
|
||||
|
||||
|
||||
async sendNotice(roomId, message) {
|
||||
logger.log("info", `SENDING *NOTICE*: ${message}`)
|
||||
try {
|
||||
await this.client.sendNotice(roomId, message)
|
||||
} catch(err) {
|
||||
switch (err["name"]) {
|
||||
case "UnknownDeviceError":
|
||||
Object.keys(err.devices).forEach(userId => {
|
||||
Object.keys(err.devices[userId]).map(async deviceId => {
|
||||
try {
|
||||
await this.client.setDeviceVerified(userId, deviceId, true);
|
||||
} catch(err) {
|
||||
logger.log("error", `ERROR VERIFYING DEVICE: ${err}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
await this.sendNotice(roomId, message);
|
||||
default:
|
||||
logger.log("error", `ERROR SENDING *NOTICE*: ${err}`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async sendMessage(roomId, content) {
|
||||
logger.log("info", `SENDING MESSAGE: ${content.body}`)
|
||||
try {
|
||||
@ -104,6 +129,7 @@ class OcrccBot {
|
||||
if (chatOffline) {
|
||||
logger.log('info', "NO FACILITATORS ONLINE")
|
||||
this.sendTextMessage(roomId, this.config.CHAT_OFFLINE_MESSAGE);
|
||||
this.sendNotice(roomId, "Chat is offline")
|
||||
}
|
||||
|
||||
} catch(err) {
|
||||
@ -112,6 +138,7 @@ class OcrccBot {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async uninviteFacilitators(roomId) {
|
||||
this.localStorage.removeItem(`${roomId}-waiting`)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user