hastebins unreliable

This commit is contained in:
Cynthia Foxwell 2024-06-01 13:53:51 -06:00
parent 96caf323ea
commit fe2e6562ee
3 changed files with 38 additions and 15 deletions

View file

@ -6,8 +6,6 @@ const child_process = require("child_process");
const {inspect} = require("util");
const {resolve} = require("path");
const {hastebin} = require("../lib/utils.js");
const guildSettings = require("../lib/guildSettings.js");
function spawn(args) {
@ -107,8 +105,15 @@ _eval.callback = async function (msg, line) {
return ":warning: Output (errored):\n```js\n" + out + "\n```";
} else {
if (out.toString().length > 1980) {
const haste = await hastebin(out.toString());
return `\u2705 Output too long to send in a message: ${haste}`;
return {
content: `\u2705 Output too long to send in a message:`,
attachments: [
{
file: out,
filename: "message.txt",
},
],
};
} else {
return "\u2705 Output:\n```js\n" + out + "\n```";
}
@ -135,9 +140,14 @@ exec.callback = async function (msg, line) {
code != 0 ? "\x1b[31m" : ""
}Exited with ${code}\x1b[0m`;
if (out.length > 1980) {
const haste = await hastebin(out);
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: {
repliedUser: false,
},

View file

@ -9,7 +9,6 @@ const {librex} = require("../../config.json");
const {getOption} = require("../lib/interactionDispatcher.js");
const {
formatTime,
hastebin,
parseHtmlEntities,
formatUsername,
safeString,
@ -177,15 +176,22 @@ wolfram.callback = async function (msg, line, args, {verbose, v}) {
if (data[1].subpods[0].plaintext.length > 0)
string = safeString(data[1].subpods[0].plaintext);
if (string.length > 2000 - (6 + safeString(query).length))
string = "Output too long: " + (await hastebin(string));
let text;
if (string.length > 2000 - (6 + safeString(query).length)) text = string;
string = "Output too long:";
return {
content: `\`${safeString(query)}\` -> ${string.length > 0 ? string : ""}`,
file: image && {
file: image,
name: "wolfram_output.gif",
attachments: [
text && {
file: text,
filename: "message.txt",
},
image && {
file: image,
filename: "wolfram_output.gif",
},
].filter((x) => !!x),
};
}
};

View file

@ -10,7 +10,6 @@ const {Constants, VoiceChannel} = require("@projectdysnomia/dysnomia");
const {getOption} = require("../lib/interactionDispatcher.js");
const {
formatTime,
hastebin,
lookupUser,
formatUsername,
safeString,
@ -1291,7 +1290,15 @@ charinfo.callback = async function (msg, line) {
.join("\n");
if (lines.length > 2000) {
return "Output too long: " + (await hastebin(lines));
return {
content: "Output too long:",
attachments: [
{
file: lines,
filename: "message.txt",
},
],
};
} else {
return lines;
}