misc.wolfram: Upload image, haste fallback for long results
This commit is contained in:
parent
c0223017bc
commit
0218f0f0e0
1 changed files with 24 additions and 6 deletions
|
@ -2,7 +2,7 @@ const Command = require("../lib/command.js");
|
||||||
const CATEGORY = "misc";
|
const CATEGORY = "misc";
|
||||||
|
|
||||||
const fetch = require("node-fetch");
|
const fetch = require("node-fetch");
|
||||||
const {safeString, parseHtmlEntities} = require("../lib/utils.js");
|
const {hastebin, safeString, parseHtmlEntities} = require("../lib/utils.js");
|
||||||
|
|
||||||
const yt = new Command("youtube");
|
const yt = new Command("youtube");
|
||||||
yt.addAlias("yt");
|
yt.addAlias("yt");
|
||||||
|
@ -118,11 +118,29 @@ wolfram.callback = async function (msg, line) {
|
||||||
|
|
||||||
return {embed};
|
return {embed};
|
||||||
} else {
|
} else {
|
||||||
return `\`${safeString(line)}\` -> ${
|
let image;
|
||||||
data[1].subpods[0].plaintext.length > 0
|
|
||||||
? safeString(data[1].subpods[0].plaintext)
|
if (data[1].subpods[0].img.src)
|
||||||
: data[1].subpods[0].img.src
|
image = Buffer.from(
|
||||||
}`;
|
await fetch(data[1].subpods[0].img.src).then((x) => x.arrayBuffer())
|
||||||
|
);
|
||||||
|
|
||||||
|
let string = "";
|
||||||
|
if (data[1].subpods[0].plaintext.length > 0)
|
||||||
|
string = safeString(data[1].subpods[0].plaintext);
|
||||||
|
|
||||||
|
if (string.length > 2000 - (6 + safeString(line).length))
|
||||||
|
string =
|
||||||
|
`Output too long: ${hf.config.haste_provider}/` +
|
||||||
|
(await hastebin(string));
|
||||||
|
|
||||||
|
return {
|
||||||
|
content: `\`${safeString(line)}\` -> ${string.length > 0 ? string : ""}`,
|
||||||
|
file: image && {
|
||||||
|
file: image,
|
||||||
|
name: "wolfram_output.gif",
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
hf.registerCommand(wolfram);
|
hf.registerCommand(wolfram);
|
||||||
|
|
Loading…
Reference in a new issue