hastebins unreliable
This commit is contained in:
parent
96caf323ea
commit
fe2e6562ee
3 changed files with 38 additions and 15 deletions
|
@ -6,8 +6,6 @@ const child_process = require("child_process");
|
||||||
const {inspect} = require("util");
|
const {inspect} = require("util");
|
||||||
const {resolve} = require("path");
|
const {resolve} = require("path");
|
||||||
|
|
||||||
const {hastebin} = require("../lib/utils.js");
|
|
||||||
|
|
||||||
const guildSettings = require("../lib/guildSettings.js");
|
const guildSettings = require("../lib/guildSettings.js");
|
||||||
|
|
||||||
function spawn(args) {
|
function spawn(args) {
|
||||||
|
@ -107,8 +105,15 @@ _eval.callback = async function (msg, line) {
|
||||||
return ":warning: Output (errored):\n```js\n" + out + "\n```";
|
return ":warning: Output (errored):\n```js\n" + out + "\n```";
|
||||||
} else {
|
} else {
|
||||||
if (out.toString().length > 1980) {
|
if (out.toString().length > 1980) {
|
||||||
const haste = await hastebin(out.toString());
|
return {
|
||||||
return `\u2705 Output too long to send in a message: ${haste}`;
|
content: `\u2705 Output too long to send in a message:`,
|
||||||
|
attachments: [
|
||||||
|
{
|
||||||
|
file: out,
|
||||||
|
filename: "message.txt",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
return "\u2705 Output:\n```js\n" + out + "\n```";
|
return "\u2705 Output:\n```js\n" + out + "\n```";
|
||||||
}
|
}
|
||||||
|
@ -135,9 +140,14 @@ exec.callback = async function (msg, line) {
|
||||||
code != 0 ? "\x1b[31m" : ""
|
code != 0 ? "\x1b[31m" : ""
|
||||||
}Exited with ${code}\x1b[0m`;
|
}Exited with ${code}\x1b[0m`;
|
||||||
if (out.length > 1980) {
|
if (out.length > 1980) {
|
||||||
const haste = await hastebin(out);
|
|
||||||
msg.channel.createMessage({
|
msg.channel.createMessage({
|
||||||
content: `Output too long to send in a message: ${haste}`,
|
content: `Output too long to send in a message:`,
|
||||||
|
attachments: [
|
||||||
|
{
|
||||||
|
file: out,
|
||||||
|
filename: "message.txt",
|
||||||
|
},
|
||||||
|
],
|
||||||
allowedMentions: {
|
allowedMentions: {
|
||||||
repliedUser: false,
|
repliedUser: false,
|
||||||
},
|
},
|
||||||
|
|
|
@ -9,7 +9,6 @@ const {librex} = require("../../config.json");
|
||||||
const {getOption} = require("../lib/interactionDispatcher.js");
|
const {getOption} = require("../lib/interactionDispatcher.js");
|
||||||
const {
|
const {
|
||||||
formatTime,
|
formatTime,
|
||||||
hastebin,
|
|
||||||
parseHtmlEntities,
|
parseHtmlEntities,
|
||||||
formatUsername,
|
formatUsername,
|
||||||
safeString,
|
safeString,
|
||||||
|
@ -177,15 +176,22 @@ wolfram.callback = async function (msg, line, args, {verbose, v}) {
|
||||||
if (data[1].subpods[0].plaintext.length > 0)
|
if (data[1].subpods[0].plaintext.length > 0)
|
||||||
string = safeString(data[1].subpods[0].plaintext);
|
string = safeString(data[1].subpods[0].plaintext);
|
||||||
|
|
||||||
if (string.length > 2000 - (6 + safeString(query).length))
|
let text;
|
||||||
string = "Output too long: " + (await hastebin(string));
|
if (string.length > 2000 - (6 + safeString(query).length)) text = string;
|
||||||
|
string = "Output too long:";
|
||||||
|
|
||||||
return {
|
return {
|
||||||
content: `\`${safeString(query)}\` -> ${string.length > 0 ? string : ""}`,
|
content: `\`${safeString(query)}\` -> ${string.length > 0 ? string : ""}`,
|
||||||
file: image && {
|
attachments: [
|
||||||
file: image,
|
text && {
|
||||||
name: "wolfram_output.gif",
|
file: text,
|
||||||
},
|
filename: "message.txt",
|
||||||
|
},
|
||||||
|
image && {
|
||||||
|
file: image,
|
||||||
|
filename: "wolfram_output.gif",
|
||||||
|
},
|
||||||
|
].filter((x) => !!x),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,7 +10,6 @@ const {Constants, VoiceChannel} = require("@projectdysnomia/dysnomia");
|
||||||
const {getOption} = require("../lib/interactionDispatcher.js");
|
const {getOption} = require("../lib/interactionDispatcher.js");
|
||||||
const {
|
const {
|
||||||
formatTime,
|
formatTime,
|
||||||
hastebin,
|
|
||||||
lookupUser,
|
lookupUser,
|
||||||
formatUsername,
|
formatUsername,
|
||||||
safeString,
|
safeString,
|
||||||
|
@ -1291,7 +1290,15 @@ charinfo.callback = async function (msg, line) {
|
||||||
.join("\n");
|
.join("\n");
|
||||||
|
|
||||||
if (lines.length > 2000) {
|
if (lines.length > 2000) {
|
||||||
return "Output too long: " + (await hastebin(lines));
|
return {
|
||||||
|
content: "Output too long:",
|
||||||
|
attachments: [
|
||||||
|
{
|
||||||
|
file: lines,
|
||||||
|
filename: "message.txt",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue