-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
50 lines (40 loc) · 1.2 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
class Plugin {
static instance = null;
#ctx;
constructor(ctx) {
if (Plugin.instance)
return Plugin.instance;
this.#ctx = ctx;
this.logger = null;
this.disable = false;
Plugin.instance = this;
}
static getInstance() {
if (!Plugin.instance)
throw new Error("Plugin not initialized");
return Plugin.instance;
}
onLoad() {
const { TREM, Logger, logger } = this.#ctx;
const { CustomLogger } = require("../logger/logger").createCustomLogger(Logger);
this.logger = new CustomLogger("disable_tts");
this.logger.info("Initialization completed!");
const winstonLogger = logger._getLogger();
winstonLogger.transports.forEach(transport => {
const originalLog = transport.log.bind(transport);
transport.log = (info, callback) => {
if (!this.disable && info.message == "Speech ready!") {
this.disable = true;
this.logger.info("Disabling TTS successfully!");
TREM.variable.speech = {
speak : () => void 0,
speaking : () => void 0,
cancel : () => void 0,
};
}
return originalLog(info, callback);
};
});
}
}
module.exports = Plugin;