This commit is contained in:
Flummi 2017-11-26 17:13:57 +01:00
parent 4af52d6609
commit ddd1530c8e
2 changed files with 10 additions and 7 deletions

View File

@ -10,13 +10,12 @@ read().then(() => {
_trigger: new Map() _trigger: new Map()
}; };
const files = fs.readdirSync(`${__dirname}/inc/trigger/`); fs.readdirSync(`${__dirname}/inc/trigger/`).forEach(file => {
for (let file in files) { if(file.substr(-3, 3) === ".js") {
if (files[file].substr(-3, 3) === ".js") { logger.info(`(main) loading trigger: ${file}`);
logger.info(`(main) loading trigger: ${files[file]}`); require(`${__dirname}/inc/trigger/${file}`)(self);
require(`${__dirname}/inc/trigger/${files[file]}`)(self);
} }
} });
bot.on("message", e => { // Todo: eventhandler bot.on("message", e => { // Todo: eventhandler
for (var [name, trigger] of self._trigger.entries()) { for (var [name, trigger] of self._trigger.entries()) {

View File

@ -37,7 +37,11 @@ module.exports = bot => {
return e.reply(`holy fuck, Ausgabe wäre viel zu lang! (${output.length} Zeichen :DDDDDD)`); return e.reply(`holy fuck, Ausgabe wäre viel zu lang! (${output.length} Zeichen :DDDDDD)`);
else { else {
_contexts.set(`${e.network}.${e.channel}.${e.user.nick}`, context); _contexts.set(`${e.network}.${e.channel}.${e.user.nick}`, context);
sql.exec("update `useless` set `data` = ? where `trigger` = 'sandbox_js';", JSON.stringify(stringify([..._contexts]).replace(/\n/g, "").replace(/\t/g, ""))) let tmp = JSON.stringify(stringify([..._contexts])
.replace(/\n/g, "")
.replace(/\t/g, "")
.split("[native code]").join(""));
sql.exec("update `useless` set `data` = ? where `trigger` = 'sandbox_js';", tmp)
.then(() => { .then(() => {
e.reply(output); e.reply(output);
}) })