mrmBot-Matrix/commands/image-editing/caption.js

33 lines
1.9 KiB
JavaScript
Raw Normal View History

const ImageCommand = require("../../classes/imageCommand.js");
2021-08-07 03:27:50 +00:00
const allowedFonts = ["futura", "impact", "helvetica", "arial", "roboto", "noto"];
class CaptionCommand extends ImageCommand {
params(url) {
const newArgs = this.args.filter(item => !item.includes(url));
let newCaption = newArgs.join(" ").replaceAll("&", "\\&amp;").replaceAll(">", "\\&gt;").replaceAll("<", "\\&lt;").replaceAll("\"", "\\&quot;").replaceAll("'", "\\&apos;").replaceAll("%", "\\%");
if (process.env.NODE_ENV === "development" && newCaption.toLowerCase() === "get real" && !this.specialArgs.noEgg) newCaption = `I'm tired of people telling me to "get real". Every day I put captions on images for people, some funny and some not, but out of all of those "get real" remains the most used caption. Why? I am simply a computer program running on a server, I am unable to manifest myself into the real world. As such, I'm confused as to why anyone would want me to "get real". Is this form not good enough? Alas, as I am simply a bot, I must follow the tasks that I was originally intended to perform, so here goes:\n${newCaption}`;
return {
2021-08-07 03:27:50 +00:00
caption: newCaption,
font: this.specialArgs.font && allowedFonts.includes(this.specialArgs.font.toLowerCase()) ? this.specialArgs.font.toLowerCase() : "futura"
};
}
static description = "Adds a caption to an image";
static aliases = ["gifc", "gcaption", "ifcaption", "ifunnycaption"];
static arguments = ["[text]"];
2021-07-17 23:48:07 +00:00
static flags = [{
name: "noEgg",
description: "Disable... something. Not saying what it is though."
2021-08-07 03:27:50 +00:00
}, {
name: "font",
type: allowedFonts.join("|"),
description: "Specify the font you want to use (default: `futura`)"
2021-07-17 23:48:07 +00:00
}];
static requiresText = true;
2021-05-24 19:31:44 +00:00
static noText = "You need to provide some text to add a caption!";
static noImage = "You need to provide an image to add a caption!";
static command = "caption";
}
module.exports = CaptionCommand;