muh
This commit is contained in:
parent
e2bb64aa2c
commit
ef947060d2
5
package-lock.json
generated
5
package-lock.json
generated
@ -2115,6 +2115,11 @@
|
||||
"hashish": "0.0.4"
|
||||
}
|
||||
},
|
||||
"string-form-utils": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/string-form-utils/-/string-form-utils-0.1.0.tgz",
|
||||
"integrity": "sha1-z/J9cobJCf7G8LicngouXl+mSNk="
|
||||
},
|
||||
"string_decoder": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz",
|
||||
|
@ -15,6 +15,7 @@
|
||||
"node-telegram-bot-api": "^0.29.0",
|
||||
"nodejs-mysql": "^0.1.3",
|
||||
"request": "^2.83.0",
|
||||
"string-form-utils": "^0.1.0",
|
||||
"winston": "^2.4.0",
|
||||
"xml2js": "^0.4.19",
|
||||
"youtube-dl": "^1.12.2"
|
||||
|
@ -39,20 +39,22 @@ const write = (kat, key, value, type, cb) => {
|
||||
if (type === "json")
|
||||
value = JSON.stringify(value);
|
||||
|
||||
self.sql.query("select * from `cfg` where `class` = ? && `key` = ? limit 1", [kat, key], (err, rows) => {
|
||||
console.log(kat, key, value, type);
|
||||
sql.exec("select * from `cfg` where `class` = ? && `key` = ? limit 1", [kat, key], (err, rows) => {
|
||||
console.log(rows);
|
||||
if (rows.length > 0) {
|
||||
self.sql.query("update `cfg` set `value` = ? where `class` = ? && `key` = ?", [value, kat, key], (err) => {
|
||||
self.read(cfg => {
|
||||
self.cfg = cfg
|
||||
if (cb) cb(err);
|
||||
sql.exec("update `cfg` set `value` = ? where `class` = ? && `key` = ?", [value, kat, key], (err) => {
|
||||
console.log("updated", err);
|
||||
read().then(() => {
|
||||
if(cb) cb();
|
||||
});
|
||||
});
|
||||
}
|
||||
else {
|
||||
self.sql.query("insert into `cfg` (`class`,`key`,`value`,`type`) values (?,?,?,?)", [kat, key, value, type], (err) => {
|
||||
self.read(cfg => {
|
||||
self.cfg = cfg
|
||||
if (cb) cb(err);
|
||||
sql.exec("insert into `cfg` (`class`,`key`,`value`,`type`) values (?,?,?,?)", [kat, key, value, type], (err) => {
|
||||
console.log("inserted", err);
|
||||
read().then(() => {
|
||||
if (cb) cb();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ const _opts = {
|
||||
showTypes: { type: "boolean", stdval: false },
|
||||
showHidden: { type: "boolean", stdval: false }
|
||||
};
|
||||
const _debug = true;
|
||||
const _debug = false;
|
||||
|
||||
module.exports = bot => {
|
||||
bot._trigger.set("cfg", {
|
||||
@ -15,7 +15,8 @@ module.exports = bot => {
|
||||
clients: ["irc"],
|
||||
f: e => {
|
||||
let args = e.message.substring(5);
|
||||
let opts = {}; // clone
|
||||
let opts = {};
|
||||
let value = null;
|
||||
|
||||
if (args.includes("{") && args.includes(":") && args.charAt(args.length - 1) === "}") { // check if options available
|
||||
try {
|
||||
@ -33,11 +34,20 @@ module.exports = bot => {
|
||||
if (typeof opts[_opt] !== _opts[_opt].type)
|
||||
opts[_opt] = _opts[_opt].stdval;
|
||||
|
||||
if(_debug) e.reply(`opts: ${JSON.stringify(opts)}`);
|
||||
if(_debug)
|
||||
e.reply(`opts: ${JSON.stringify(opts)}`);
|
||||
|
||||
args = args.trim().split(" ");
|
||||
let mode = args.shift();
|
||||
|
||||
if (mode === "set" && e.message.includes("=")) { // get value if mode = set
|
||||
args = args.join(" "); // omg
|
||||
value = args.replace(/.*=(.*?)/, "$1").trim();
|
||||
args = args.replace(/(.*?)=.*/, "$1").trim().split(" ");
|
||||
|
||||
e.reply(`value: ${value}, rest: ${args}`);
|
||||
}
|
||||
|
||||
if (mode === "opts") // maybe replaced by switch in the future
|
||||
return e.reply(`options: ${Object.keys(_opts).map(el => `[b]${el}[/b]: [i]${_opts[el].stdval} (${_opts[el].type})[/i]`).join(", ")}`)
|
||||
|
||||
@ -58,11 +68,28 @@ module.exports = bot => {
|
||||
return e.reply(`keys in class [b]${cfgstr[0]}[/b]: ${keys.public.length > 0 ? keys.public.map(el => `${el}${opts.showTypes ? ` [i](${cfg[cfgstr[0]][el].type})[/i]` : ""}`).join(", ") : "none"} (${keys.hidden.length} hidden)`);
|
||||
}
|
||||
|
||||
if (!opts.showHidden)
|
||||
if (cfg[cfgstr[0]][cfgstr[1]].hidden || opts.showHidden) // catch hidden key
|
||||
return e.reply(`key [b]${cfgstr[1]}[/b] in class [b]${cfgstr[0]}[/b] is hidden, kek`);
|
||||
if(mode === "get") {
|
||||
if (!opts.showHidden)
|
||||
if (cfg[cfgstr[0]][cfgstr[1]].hidden || opts.showHidden) // catch hidden key
|
||||
return e.reply(`key [b]${cfgstr[1]}[/b] in class [b]${cfgstr[0]}[/b] is hidden, kek`);
|
||||
}
|
||||
|
||||
e.reply(cfg[cfgstr[0]][cfgstr[1]].val);
|
||||
switch (mode) {
|
||||
case "get":
|
||||
e.reply(cfg[cfgstr[0]][cfgstr[1]].val);
|
||||
break;
|
||||
case "set":
|
||||
if (cfg[cfgstr[0]][cfgstr[1]].type === "json")
|
||||
return e.reply("JSON isn't supported yet");
|
||||
if(value === null)
|
||||
return e.reply("Error");
|
||||
|
||||
write(cfgstr[0], cfgstr[1], value, cfg[cfgstr[0]][cfgstr[1]].type, () => {
|
||||
e.reply(cfg[cfgstr[0]][cfgstr[1]].val);
|
||||
})
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -1,6 +1,7 @@
|
||||
const request = require("request");
|
||||
const request = require("request")
|
||||
, fs = require("fs");
|
||||
|
||||
const maxoutput = 400;
|
||||
const maxoutput = 500;
|
||||
|
||||
const hsimports = [
|
||||
"Control.Applicative", "Control.Arrow", "Control.Monad",
|
||||
@ -12,6 +13,7 @@ const hsimports = [
|
||||
].map(imp => { return `import qualified ${imp}`; }).join("\r\n");
|
||||
|
||||
function sandbox(lang, code) {
|
||||
console.log(`${ __dirname }/../../../../neofetch`);
|
||||
const langs = {
|
||||
cpp: {
|
||||
"LanguageChoice": "7",
|
||||
@ -48,6 +50,18 @@ function sandbox(lang, code) {
|
||||
"Program": code,
|
||||
"Input": "",
|
||||
"CompilerArgs": ""
|
||||
},
|
||||
bash: {
|
||||
"LanguageChoice": "38",
|
||||
"Program": "#!/bin/bash\r\n" + code,
|
||||
"Input": "",
|
||||
"CompilerArgs": ""
|
||||
},
|
||||
neofetch: {
|
||||
"LanguageChoice": "38",
|
||||
"Program": fs.readFileSync(`${__dirname}/../../../../neofetch`, "utf8"),
|
||||
"Input": "",
|
||||
"CompilerArgs": ""
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -31,7 +31,7 @@ module.exports = bot => {
|
||||
});
|
||||
|
||||
bot._trigger.set("sandbox", {
|
||||
call: /^\!(hs|py|cpp|bf|php|lua) .*/i,
|
||||
call: /^\!(hs|py|cpp|bf|php|lua|bash) .*/i,
|
||||
level: 100,
|
||||
active: true,
|
||||
clients: ["irc", "tg"],
|
||||
|
@ -1,11 +1,14 @@
|
||||
import sql from "../sql.js";
|
||||
|
||||
const sfu = require("string-form-utils");
|
||||
|
||||
const data = {
|
||||
yiff: [],
|
||||
kill_templates: [],
|
||||
kill_parts: {},
|
||||
genders: [],
|
||||
woahs: []
|
||||
woahs: [],
|
||||
slap: []
|
||||
};
|
||||
|
||||
Object.keys(data).forEach(cur => {
|
||||
@ -78,6 +81,7 @@ module.exports = bot => {
|
||||
|
||||
e.replyAction(data.yiff[~~(Math.random() * data.yiff.length)]
|
||||
.replace("{user}", `[b]${args[0]}[/b]`)
|
||||
.replace("{yiffer}", `[b]${e.user.nick}[/b]`)
|
||||
);
|
||||
}
|
||||
});
|
||||
@ -204,7 +208,7 @@ module.exports = bot => {
|
||||
bot._trigger.set("meme", {
|
||||
call: /^(.|\/)meme .*/i,
|
||||
level: 0,
|
||||
active: false,
|
||||
active: true,
|
||||
clients: ["irc", "tg"],
|
||||
f: e => {
|
||||
const args = e.message.trim().substring(6).split("/");
|
||||
@ -213,4 +217,30 @@ module.exports = bot => {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
bot._trigger.set("slap", {
|
||||
call: /^(.|\/)slap/i,
|
||||
level: 0,
|
||||
active: true,
|
||||
clients: ["irc", "tg"],
|
||||
f: e => {
|
||||
let args = e.message.trim().split(" ");
|
||||
args.shift();
|
||||
args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0];
|
||||
e.replyAction(data.slap[~~(Math.random() * data.slap.length)]
|
||||
.replace("{user}", `[b]${args[0]}[/b]`)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
bot._trigger.set("fw", {
|
||||
call: /^(.|\/)fw .*/i,
|
||||
level: 0,
|
||||
active: true,
|
||||
clients: ["irc", "tg"],
|
||||
f: e => {
|
||||
const args = e.message.substring(4).trim();
|
||||
e.reply(sfu.transformToFullwidth(args.toUpperCase()));
|
||||
}
|
||||
});
|
||||
};
|
4747
src/neofetch
Normal file
4747
src/neofetch
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user