Completely rewrote meme, removed old help page

This commit is contained in:
TheEssem 2020-01-27 15:27:33 -06:00
parent 318c30846d
commit f2bf5297a8
3 changed files with 44 additions and 127 deletions

View file

@ -1,98 +0,0 @@
head
title esmBot Command List
meta(name='viewport' content='width=device-width, initial-scale=1')
meta(name='description' content='The command list for esmBot')
meta(property='og:title' content='esmBot Command List')
meta(property='og:site_name' content='esmBot')
meta(property='og:url' content='https://projectlounge.pw/esmBot/help.html')
meta(property='og:description' content='This is the command list for esmBot.')
meta(property='og:type' content='object')
meta(property='og:image' content='https://raw.githubusercontent.com/TheEssem/esmBot/master/esmbot.png')
meta(charset='UTF-8')
link(rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/2.10.0/github-markdown.min.css')
style.
.markdown-body {
box-sizing: border-box;
min-width: 200px;
max-width: 980px;
margin: 0 auto;
padding: 45px;
}
@media (max-width: 767px) {
.markdown-body {
padding: 15px;
}
}
body
article#markdown.markdown-body
h1#img-srchttpsrawgithubusercontentcomtheessemesmbotmasteresmbotpng-width64-esmbot-dev-command-list
img(src='https://raw.githubusercontent.com/TheEssem/esmBot/master/esmbot.png' width='64')
| esmBot Command List
if dev
p
strong
| You are currently using esmBot Dev! Things may change at any time without warning and there will be bugs. Many bugs. If you find one,
a(href='https://github.com/TheEssem/esmBot/issues') report it here
| or in the esmBot Support server.
p
code []
| means an argument is required,
code {}
| means an argument is optional.
p
| Default prefix is
code &
| .
blockquote
p
| Tip: You can get more info about a command by using
code help [command]
| .
h2#table-of-contents Table of Contents
ul
li
a(href='#general')
strong General
li
a(href='#moderation')
strong Moderation
li
a(href='#tags')
strong Tags
li
a(href='#fun')
strong Fun
li
a(href='#images')
strong Image Editing
li
a(href='#soundboard')
strong Soundboard
h2(id='general') 💻 General
each command in commands.general
ul
li!= command
h2(id='moderation') 🔨 Moderation
each command in commands.moderation
ul
li!= command
h2(id='tags') 🏷️ Tags
blockquote
p Every command in this category is a subcommand of the tag command.
each command in commands.tags
ul
li!= command
h2(id='fun') 👌 Fun
each command in commands.fun
ul
li!= command
h2(id='images') 🖼️ Image Editing
blockquote
p These commands support the PNG, JPEG, and WEBP formats.
each command in commands.images
ul
li!= command
h2(id='soundboard') 🔊 Soundboard
each command in commands.soundboard
ul
li!= command

View file

@ -1,30 +1,33 @@
const { spawn } = require("child_process");
const gm = require("gm").subClass({
imageMagick: true
});
const gmToBuffer = require("../utils/gmbuffer.js");
exports.run = async (message, args) => {
message.channel.sendTyping();
const image = await require("../utils/imagedetect.js")(message);
if (image === undefined) return `${message.author.mention}, you need to provide an image to generate a meme!`;
if (image.type === "gif") return `${message.author.mention}, this command doesn't work with GIFs!`;
if (args.length === 0) return `${message.author.mention}, you need to provide some text to generate a meme!`;
const [topText, bottomText] = args.join(" ").split(",").map(elem => elem.trim());
const child = spawn("./utils/meme.sh", [topText.toUpperCase().replace(/\\/g, "\\\\"), bottomText ? bottomText.toUpperCase().replace(/\\/g, "\\\\") : ""]);
child.stdin.write(image.data);
child.stdin.end();
const chunks = [];
child.stdout.on("data", (data) => {
chunks.push(data);
});
child.once("error", (error) => {
const file = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
const file2 = `/tmp/${Math.random().toString(36).substring(2, 15)}.png`;
const file3 = `/tmp/${Math.random().toString(36).substring(2, 15)}.png`;
gm(image.data).resize(600, 600).noProfile().write(file, (error) => {
if (error) throw error;
});
child.stderr.once("data", (error) => {
if (error) throw new Error(error.toString());
});
child.stdout.once("close", () => {
const data = Buffer.concat(chunks);
return message.channel.createMessage("", {
file: data,
name: "meme.png"
gm(file).size((error, size) => {
if (error) throw error;
gm().out("-size", size.width).background("none").gravity("Center").out("(", "(").font("Impact").out("-pointsize", 40).out(`pango:<span foreground='white'>${topText.toUpperCase()}</span>`).out(")", "(", "+clone").out("-channel", "A").out("-morphology", "EdgeOut", "Octagon", "+channel", "+level-colors", "black", ")").compose("DstOver").out(")", "-composite").write(file2, (error) => {
if (error) throw error;
gm().out("-size", size.width).background("none").gravity("Center").out("(", "(").font("Impact").out("-pointsize", 40).out(`pango:<span foreground='white'>${bottomText ? bottomText.toUpperCase() : " "}</span>`).out(")", "(", "+clone").out("-channel", "A").out("-morphology", "EdgeOut", "Octagon", "+channel", "+level-colors", "black", ")").compose("DstOver").out(")", "-composite").write(file3, async (error) => {
if (error) throw error;
const data = gm(file).coalesce().out("null:").gravity("North").out(file2).out("-layers", "composite").out("null:").gravity("South").out(file3).out("-layers", "composite").out("-layers", "optimize");
const resultBuffer = await gmToBuffer(data);
return message.channel.createMessage("", {
file: resultBuffer,
name: `meme.${image.type}`
});
});
});
});
});
};

View file

@ -1,12 +1,24 @@
file=$(mktemp /tmp/XXXXXXXXXXXXXXXXXXXXXX.png)
newfile=$(mktemp /tmp/XXXXXXXXXXXXXXXXXXXXXX.png)
convert - -resize 600x600 +profile "*" $newfile
SIZE=$(identify -format "%[fx:w]x%[fx:h]" $newfile)
convert $newfile \
-gravity north \
\( -size $SIZE -background none -font "./assets/ImpactMix.ttf" -pointsize 50 -stroke black -strokewidth 3 caption:"$1" \) -composite \
\( -size $SIZE -background none -font "./assets/ImpactMix.ttf" -pointsize 50 -fill white -stroke none caption:"$1" \) -composite \
-gravity south \
\( -size $SIZE -background none -font "./assets/ImpactMix.ttf" -pointsize 50 -stroke black -strokewidth 3 caption:"$2" \) -composite \
\( -size $SIZE -background none -font "./assets/ImpactMix.ttf" -pointsize 50 -fill white -stroke none caption:"$2" \) -composite\
-
newfile2=$(mktemp /tmp/XXXXXXXXXXXXXXXXXXXXXX.png)
convert - -resize 600x600 +profile "*" $file
SIZE=$(identify -format "%[fx:w]" $file)
convert \
-size $SIZE -background none -gravity center \
\( \( -font Impact -pointsize 40 pango:"<span foreground='white'>$1</span>" \) \
\( +clone -channel A -morphology EdgeOut Octagon +channel +level-colors black \) -compose DstOver \) -composite \
$newfile
if ! [ -z "$2" ]
then
convert \
-size $SIZE -background none -gravity center \
\( \( -font Impact -pointsize 40 pango:"<span foreground='white'>$2</span>" \) \
\( +clone -channel A -morphology EdgeOut Octagon +channel +level-colors black \) -compose DstOver \) -composite \
$newfile2
convert $file -coalesce null: -gravity north $newfile -layers composite null: -gravity south $newfile2 -layers composite -layers optimize -
exit 0
fi
convert $file -coalesce null: -gravity north $newfile -layers composite -layers optimize -
rm $file
rm $newfile
rm $newfile2