check for presence of transcript file before attempting to write to it

This commit is contained in:
Sharon Kennedy 2020-04-23 10:24:03 -04:00
parent b641b18a28
commit 18d96af731
2 changed files with 10 additions and 0 deletions

5
dist/bot.js vendored
View File

@ -184,6 +184,11 @@ class OcrccBot {
timeZone: "America/New_York"
});
const filepath = this.localStorage.getItem(`${roomId}-transcript`);
if (!filepath) {
return _logger.default.log("error", `NO TRANSCRIPT FILE FOR ROOM: ${roomId}`);
}
const message = `${sender} [${time}]: ${content.body}\n`;
fs.appendFileSync(filepath, message, "utf8");
} catch (err) {

View File

@ -173,6 +173,11 @@ class OcrccBot {
timeZone: "America/New_York"
});
const filepath = this.localStorage.getItem(`${roomId}-transcript`)
if (!filepath) {
return logger.log("error", `NO TRANSCRIPT FILE FOR ROOM: ${roomId}`);
}
const message = `${sender} [${time}]: ${content.body}\n`;
fs.appendFileSync(filepath, message, "utf8");