Catch image load warnings, set message limit to 50, don't crash the bot if .git is missing
This commit is contained in:
parent
ab3ae7b9c6
commit
f5a0fa5f7c
39 changed files with 305 additions and 50 deletions
3
app.js
3
app.js
|
@ -45,7 +45,7 @@ k <BBBw BBBBEBBBBBBBBBBBBBBBBBQ4BM #
|
|||
*+, " F'"'*^~~~^"^\` V+*^
|
||||
\`"""
|
||||
|
||||
esmBot ${esmBotVersion} (${(await exec("git rev-parse HEAD")).stdout.substring(0, 7)}), powered by eris-fleet ${erisFleetVersion}
|
||||
esmBot ${esmBotVersion} (${(await exec("git rev-parse HEAD").catch(() => {})).stdout.substring(0, 7)}), powered by eris-fleet ${erisFleetVersion}
|
||||
`);
|
||||
}
|
||||
|
||||
|
@ -89,6 +89,7 @@ const Admiral = new Fleet({
|
|||
repliedUser: true
|
||||
},
|
||||
guildSubscriptions: false,
|
||||
messageLimit: 50,
|
||||
intents: [
|
||||
"guilds",
|
||||
"guildVoiceStates",
|
||||
|
|
|
@ -122,8 +122,6 @@ export default async (client, cluster, worker, ipc, message) => {
|
|||
case 3:
|
||||
fileSize = 104856616;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (result.file.length > fileSize) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <Magick++.h>
|
||||
#include <napi.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
|
@ -21,7 +22,13 @@ Napi::Value Blur(const Napi::CallbackInfo &info) {
|
|||
|
||||
list<Image> frames;
|
||||
list<Image> coalesced;
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
try {
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
} catch (Magick::WarningCoder &warning) {
|
||||
cerr << "Coder Warning: " << warning.what() << endl;
|
||||
} catch (Magick::Warning &warning) {
|
||||
cerr << "Warning: " << warning.what() << endl;
|
||||
}
|
||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||
|
||||
if (sharp) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <Magick++.h>
|
||||
#include <napi.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
|
@ -23,7 +24,13 @@ Napi::Value Blurple(const Napi::CallbackInfo &info) {
|
|||
list<Image> frames;
|
||||
list<Image> coalesced;
|
||||
list<Image> blurpled;
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
try {
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
} catch (Magick::WarningCoder &warning) {
|
||||
cerr << "Coder Warning: " << warning.what() << endl;
|
||||
} catch (Magick::Warning &warning) {
|
||||
cerr << "Warning: " << warning.what() << endl;
|
||||
}
|
||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||
|
||||
for (Image &image : coalesced) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <Magick++.h>
|
||||
#include <napi.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
|
@ -23,7 +24,13 @@ Napi::Value Caption(const Napi::CallbackInfo &info) {
|
|||
list<Image> frames;
|
||||
list<Image> coalesced;
|
||||
list<Image> captioned;
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
try {
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
} catch (Magick::WarningCoder &warning) {
|
||||
cerr << "Coder Warning: " << warning.what() << endl;
|
||||
} catch (Magick::Warning &warning) {
|
||||
cerr << "Warning: " << warning.what() << endl;
|
||||
}
|
||||
|
||||
size_t width = frames.front().baseColumns();
|
||||
string query(to_string(width - ((width / 25) * 2)) + "x");
|
||||
|
@ -32,7 +39,10 @@ Napi::Value Caption(const Napi::CallbackInfo &info) {
|
|||
caption_image.alpha(true);
|
||||
caption_image.fontPointsize(width / 13);
|
||||
caption_image.textGravity(Magick::CenterGravity);
|
||||
caption_image.read("pango:<span font_family=\"" + (font == "roboto" ? "Roboto Condensed" : font) + "\" weight=\"" + (font != "impact" ? "bold" : "normal") + "\">" + caption + "</span>");
|
||||
caption_image.read("pango:<span font_family=\"" +
|
||||
(font == "roboto" ? "Roboto Condensed" : font) +
|
||||
"\" weight=\"" + (font != "impact" ? "bold" : "normal") +
|
||||
"\">" + caption + "</span>");
|
||||
caption_image.extent(Geometry(width, caption_image.rows() + (width / 13)),
|
||||
Magick::CenterGravity);
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <Magick++.h>
|
||||
#include <napi.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
|
@ -24,7 +25,13 @@ Napi::Value CaptionTwo(const Napi::CallbackInfo &info) {
|
|||
list<Image> coalesced;
|
||||
list<Image> captioned;
|
||||
Blob caption_blob;
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
try {
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
} catch (Magick::WarningCoder &warning) {
|
||||
cerr << "Coder Warning: " << warning.what() << endl;
|
||||
} catch (Magick::Warning &warning) {
|
||||
cerr << "Warning: " << warning.what() << endl;
|
||||
}
|
||||
|
||||
size_t width = frames.front().baseColumns();
|
||||
string query(to_string(width - ((width / 25) * 2)) + "x");
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <Magick++.h>
|
||||
#include <napi.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
|
@ -21,7 +22,13 @@ Napi::Value Circle(const Napi::CallbackInfo &info) {
|
|||
list<Image> frames;
|
||||
list<Image> coalesced;
|
||||
list<Image> blurred;
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
try {
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
} catch (Magick::WarningCoder &warning) {
|
||||
cerr << "Coder Warning: " << warning.what() << endl;
|
||||
} catch (Magick::Warning &warning) {
|
||||
cerr << "Warning: " << warning.what() << endl;
|
||||
}
|
||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||
|
||||
for (Image &image : coalesced) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <Magick++.h>
|
||||
#include <napi.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
|
@ -21,7 +22,13 @@ Napi::Value Crop(const Napi::CallbackInfo &info) {
|
|||
list<Image> frames;
|
||||
list<Image> coalesced;
|
||||
list<Image> mid;
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
try {
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
} catch (Magick::WarningCoder &warning) {
|
||||
cerr << "Coder Warning: " << warning.what() << endl;
|
||||
} catch (Magick::Warning &warning) {
|
||||
cerr << "Warning: " << warning.what() << endl;
|
||||
}
|
||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||
|
||||
for (Image &image : coalesced) {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include <Magick++.h>
|
||||
#include <napi.h>
|
||||
|
||||
#include <list>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
using namespace Magick;
|
||||
|
@ -22,7 +22,13 @@ Napi::Value Deepfry(const Napi::CallbackInfo &info) {
|
|||
list<Image> frames;
|
||||
list<Image> coalesced;
|
||||
list<Image> blurred;
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
try {
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
} catch (Magick::WarningCoder &warning) {
|
||||
cerr << "Coder Warning: " << warning.what() << endl;
|
||||
} catch (Magick::Warning &warning) {
|
||||
cerr << "Warning: " << warning.what() << endl;
|
||||
}
|
||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||
|
||||
for (Image &image : coalesced) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <Magick++.h>
|
||||
#include <napi.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
|
@ -22,7 +23,13 @@ Napi::Value Explode(const Napi::CallbackInfo &info) {
|
|||
list<Image> frames;
|
||||
list<Image> coalesced;
|
||||
list<Image> blurred;
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
try {
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
} catch (Magick::WarningCoder &warning) {
|
||||
cerr << "Coder Warning: " << warning.what() << endl;
|
||||
} catch (Magick::Warning &warning) {
|
||||
cerr << "Warning: " << warning.what() << endl;
|
||||
}
|
||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||
|
||||
for (Image &image : coalesced) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <Magick++.h>
|
||||
#include <napi.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
|
@ -23,7 +24,13 @@ Napi::Value Flag(const Napi::CallbackInfo &info) {
|
|||
list<Image> coalesced;
|
||||
list<Image> mid;
|
||||
Image watermark;
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
try {
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
} catch (Magick::WarningCoder &warning) {
|
||||
cerr << "Coder Warning: " << warning.what() << endl;
|
||||
} catch (Magick::Warning &warning) {
|
||||
cerr << "Warning: " << warning.what() << endl;
|
||||
}
|
||||
watermark.read(overlay);
|
||||
watermark.alphaChannel(Magick::SetAlphaChannel);
|
||||
watermark.evaluate(Magick::AlphaChannel, Magick::MultiplyEvaluateOperator,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <Magick++.h>
|
||||
#include <napi.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
|
@ -23,7 +24,13 @@ Napi::Value Flip(const Napi::CallbackInfo &info) {
|
|||
list<Image> frames;
|
||||
list<Image> coalesced;
|
||||
list<Image> mid;
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
try {
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
} catch (Magick::WarningCoder &warning) {
|
||||
cerr << "Coder Warning: " << warning.what() << endl;
|
||||
} catch (Magick::Warning &warning) {
|
||||
cerr << "Warning: " << warning.what() << endl;
|
||||
}
|
||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||
|
||||
for (Image &image : coalesced) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <Magick++.h>
|
||||
#include <napi.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
|
@ -56,7 +57,13 @@ Napi::Value Freeze(const Napi::CallbackInfo &info) {
|
|||
Blob blob;
|
||||
|
||||
list<Image> frames;
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
try {
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
} catch (Magick::WarningCoder &warning) {
|
||||
cerr << "Coder Warning: " << warning.what() << endl;
|
||||
} catch (Magick::Warning &warning) {
|
||||
cerr << "Warning: " << warning.what() << endl;
|
||||
}
|
||||
size_t frameSize = frames.size();
|
||||
int framePos = clamp(frame, 0, (int)frameSize);
|
||||
frames.resize(framePos + 1);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <Magick++.h>
|
||||
#include <napi.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
|
@ -22,7 +23,13 @@ Napi::Value Gamexplain(const Napi::CallbackInfo &info) {
|
|||
list<Image> coalesced;
|
||||
list<Image> mid;
|
||||
Image watermark;
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
try {
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
} catch (Magick::WarningCoder &warning) {
|
||||
cerr << "Coder Warning: " << warning.what() << endl;
|
||||
} catch (Magick::Warning &warning) {
|
||||
cerr << "Warning: " << warning.what() << endl;
|
||||
}
|
||||
watermark.read("./assets/images/gamexplain.png");
|
||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <Magick++.h>
|
||||
#include <napi.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
|
@ -23,7 +24,13 @@ Napi::Value Globe(const Napi::CallbackInfo &info) {
|
|||
list<Image> mid;
|
||||
Image distort;
|
||||
Image overlay;
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
try {
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
} catch (Magick::WarningCoder &warning) {
|
||||
cerr << "Coder Warning: " << warning.what() << endl;
|
||||
} catch (Magick::Warning &warning) {
|
||||
cerr << "Warning: " << warning.what() << endl;
|
||||
}
|
||||
distort.read("./assets/images/spheremap.png");
|
||||
overlay.read("./assets/images/sphere_overlay.png");
|
||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <Magick++.h>
|
||||
#include <napi.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
|
@ -21,7 +22,13 @@ Napi::Value Invert(const Napi::CallbackInfo &info) {
|
|||
list<Image> frames;
|
||||
list<Image> coalesced;
|
||||
list<Image> mid;
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
try {
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
} catch (Magick::WarningCoder &warning) {
|
||||
cerr << "Coder Warning: " << warning.what() << endl;
|
||||
} catch (Magick::Warning &warning) {
|
||||
cerr << "Warning: " << warning.what() << endl;
|
||||
}
|
||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||
|
||||
for_each(coalesced.begin(), coalesced.end(), negateImage());
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <Magick++.h>
|
||||
#include <napi.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
|
@ -24,7 +25,13 @@ Napi::Value Jpeg(const Napi::CallbackInfo &info) {
|
|||
list<Image> frames;
|
||||
list<Image> coalesced;
|
||||
list<Image> jpeged;
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
try {
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
} catch (Magick::WarningCoder &warning) {
|
||||
cerr << "Coder Warning: " << warning.what() << endl;
|
||||
} catch (Magick::Warning &warning) {
|
||||
cerr << "Warning: " << warning.what() << endl;
|
||||
}
|
||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||
|
||||
for (Image &image : coalesced) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <Magick++.h>
|
||||
#include <napi.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
|
@ -22,7 +23,13 @@ Napi::Value Leak(const Napi::CallbackInfo &info) {
|
|||
list<Image> coalesced;
|
||||
list<Image> mid;
|
||||
Image watermark;
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
try {
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
} catch (Magick::WarningCoder &warning) {
|
||||
cerr << "Coder Warning: " << warning.what() << endl;
|
||||
} catch (Magick::Warning &warning) {
|
||||
cerr << "Warning: " << warning.what() << endl;
|
||||
}
|
||||
watermark.read("./assets/images/leak.png");
|
||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <Magick++.h>
|
||||
#include <napi.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
|
@ -21,7 +22,13 @@ Napi::Value Magik(const Napi::CallbackInfo &info) {
|
|||
list<Image> frames;
|
||||
list<Image> coalesced;
|
||||
list<Image> blurred;
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
try {
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
} catch (Magick::WarningCoder &warning) {
|
||||
cerr << "Coder Warning: " << warning.what() << endl;
|
||||
} catch (Magick::Warning &warning) {
|
||||
cerr << "Warning: " << warning.what() << endl;
|
||||
}
|
||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||
|
||||
for (Image &image : coalesced) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <Magick++.h>
|
||||
#include <napi.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
|
@ -25,7 +26,13 @@ Napi::Value Meme(const Napi::CallbackInfo &info) {
|
|||
list<Image> mid;
|
||||
Image top_text;
|
||||
Image bottom_text;
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
try {
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
} catch (Magick::WarningCoder &warning) {
|
||||
cerr << "Coder Warning: " << warning.what() << endl;
|
||||
} catch (Magick::Warning &warning) {
|
||||
cerr << "Warning: " << warning.what() << endl;
|
||||
}
|
||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||
|
||||
int width = coalesced.front().columns();
|
||||
|
@ -42,7 +49,9 @@ Napi::Value Meme(const Napi::CallbackInfo &info) {
|
|||
top_text_fill.morphology(Magick::EdgeOutMorphology, "Octagon");
|
||||
top_text_fill.backgroundColor("black");
|
||||
top_text_fill.alphaChannel(Magick::ShapeAlphaChannel);
|
||||
if (dividedWidth > 1) top_text_fill.morphology(Magick::DilateMorphology, "Octagon", dividedWidth);
|
||||
if (dividedWidth > 1)
|
||||
top_text_fill.morphology(Magick::DilateMorphology, "Octagon",
|
||||
dividedWidth);
|
||||
top_text.composite(top_text_fill, Magick::CenterGravity,
|
||||
Magick::DstOverCompositeOp);
|
||||
|
||||
|
@ -58,7 +67,9 @@ Napi::Value Meme(const Napi::CallbackInfo &info) {
|
|||
bottom_text_fill.morphology(Magick::EdgeOutMorphology, "Octagon");
|
||||
bottom_text_fill.backgroundColor("black");
|
||||
bottom_text_fill.alphaChannel(Magick::ShapeAlphaChannel);
|
||||
if (dividedWidth > 1) bottom_text_fill.morphology(Magick::DilateMorphology, "Octagon", dividedWidth);
|
||||
if (dividedWidth > 1)
|
||||
bottom_text_fill.morphology(Magick::DilateMorphology, "Octagon",
|
||||
dividedWidth);
|
||||
bottom_text.composite(bottom_text_fill, Magick::CenterGravity,
|
||||
Magick::DstOverCompositeOp);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <Magick++.h>
|
||||
#include <napi.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
|
@ -27,7 +28,13 @@ Napi::Value Mirror(const Napi::CallbackInfo &info) {
|
|||
list<Image> coalesced;
|
||||
list<Image> mid;
|
||||
MagickCore::GravityType gravity;
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
try {
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
} catch (Magick::WarningCoder &warning) {
|
||||
cerr << "Coder Warning: " << warning.what() << endl;
|
||||
} catch (Magick::Warning &warning) {
|
||||
cerr << "Warning: " << warning.what() << endl;
|
||||
}
|
||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||
|
||||
if (vertical && first) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <Magick++.h>
|
||||
#include <napi.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
|
@ -25,7 +26,13 @@ Napi::Value Motivate(const Napi::CallbackInfo &info) {
|
|||
list<Image> mid;
|
||||
Image top;
|
||||
Image bottom;
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
try {
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
} catch (Magick::WarningCoder &warning) {
|
||||
cerr << "Coder Warning: " << warning.what() << endl;
|
||||
} catch (Magick::Warning &warning) {
|
||||
cerr << "Warning: " << warning.what() << endl;
|
||||
}
|
||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||
|
||||
top.size(Geometry("600"));
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <Magick++.h>
|
||||
#include <napi.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
|
@ -23,7 +24,13 @@ Napi::Value Reddit(const Napi::CallbackInfo &info) {
|
|||
list<Image> mid;
|
||||
Image watermark;
|
||||
Image text_image;
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
try {
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
} catch (Magick::WarningCoder &warning) {
|
||||
cerr << "Coder Warning: " << warning.what() << endl;
|
||||
} catch (Magick::Warning &warning) {
|
||||
cerr << "Warning: " << warning.what() << endl;
|
||||
}
|
||||
|
||||
watermark.read("./assets/images/reddit.png");
|
||||
text_image.textGravity(Magick::WestGravity);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <Magick++.h>
|
||||
#include <napi.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
|
@ -26,7 +27,13 @@ Napi::Value Resize(const Napi::CallbackInfo &info) {
|
|||
list<Image> frames;
|
||||
list<Image> coalesced;
|
||||
list<Image> blurred;
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
try {
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
} catch (Magick::WarningCoder &warning) {
|
||||
cerr << "Coder Warning: " << warning.what() << endl;
|
||||
} catch (Magick::Warning &warning) {
|
||||
cerr << "Warning: " << warning.what() << endl;
|
||||
}
|
||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||
|
||||
for (Image &image : coalesced) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <Magick++.h>
|
||||
#include <napi.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
|
@ -21,7 +22,13 @@ Napi::Value Reverse(const Napi::CallbackInfo &info) {
|
|||
|
||||
list<Image> frames;
|
||||
list<Image> coalesced;
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
try {
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
} catch (Magick::WarningCoder &warning) {
|
||||
cerr << "Coder Warning: " << warning.what() << endl;
|
||||
} catch (Magick::Warning &warning) {
|
||||
cerr << "Warning: " << warning.what() << endl;
|
||||
}
|
||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||
|
||||
if (soos) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <Magick++.h>
|
||||
#include <napi.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
|
@ -22,7 +23,13 @@ Napi::Value Scott(const Napi::CallbackInfo &info) {
|
|||
list<Image> coalesced;
|
||||
list<Image> mid;
|
||||
Image watermark;
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
try {
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
} catch (Magick::WarningCoder &warning) {
|
||||
cerr << "Coder Warning: " << warning.what() << endl;
|
||||
} catch (Magick::Warning &warning) {
|
||||
cerr << "Warning: " << warning.what() << endl;
|
||||
}
|
||||
watermark.read("./assets/images/scott.png");
|
||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <Magick++.h>
|
||||
#include <napi.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
|
@ -13,7 +14,8 @@ Napi::Value Snapchat(const Napi::CallbackInfo &info) {
|
|||
Napi::Object obj = info[0].As<Napi::Object>();
|
||||
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||
string caption = obj.Get("caption").As<Napi::String>().Utf8Value();
|
||||
float pos = obj.Has("pos") ? obj.Get("pos").As<Napi::Number>().FloatValue() : 0.5;
|
||||
float pos =
|
||||
obj.Has("pos") ? obj.Get("pos").As<Napi::Number>().FloatValue() : 0.5;
|
||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||
int delay =
|
||||
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||
|
@ -24,7 +26,13 @@ Napi::Value Snapchat(const Napi::CallbackInfo &info) {
|
|||
list<Image> coalesced;
|
||||
list<Image> captioned;
|
||||
Blob caption_blob;
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
try {
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
} catch (Magick::WarningCoder &warning) {
|
||||
cerr << "Coder Warning: " << warning.what() << endl;
|
||||
} catch (Magick::Warning &warning) {
|
||||
cerr << "Warning: " << warning.what() << endl;
|
||||
}
|
||||
|
||||
size_t width = frames.front().baseColumns();
|
||||
size_t height = frames.front().baseRows();
|
||||
|
@ -44,8 +52,7 @@ Napi::Value Snapchat(const Napi::CallbackInfo &info) {
|
|||
|
||||
for (Image &image : coalesced) {
|
||||
list<Image> images;
|
||||
image.composite(caption_image, 0, height * pos,
|
||||
Magick::OverCompositeOp);
|
||||
image.composite(caption_image, 0, height * pos, Magick::OverCompositeOp);
|
||||
image.magick(type);
|
||||
image.animationDelay(delay == 0 ? image.animationDelay() : delay);
|
||||
captioned.push_back(image);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <Magick++.h>
|
||||
#include <napi.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
|
@ -83,7 +84,13 @@ Napi::Value Speed(const Napi::CallbackInfo &info) {
|
|||
Blob blob;
|
||||
|
||||
list<Image> frames;
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
try {
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
} catch (Magick::WarningCoder &warning) {
|
||||
cerr << "Coder Warning: " << warning.what() << endl;
|
||||
} catch (Magick::Warning &warning) {
|
||||
cerr << "Warning: " << warning.what() << endl;
|
||||
}
|
||||
|
||||
for (list<Image>::iterator i = frames.begin(); i != frames.end(); ++i) {
|
||||
int index = distance(frames.begin(), i);
|
||||
|
@ -126,7 +133,13 @@ Napi::Value Speed(const Napi::CallbackInfo &info) {
|
|||
Blob blob;
|
||||
|
||||
list<Image> frames;
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
try {
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
} catch (Magick::WarningCoder &warning) {
|
||||
cerr << "Coder Warning: " << warning.what() << endl;
|
||||
} catch (Magick::Warning &warning) {
|
||||
cerr << "Warning: " << warning.what() << endl;
|
||||
}
|
||||
|
||||
for (int i = 0; i < speed - 1; ++i) {
|
||||
frames.remove_if([counter = 0](const auto x) mutable {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <Magick++.h>
|
||||
#include <napi.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
|
@ -21,7 +22,13 @@ Napi::Value Spin(const Napi::CallbackInfo &info) {
|
|||
list<Image> frames;
|
||||
list<Image> coalesced;
|
||||
list<Image> mid;
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
try {
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
} catch (Magick::WarningCoder &warning) {
|
||||
cerr << "Coder Warning: " << warning.what() << endl;
|
||||
} catch (Magick::Warning &warning) {
|
||||
cerr << "Warning: " << warning.what() << endl;
|
||||
}
|
||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||
|
||||
if (type != "gif") {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <Magick++.h>
|
||||
#include <napi.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
|
@ -21,7 +22,13 @@ Napi::Value Swirl(const Napi::CallbackInfo &info) {
|
|||
list<Image> frames;
|
||||
list<Image> coalesced;
|
||||
list<Image> mid;
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
try {
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
} catch (Magick::WarningCoder &warning) {
|
||||
cerr << "Coder Warning: " << warning.what() << endl;
|
||||
} catch (Magick::Warning &warning) {
|
||||
cerr << "Warning: " << warning.what() << endl;
|
||||
}
|
||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||
|
||||
for (Image &image : coalesced) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <Magick++.h>
|
||||
#include <napi.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
|
@ -21,7 +22,13 @@ Napi::Value Tile(const Napi::CallbackInfo &info) {
|
|||
list<Image> frames;
|
||||
list<Image> coalesced;
|
||||
list<Image> mid;
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
try {
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
} catch (Magick::WarningCoder &warning) {
|
||||
cerr << "Coder Warning: " << warning.what() << endl;
|
||||
} catch (Magick::Warning &warning) {
|
||||
cerr << "Warning: " << warning.what() << endl;
|
||||
}
|
||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||
|
||||
for (Image &image : coalesced) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <Magick++.h>
|
||||
#include <napi.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
|
@ -22,7 +23,13 @@ Napi::Value Trump(const Napi::CallbackInfo &info) {
|
|||
list<Image> coalesced;
|
||||
list<Image> mid;
|
||||
Image watermark;
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
try {
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
} catch (Magick::WarningCoder &warning) {
|
||||
cerr << "Coder Warning: " << warning.what() << endl;
|
||||
} catch (Magick::Warning &warning) {
|
||||
cerr << "Warning: " << warning.what() << endl;
|
||||
}
|
||||
watermark.read("./assets/images/trump.png");
|
||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <Magick++.h>
|
||||
#include <napi.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
|
@ -21,7 +22,13 @@ Napi::Value Uncaption(const Napi::CallbackInfo &info) {
|
|||
list<Image> frames;
|
||||
list<Image> coalesced;
|
||||
list<Image> mid;
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
try {
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
} catch (Magick::WarningCoder &warning) {
|
||||
cerr << "Coder Warning: " << warning.what() << endl;
|
||||
} catch (Magick::Warning &warning) {
|
||||
cerr << "Warning: " << warning.what() << endl;
|
||||
}
|
||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||
|
||||
Image firstImage = coalesced.front();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <Magick++.h>
|
||||
#include <napi.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
|
@ -21,7 +22,13 @@ Napi::Value Wall(const Napi::CallbackInfo &info) {
|
|||
list<Image> frames;
|
||||
list<Image> coalesced;
|
||||
list<Image> mid;
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
try {
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
} catch (Magick::WarningCoder &warning) {
|
||||
cerr << "Coder Warning: " << warning.what() << endl;
|
||||
} catch (Magick::Warning &warning) {
|
||||
cerr << "Warning: " << warning.what() << endl;
|
||||
}
|
||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||
|
||||
for (Image &image : coalesced) {
|
||||
|
|
|
@ -32,7 +32,13 @@ Napi::Value Watermark(const Napi::CallbackInfo &info) {
|
|||
list<Image> coalesced;
|
||||
list<Image> mid;
|
||||
Image watermark;
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
try {
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
} catch (Magick::WarningCoder &warning) {
|
||||
cerr << "Coder Warning: " << warning.what() << endl;
|
||||
} catch (Magick::Warning &warning) {
|
||||
cerr << "Warning: " << warning.what() << endl;
|
||||
}
|
||||
watermark.read(water);
|
||||
if (resize && append) {
|
||||
string query(to_string(frames.front().baseColumns()) + "x");
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <Magick++.h>
|
||||
#include <napi.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
|
@ -22,7 +23,13 @@ Napi::Value Wdt(const Napi::CallbackInfo &info) {
|
|||
list<Image> coalesced;
|
||||
list<Image> mid;
|
||||
Image watermark;
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
try {
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
} catch (Magick::WarningCoder &warning) {
|
||||
cerr << "Coder Warning: " << warning.what() << endl;
|
||||
} catch (Magick::Warning &warning) {
|
||||
cerr << "Warning: " << warning.what() << endl;
|
||||
}
|
||||
watermark.read("./assets/images/whodidthis.png");
|
||||
coalesceImages(&coalesced, frames.begin(), frames.end());
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <Magick++.h>
|
||||
#include <napi.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
|
@ -23,7 +24,13 @@ Napi::Value Whisper(const Napi::CallbackInfo &info) {
|
|||
list<Image> coalesced;
|
||||
list<Image> captioned;
|
||||
Blob caption_blob;
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
try {
|
||||
readImages(&frames, Blob(data.Data(), data.Length()));
|
||||
} catch (Magick::WarningCoder &warning) {
|
||||
cerr << "Coder Warning: " << warning.what() << endl;
|
||||
} catch (Magick::Warning &warning) {
|
||||
cerr << "Warning: " << warning.what() << endl;
|
||||
}
|
||||
|
||||
size_t width = frames.front().baseColumns();
|
||||
size_t height = frames.front().baseRows();
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
import { EventEmitter } from "events";
|
||||
|
||||
class InteractionCollector extends EventEmitter {
|
||||
constructor(client, message, options = {}) {
|
||||
constructor(client, message, timeout = 120000) {
|
||||
super();
|
||||
this.message = message;
|
||||
this.options = options;
|
||||
//this.time = timeout;
|
||||
this.ended = false;
|
||||
this.bot = client;
|
||||
this.listener = async (packet) => {
|
||||
|
@ -13,7 +13,7 @@ class InteractionCollector extends EventEmitter {
|
|||
await this.verify(packet.d.message, packet.d.data.custom_id, packet.d.id, packet.d.token, packet.d.member ? packet.d.member.user.id : packet.d.user.id);
|
||||
};
|
||||
this.bot.on("rawWS", this.listener);
|
||||
if (options.time) setTimeout(() => this.stop("time"), options.time);
|
||||
setTimeout(() => this.stop("time"), timeout);
|
||||
}
|
||||
|
||||
async verify(message, interaction, id, token, member) {
|
||||
|
|
|
@ -72,7 +72,7 @@ export default async (client, message, pages, timeout = 120000) => {
|
|||
};
|
||||
let currentPage = await client.createMessage(message.channel.id, Object.assign(pages[page], options, pages.length > 1 ? components : {}));
|
||||
if (pages.length > 1) {
|
||||
const interactionCollector = new InteractionCollector(client, currentPage, { time: timeout });
|
||||
const interactionCollector = new InteractionCollector(client, currentPage, timeout);
|
||||
interactionCollector.on("interaction", async (interaction, id, token, member) => {
|
||||
if (member === message.author.id) {
|
||||
switch (interaction) {
|
||||
|
|
Loading…
Reference in a new issue