Fixed slow, changed clean to handle all env variables, changed database handling

This commit is contained in:
TheEssem 2021-04-14 16:37:40 -05:00
parent e89ae06646
commit cc82d32840
5 changed files with 10 additions and 14 deletions

View file

@ -29,7 +29,7 @@ class SpeedWorker : public Napi::AsyncWorker {
}
int new_delay = slow ? old_delay * 2 : old_delay / 2;
if (new_delay <= 1) {
if (!slow && new_delay <= 1) {
new_delay = old_delay;
auto it = frames.begin();
while(it != frames.end() && ++it != frames.end()) it = frames.erase(it);

View file

@ -1,3 +1,3 @@
// wrapper for the database drivers in ./database/
module.exports = require(`./database/${process.env.DB_DRIVER}.js`);
module.exports = require(`./database/${process.env.DB.split("://")[0]}.js`);

View file

@ -6,7 +6,7 @@ exports.random = (array) => {
};
const optionalReplace = (token) => {
return token === "" ? "" : "<redacted>";
return token === undefined || token === "" ? "" : "<redacted>";
};
// clean(text) to clean message of any private info or mentions
@ -18,17 +18,13 @@ exports.clean = async (text) => {
text = text
.replaceAll("`", `\`${String.fromCharCode(8203)}`)
.replaceAll("@", `@${String.fromCharCode(8203)}`)
.replaceAll(process.env.TOKEN, optionalReplace(process.env.TOKEN))
.replaceAll(process.env.MASHAPE, optionalReplace(process.env.MASHAPE))
.replaceAll(process.env.CAT, optionalReplace(process.env.CAT))
.replaceAll(process.env.GOOGLE, optionalReplace(process.env.GOOGLE))
.replaceAll(process.env.DBL, optionalReplace(process.env.DBL))
.replaceAll(process.env.MONGO, optionalReplace(process.env.MONGO))
.replaceAll(process.env.TWITTER_KEY, optionalReplace(process.env.TWITTER_KEY))
.replaceAll(process.env.CONSUMER_SECRET, optionalReplace(process.env.CONSUMER_SECRET))
.replaceAll(process.env.ACCESS_TOKEN, optionalReplace(process.env.ACCESS_TOKEN))
.replaceAll(process.env.ACCESS_SECRET, optionalReplace(process.env.ACCESS_SECRET));
.replaceAll("@", `@${String.fromCharCode(8203)}`);
const { parsed } = require("dotenv").config();
for (const env of Object.keys(parsed)) {
text = text.replaceAll(parsed[env], optionalReplace(parsed[env]));
}
return text;
};