diff --git a/CMakeLists.txt b/CMakeLists.txt
index eb8fc66..8617eba 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,34 +2,24 @@ cmake_minimum_required(VERSION 3.15)
cmake_policy(SET CMP0091 NEW)
cmake_policy(SET CMP0042 NEW)
project(image)
-
+include_directories(${CMAKE_JS_INC})
file(GLOB SOURCE_FILES "natives/*.cc" "natives/*.h")
-
-if (CMAKE_JS_VERSION)
- include_directories(${CMAKE_JS_INC})
- add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${CMAKE_JS_SRC} natives/node/image.cc)
- set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node")
- target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB})
-else()
- add_executable(${PROJECT_NAME} ${SOURCE_FILES} natives/cli/image.cc)
-endif()
-
+add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${CMAKE_JS_SRC})
+set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node")
+target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB})
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
-
if(MSVC) # todo: change flags for more parity with GCC/clang, I don't know much about MSVC so pull requests are open
- set(CMAKE_CXX_FLAGS "/Wall /EHsc /GS")
- set(CMAKE_CXX_FLAGS_DEBUG "/Zi")
- set(CMAKE_CXX_FLAGS_RELEASE "/Ox")
- set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
- set(BUILD_SHARED_LIBS TRUE)
+set(CMAKE_CXX_FLAGS "/Wall /EHsc /GS")
+set(CMAKE_CXX_FLAGS_DEBUG "/Zi")
+set(CMAKE_CXX_FLAGS_RELEASE "/Ox")
+set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
+set(BUILD_SHARED_LIBS TRUE)
else()
- set(CMAKE_CXX_FLAGS "-Wall -Wextra -Werror=format-security -Wno-cast-function-type -fexceptions -D_GLIBCXX_ASSERTIONS -fstack-clash-protection -pedantic -D_GLIBCXX_USE_CXX11_ABI=1")
- set(CMAKE_CXX_FLAGS_DEBUG "-g")
- set(CMAKE_CXX_FLAGS_RELEASE "-O2")
+set(CMAKE_CXX_FLAGS "-Wall -Wextra -Werror=format-security -Wno-cast-function-type -fexceptions -D_GLIBCXX_ASSERTIONS -fstack-clash-protection -pedantic -D_GLIBCXX_USE_CXX11_ABI=1")
+set(CMAKE_CXX_FLAGS_DEBUG "-g")
+set(CMAKE_CXX_FLAGS_RELEASE "-O3")
endif()
-set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
-
find_package(ImageMagick REQUIRED COMPONENTS Magick++ MagickCore)
add_definitions(-DMAGICKCORE_QUANTUM_DEPTH=16)
add_definitions(-DMAGICKCORE_HDRI_ENABLE=0)
@@ -41,7 +31,7 @@ include_directories(${VIPS_INCLUDE_DIRS})
link_directories(${VIPS_LIBRARY_DIRS})
target_link_libraries(${PROJECT_NAME} ${VIPS_LDFLAGS})
-if(MSVC AND CMAKE_JS_NODELIB_DEF AND CMAKE_JS_NODELIB_TARGET AND CMAKE_JS_VERSION)
+if(MSVC AND CMAKE_JS_NODELIB_DEF AND CMAKE_JS_NODELIB_TARGET)
# Generate node.lib
execute_process(COMMAND ${CMAKE_AR} /def:${CMAKE_JS_NODELIB_DEF} /out:${CMAKE_JS_NODELIB_TARGET} ${CMAKE_STATIC_LINKER_FLAGS})
endif()
diff --git a/application.yml b/application.yml
index 96c4464..744b708 100644
--- a/application.yml
+++ b/application.yml
@@ -28,7 +28,7 @@ lavalink:
plugins:
- dependency: "com.github.esmBot:lava-xm-plugin:v0.2.1"
repository: "https://jitpack.io"
- - dependency: "com.github.TopiSenpai.LavaSrc:lavasrc-plugin:3.2.0"
+ - dependency: "com.github.TopiSenpai.LavaSrc:lavasrc-plugin:3.1.7"
repository: "https://jitpack.io"
plugins:
diff --git a/assets/images/scottmap.png b/assets/images/scottmap.png
deleted file mode 100644
index f57e04e..0000000
Binary files a/assets/images/scottmap.png and /dev/null differ
diff --git a/classes/imageCommand.js b/classes/imageCommand.js
index 554a17b..a9ba426 100644
--- a/classes/imageCommand.js
+++ b/classes/imageCommand.js
@@ -25,9 +25,7 @@ class ImageCommand extends Command {
const imageParams = {
cmd: this.constructor.command,
- params: {
- togif: !!this.options.togif
- },
+ params: {},
id: (this.interaction ?? this.message).id
};
@@ -131,11 +129,6 @@ class ImageCommand extends Command {
description: "An image/GIF URL"
});
}
- this.flags.push({
- name: "togif",
- type: 5,
- description: "Force GIF output"
- });
return this;
}
diff --git a/commands/general/eval.js b/commands/general/eval.js
index 62b0e1f..64e3bea 100644
--- a/commands/general/eval.js
+++ b/commands/general/eval.js
@@ -17,11 +17,9 @@ class EvalCommand extends Command {
const sendString = `\`\`\`js\n${cleaned}\n\`\`\``;
if (sendString.length >= 2000) {
return {
- content: "The result was too large, so here it is as a file:",
- files: [{
- contents: cleaned,
- name: "result.txt"
- }]
+ text: "The result was too large, so here it is as a file:",
+ file: cleaned,
+ name: "result.txt"
};
} else {
return sendString;
diff --git a/commands/general/restart.js b/commands/general/restart.js
index a39cf2a..5f4c496 100644
--- a/commands/general/restart.js
+++ b/commands/general/restart.js
@@ -7,7 +7,7 @@ class RestartCommand extends Command {
this.success = false;
return "Only the bot owner can restart me!";
}
- await this.channel.createMessage(Object.assign({
+ await this.message.channel.createMessage(Object.assign({
content: "esmBot is restarting."
}, this.reference));
process.exit(1);
diff --git a/commands/image-editing/explode.js b/commands/image-editing/explode.js
index 63168f4..a03bda2 100644
--- a/commands/image-editing/explode.js
+++ b/commands/image-editing/explode.js
@@ -1,6 +1,10 @@
import ImageCommand from "../../classes/imageCommand.js";
class ExplodeCommand extends ImageCommand {
+ params = {
+ amount: -1
+ };
+
static description = "Explodes an image";
static aliases = ["exp"];
diff --git a/commands/image-editing/implode.js b/commands/image-editing/implode.js
index 1f05b2e..60f9909 100644
--- a/commands/image-editing/implode.js
+++ b/commands/image-editing/implode.js
@@ -2,7 +2,7 @@ import ImageCommand from "../../classes/imageCommand.js";
class ImplodeCommand extends ImageCommand {
params = {
- implode: true
+ amount: 1
};
static description = "Implodes an image";
diff --git a/config/messages.json b/config/messages.json
index 4c6f16f..d6d5d25 100644
--- a/config/messages.json
+++ b/config/messages.json
@@ -128,6 +128,7 @@
"$19 Fortnite Card",
"Wild Woody",
"RDI Halcyon",
+ "cry about it",
"KFC",
"Cave Story",
"YouTube ads",
@@ -158,6 +159,7 @@
"Item Asylum",
"TIC-80",
"Ghetto Smosh",
+ "brought to you by the DFS project",
"Splatoon 3",
"changed",
"Chutes and Ladders",
@@ -194,9 +196,6 @@
"ANTONBLAST",
"[object Object]",
"Xonotic",
- "Lario",
- "Hi-Fi Rush",
- "Calckey",
"The clock is ticking."
]
}
diff --git a/docs/custom-commands.md b/docs/custom-commands.md
index 2cce3e9..1b8b1e7 100644
--- a/docs/custom-commands.md
+++ b/docs/custom-commands.md
@@ -22,7 +22,7 @@ As you can see, each command is grouped into categories, which are represented b
!!! tip
The `message` category is special; commands in here act as right-click context menu message commands instead of "classic" or slash commands.
-## Command Structure
+## Commnand Structure
It's recommended to use the `Command` class located in `classes/command.js` to create a new command in most cases. This class provides various parameters and fields that will likely be useful when creating a command. Here is a simple example of a working command file:
```js
import Command from "../../classes/command.js";
diff --git a/events/guildCreate.js b/events/guildCreate.js
deleted file mode 100644
index f63ca10..0000000
--- a/events/guildCreate.js
+++ /dev/null
@@ -1,6 +0,0 @@
-import { log } from "../utils/logger.js";
-
-// run when the bot is added to a guild
-export default async (client, guild) => {
- log(`[GUILD JOIN] ${guild.name} (${guild.id}) added the bot.`);
-};
diff --git a/events/voiceChannelLeave.js b/events/voiceChannelLeave.js
index 00e8fdf..137b21b 100644
--- a/events/voiceChannelLeave.js
+++ b/events/voiceChannelLeave.js
@@ -1,7 +1,6 @@
import { players, queues, skipVotes } from "../utils/soundplayer.js";
import AwaitRejoin from "../utils/awaitrejoin.js";
import { random } from "../utils/misc.js";
-import { logger } from "../utils/logger.js";
const isWaiting = new Map();
@@ -17,10 +16,9 @@ export default async (client, member, oldChannel) => {
content: "🔊 Waiting 10 seconds for someone to return..."
});
const awaitRejoin = new AwaitRejoin(oldChannel, true, member.id);
- awaitRejoin.once("end", async (rejoined, newMember, cancel) => {
+ awaitRejoin.on("end", async (rejoined, newMember) => {
isWaiting.delete(oldChannel.id);
if (rejoined) {
- if (cancel) return;
connection.player.setPaused(false);
if (member.id !== newMember.id) {
players.set(connection.voiceChannel.guildID, { player: connection.player, type: connection.type, host: newMember.id, voiceChannel: connection.voiceChannel, originalChannel: connection.originalChannel, loop: connection.loop, shuffle: connection.shuffle, playMessage: connection.playMessage });
@@ -31,20 +29,19 @@ export default async (client, member, oldChannel) => {
try {
await waitMessage.delete();
} catch {
- logger.warn(`Failed to delete wait message ${waitMessage.id}`);
+ // no-op
}
}
} else {
try {
if (waitMessage.channel.messages.has(waitMessage.id)) await waitMessage.delete();
} catch {
- logger.warn(`Failed to delete wait message ${waitMessage.id}`);
+ // no-op
}
- if (cancel) return;
try {
connection.player.node.leaveChannel(connection.originalChannel.guildID);
} catch {
- logger.warn(`Failed to leave voice channel ${connection.originalChannel.guildID}`);
+ // no-op
}
players.delete(connection.originalChannel.guildID);
queues.delete(connection.originalChannel.guildID);
@@ -61,13 +58,13 @@ export default async (client, member, oldChannel) => {
content: "🔊 Waiting 10 seconds for the host to return..."
});
const awaitRejoin = new AwaitRejoin(oldChannel, false, member.id);
- awaitRejoin.once("end", async (rejoined) => {
+ awaitRejoin.on("end", async (rejoined) => {
isWaiting.delete(oldChannel.id);
if (rejoined) {
try {
if (waitMessage.channel.messages.has(waitMessage.id)) await waitMessage.delete();
} catch {
- logger.warn(`Failed to delete wait message ${waitMessage.id}`);
+ // no-op
}
} else {
const members = oldChannel.voiceMembers.filter((i) => i.id !== client.user.id && !i.bot);
@@ -75,12 +72,12 @@ export default async (client, member, oldChannel) => {
try {
if (waitMessage.channel.messages.has(waitMessage.id)) await waitMessage.delete();
} catch {
- logger.warn(`Failed to delete wait message ${waitMessage.id}`);
+ // no-op
}
try {
connection.player.node.leaveChannel(connection.originalChannel.guildID);
} catch {
- logger.warn(`Failed to leave voice channel ${connection.originalChannel.guildID}`);
+ // no-op
}
players.delete(connection.originalChannel.guildID);
queues.delete(connection.originalChannel.guildID);
@@ -102,7 +99,7 @@ export default async (client, member, oldChannel) => {
try {
connection.player.node.leaveChannel(connection.originalChannel.guildID);
} catch {
- logger.warn(`Failed to leave voice channel ${connection.originalChannel.guildID}`);
+ // no-op
}
players.delete(connection.originalChannel.guildID);
queues.delete(connection.originalChannel.guildID);
diff --git a/mkdocs.yml b/mkdocs.yml
index 7f68add..b283150 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -2,7 +2,7 @@ site_name: esmBot
docs_dir: docs/
repo_name: 'esmBot/esmBot'
repo_url: 'https://github.com/esmBot/esmBot'
-copyright: Copyright © 2018 - 2023 Essem
+copyright: Copyright © 2018 - 2022 Essem
nav:
- Home: index.md
- setup.md
diff --git a/natives/blur.cc b/natives/blur.cc
index 5347f8e..8cdebd4 100644
--- a/natives/blur.cc
+++ b/natives/blur.cc
@@ -7,14 +7,14 @@
using namespace std;
using namespace vips;
-char *Blur(string type, string *outType, char *BufferData, size_t BufferLength,
+char *Blur(string *type, char *BufferData, size_t BufferLength,
ArgumentMap Arguments, size_t *DataSize) {
bool sharp = GetArgument(Arguments, "sharp");
VOption *options = VImage::option()->set("access", "sequential");
VImage in =
VImage::new_from_buffer(BufferData, BufferLength, "",
- type == "gif" ? options->set("n", -1) : options)
+ *type == "gif" ? options->set("n", -1) : options)
.colourspace(VIPS_INTERPRETATION_sRGB);
if (!in.has_alpha()) in = in.bandjoin(255);
@@ -25,7 +25,7 @@ char *Blur(string type, string *outType, char *BufferData, size_t BufferLength,
sharp ? in.sharpen(VImage::option()->set("sigma", 3)) : in.gaussblur(15);
void *buf;
- out.write_to_buffer(("." + *outType).c_str(), &buf, DataSize);
+ out.write_to_buffer(("." + *type).c_str(), &buf, DataSize);
return (char *)buf;
}
diff --git a/natives/blur.h b/natives/blur.h
index 4f4b96d..8b017e2 100644
--- a/natives/blur.h
+++ b/natives/blur.h
@@ -4,5 +4,5 @@
using std::string;
-char* Blur(string type, string* outType, char* BufferData, size_t BufferLength,
+char* Blur(string* type, char* BufferData, size_t BufferLength,
ArgumentMap Arguments, size_t* DataSize);
\ No newline at end of file
diff --git a/natives/bounce.cc b/natives/bounce.cc
index e0d27a7..7faad55 100644
--- a/natives/bounce.cc
+++ b/natives/bounce.cc
@@ -7,29 +7,28 @@
using namespace std;
using namespace vips;
-char *Bounce(string type, string *outType, char *BufferData,
- size_t BufferLength, [[maybe_unused]] ArgumentMap Arguments,
- size_t *DataSize) {
+char *Bounce(string *type, char *BufferData, size_t BufferLength,
+ ArgumentMap Arguments, size_t *DataSize) {
VOption *options = VImage::option();
VImage in =
VImage::new_from_buffer(
BufferData, BufferLength, "",
- type == "gif" ? options->set("n", -1)->set("access", "sequential")
- : options)
+ *type == "gif" ? options->set("n", -1)->set("access", "sequential")
+ : options)
.colourspace(VIPS_INTERPRETATION_sRGB);
if (!in.has_alpha()) in = in.bandjoin(255);
int width = in.width();
int pageHeight = vips_image_get_page_height(in.get_image());
- int nPages = type == "gif" ? vips_image_get_n_pages(in.get_image()) : 15;
+ int nPages = *type == "gif" ? vips_image_get_n_pages(in.get_image()) : 15;
double mult = M_PI / nPages;
int halfHeight = pageHeight / 2;
vector img;
for (int i = 0; i < nPages; i++) {
VImage img_frame =
- type == "gif" ? in.crop(0, i * pageHeight, width, pageHeight) : in;
+ *type == "gif" ? in.crop(0, i * pageHeight, width, pageHeight) : in;
double height = halfHeight * ((abs(sin(i * mult)) * -1) + 1);
VImage embedded =
img_frame.embed(0, height, width, pageHeight + halfHeight);
@@ -37,7 +36,7 @@ char *Bounce(string type, string *outType, char *BufferData,
}
VImage final = VImage::arrayjoin(img, VImage::option()->set("across", 1));
final.set(VIPS_META_PAGE_HEIGHT, pageHeight + halfHeight);
- if (type != "gif") {
+ if (*type != "gif") {
vector delay(30, 50);
final.set("delay", delay);
}
@@ -45,7 +44,7 @@ char *Bounce(string type, string *outType, char *BufferData,
void *buf;
final.write_to_buffer(".gif", &buf, DataSize);
- *outType = "gif";
+ *type = "gif";
return (char *)buf;
}
\ No newline at end of file
diff --git a/natives/bounce.h b/natives/bounce.h
index 0ea273a..44a329f 100644
--- a/natives/bounce.h
+++ b/natives/bounce.h
@@ -4,5 +4,5 @@
using std::string;
-char* Bounce(string type, string* outType, char* BufferData, size_t BufferLength,
+char* Bounce(string* type, char* BufferData, size_t BufferLength,
ArgumentMap Arguments, size_t* DataSize);
\ No newline at end of file
diff --git a/natives/caption.cc b/natives/caption.cc
index 1979c4f..d1824af 100644
--- a/natives/caption.cc
+++ b/natives/caption.cc
@@ -6,8 +6,8 @@
using namespace std;
using namespace vips;
-char *Caption(string type, string *outType, char *BufferData,
- size_t BufferLength, ArgumentMap Arguments, size_t *DataSize) {
+char *Caption(string *type, char *BufferData, size_t BufferLength,
+ ArgumentMap Arguments, size_t *DataSize) {
string caption = GetArgument(Arguments, "caption");
string font = GetArgument(Arguments, "font");
string basePath = GetArgument(Arguments, "basePath");
@@ -16,7 +16,7 @@ char *Caption(string type, string *outType, char *BufferData,
VImage in =
VImage::new_from_buffer(BufferData, BufferLength, "",
- type == "gif" ? options->set("n", -1) : options)
+ *type == "gif" ? options->set("n", -1) : options)
.colourspace(VIPS_INTERPRETATION_sRGB);
if (!in.has_alpha()) in = in.bandjoin(255);
@@ -57,7 +57,7 @@ char *Caption(string type, string *outType, char *BufferData,
vector img;
for (int i = 0; i < nPages; i++) {
VImage img_frame =
- type == "gif" ? in.crop(0, i * pageHeight, width, pageHeight) : in;
+ *type == "gif" ? in.crop(0, i * pageHeight, width, pageHeight) : in;
VImage frame = captionImage.join(
img_frame, VIPS_DIRECTION_VERTICAL,
VImage::option()->set("background", 0xffffff)->set("expand", true));
@@ -68,10 +68,9 @@ char *Caption(string type, string *outType, char *BufferData,
void *buf;
final.write_to_buffer(
- ("." + *outType).c_str(), &buf, DataSize,
- *outType == "gif"
- ? VImage::option()->set("dither", 0)->set("reoptimise", 1)
- : 0);
+ ("." + *type).c_str(), &buf, DataSize,
+ *type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1)
+ : 0);
return (char *)buf;
}
diff --git a/natives/caption.h b/natives/caption.h
index 6ff73c1..a84ccb1 100644
--- a/natives/caption.h
+++ b/natives/caption.h
@@ -4,5 +4,5 @@
using std::string;
-char* Caption(string type, string* outType, char* BufferData, size_t BufferLength,
+char* Caption(string* type, char* BufferData, size_t BufferLength,
ArgumentMap Arguments, size_t* DataSize);
\ No newline at end of file
diff --git a/natives/caption2.cc b/natives/caption2.cc
index 0b9026e..a7bf181 100644
--- a/natives/caption2.cc
+++ b/natives/caption2.cc
@@ -7,8 +7,8 @@
using namespace std;
using namespace vips;
-char *CaptionTwo(string type, string *outType, char *BufferData,
- size_t BufferLength, ArgumentMap Arguments, size_t *DataSize) {
+char *CaptionTwo(string *type, char *BufferData, size_t BufferLength,
+ ArgumentMap Arguments, size_t *DataSize) {
bool top = GetArgument(Arguments, "top");
string caption = GetArgument(Arguments, "caption");
string font = GetArgument(Arguments, "font");
@@ -18,7 +18,7 @@ char *CaptionTwo(string type, string *outType, char *BufferData,
VImage in =
VImage::new_from_buffer(BufferData, BufferLength, "",
- type == "gif" ? options->set("n", -1) : options)
+ *type == "gif" ? options->set("n", -1) : options)
.colourspace(VIPS_INTERPRETATION_sRGB);
if (!in.has_alpha()) in = in.bandjoin(255);
@@ -58,7 +58,7 @@ char *CaptionTwo(string type, string *outType, char *BufferData,
vector img;
for (int i = 0; i < nPages; i++) {
VImage img_frame =
- type == "gif" ? in.crop(0, i * pageHeight, width, pageHeight) : in;
+ *type == "gif" ? in.crop(0, i * pageHeight, width, pageHeight) : in;
VImage frame =
(top ? captionImage : img_frame)
.join(top ? img_frame : captionImage, VIPS_DIRECTION_VERTICAL,
@@ -72,10 +72,9 @@ char *CaptionTwo(string type, string *outType, char *BufferData,
void *buf;
final.write_to_buffer(
- ("." + *outType).c_str(), &buf, DataSize,
- *outType == "gif"
- ? VImage::option()->set("dither", 0)->set("reoptimise", 1)
- : 0);
+ ("." + *type).c_str(), &buf, DataSize,
+ *type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1)
+ : 0);
return (char *)buf;
}
diff --git a/natives/caption2.h b/natives/caption2.h
index 6ee4790..d45e2d2 100644
--- a/natives/caption2.h
+++ b/natives/caption2.h
@@ -4,5 +4,5 @@
using std::string;
-char* CaptionTwo(string type, string* outType, char* BufferData, size_t BufferLength,
+char* CaptionTwo(string* type, char* BufferData, size_t BufferLength,
ArgumentMap Arguments, size_t* DataSize);
\ No newline at end of file
diff --git a/natives/circle.cc b/natives/circle.cc
index 96a1768..3834be3 100644
--- a/natives/circle.cc
+++ b/natives/circle.cc
@@ -11,9 +11,8 @@
using namespace std;
using namespace Magick;
-char *Circle(string type, string *outType, char *BufferData,
- size_t BufferLength, [[maybe_unused]] ArgumentMap Arguments,
- size_t *DataSize) {
+char *Circle(string *type, char *BufferData, size_t BufferLength,
+ ArgumentMap Arguments, size_t *DataSize) {
Blob blob;
list frames;
@@ -30,13 +29,13 @@ char *Circle(string type, string *outType, char *BufferData,
for (Image &image : coalesced) {
image.rotationalBlur(10);
- image.magick(*outType);
+ image.magick(*type);
blurred.push_back(image);
}
optimizeTransparency(blurred.begin(), blurred.end());
- if (*outType == "gif") {
+ if (*type == "gif") {
for (Image &image : blurred) {
image.quantizeDitherMethod(FloydSteinbergDitherMethod);
image.quantize();
diff --git a/natives/circle.h b/natives/circle.h
index 4ee7f96..283ca79 100644
--- a/natives/circle.h
+++ b/natives/circle.h
@@ -4,5 +4,5 @@
using std::string;
-char* Circle(string type, string* outType, char* BufferData, size_t BufferLength,
+char* Circle(string* type, char* BufferData, size_t BufferLength,
ArgumentMap Arguments, size_t* DataSize);
\ No newline at end of file
diff --git a/natives/cli/image.cc b/natives/cli/image.cc
deleted file mode 100644
index 344d0bb..0000000
--- a/natives/cli/image.cc
+++ /dev/null
@@ -1,26 +0,0 @@
-#include
-#include
-
-#include "../common.h"
-
-void showUsage(char *path) {
- std::cout << "Usage: " << path << " operation [--arg=\"param\"] [...]" << std::endl;
-}
-
-int main(int argc, char *argv[]) {
- if (argc < 1 ||
- (argc == 1 && !strcmp(argv[1], "-h"))) {
- showUsage(argv[0]);
-#ifdef _WIN32
- system("PAUSE");
-#endif
- return 1;
- }
-
- char *op = argv[1];
-
- //handleArguments(argc, argv);
-
- std::cout << "This does nothing yet, but it might in the future!" << std::endl;
- return 0;
-}
\ No newline at end of file
diff --git a/natives/colors.cc b/natives/colors.cc
index b488600..6c8fa62 100644
--- a/natives/colors.cc
+++ b/natives/colors.cc
@@ -10,15 +10,15 @@ using namespace vips;
VImage sepia = VImage::new_matrixv(3, 3, 0.3588, 0.7044, 0.1368, 0.2990, 0.5870,
0.1140, 0.2392, 0.4696, 0.0912);
-char *Colors(string type, string *outType, char *BufferData,
- size_t BufferLength, ArgumentMap Arguments, size_t *DataSize) {
+char *Colors(string *type, char *BufferData, size_t BufferLength,
+ ArgumentMap Arguments, size_t *DataSize) {
string color = GetArgument(Arguments, "color");
VOption *options = VImage::option()->set("access", "sequential");
VImage in =
VImage::new_from_buffer(BufferData, BufferLength, "",
- type == "gif" ? options->set("n", -1) : options)
+ *type == "gif" ? options->set("n", -1) : options)
.colourspace(VIPS_INTERPRETATION_sRGB);
VImage out;
@@ -30,7 +30,7 @@ char *Colors(string type, string *outType, char *BufferData,
}
void *buf;
- out.write_to_buffer(("." + *outType).c_str(), &buf, DataSize);
+ out.write_to_buffer(("." + *type).c_str(), &buf, DataSize);
return (char *)buf;
}
diff --git a/natives/colors.h b/natives/colors.h
index 4d00d0b..d0bddf5 100644
--- a/natives/colors.h
+++ b/natives/colors.h
@@ -4,5 +4,5 @@
using std::string;
-char* Colors(string type, string* outType, char* BufferData, size_t BufferLength,
+char* Colors(string* type, char* BufferData, size_t BufferLength,
ArgumentMap Arguments, size_t* DataSize);
\ No newline at end of file
diff --git a/natives/common.h b/natives/common.h
index 1d71efb..2099433 100644
--- a/natives/common.h
+++ b/natives/common.h
@@ -12,46 +12,6 @@ using std::variant;
typedef variant ArgumentVariant;
typedef map ArgumentMap;
-#include "blur.h"
-#include "bounce.h"
-#include "caption.h"
-#include "caption2.h"
-#include "circle.h"
-#include "colors.h"
-#include "crop.h"
-#include "deepfry.h"
-#include "explode.h"
-#include "flag.h"
-#include "flip.h"
-#include "freeze.h"
-#include "gamexplain.h"
-#include "globe.h"
-#include "homebrew.h"
-#include "invert.h"
-#include "jpeg.h"
-#include "magik.h"
-#include "meme.h"
-#include "mirror.h"
-#include "motivate.h"
-#include "reddit.h"
-#include "resize.h"
-#include "reverse.h"
-#include "scott.h"
-#include "snapchat.h"
-#include "sonic.h"
-#include "speed.h"
-#include "spin.h"
-#include "squish.h"
-#include "swirl.h"
-#include "tile.h"
-#include "togif.h"
-#include "uncanny.h"
-#include "uncaption.h"
-#include "wall.h"
-#include "watermark.h"
-#include "whisper.h"
-#include "zamn.h"
-
template
T GetArgument(ArgumentMap map, string key) {
try {
@@ -82,49 +42,4 @@ T GetArgumentWithFallback(ArgumentMap map, string key, T fallback) {
const std::unordered_map fontPaths{
{"futura", "assets/fonts/caption.otf"},
{"helvetica", "assets/fonts/caption2.ttf"},
- {"roboto", "assets/fonts/reddit.ttf"}};
-
-const std::map
- FunctionMap = {{"blur", &Blur},
- {"bounce", &Bounce},
- {"caption", &Caption},
- {"captionTwo", &CaptionTwo},
- {"circle", &Circle},
- {"colors", &Colors},
- {"crop", &Crop},
- {"deepfry", &Deepfry},
- {"explode", &Explode},
- {"flag", &Flag},
- {"flip", &Flip},
- {"freeze", &Freeze},
- {"gamexplain", Gamexplain},
- {"globe", Globe},
- {"invert", Invert},
- {"jpeg", Jpeg},
- {"magik", Magik},
- {"meme", Meme},
- {"mirror", Mirror},
- {"motivate", Motivate},
- {"reddit", Reddit},
- {"resize", Resize},
- {"reverse", Reverse},
- {"scott", Scott},
- {"snapchat", Snapchat},
- {"speed", &Speed},
- {"spin", Spin},
- {"squish", Squish},
- {"swirl", Swirl},
- {"tile", Tile},
- {"togif", ToGif},
- {"uncanny", Uncanny},
- {"uncaption", &Uncaption},
- {"wall", Wall},
- {"watermark", &Watermark},
- {"whisper", Whisper},
- {"zamn", Zamn}};
-
-const std::map
- NoInputFunctionMap = {{"homebrew", Homebrew}, {"sonic", Sonic}};
\ No newline at end of file
+ {"roboto", "assets/fonts/reddit.ttf"}};
\ No newline at end of file
diff --git a/natives/crop.cc b/natives/crop.cc
index 9faba5b..07cbad5 100644
--- a/natives/crop.cc
+++ b/natives/crop.cc
@@ -7,13 +7,13 @@
using namespace std;
using namespace vips;
-char *Crop(string type, string *outType, char *BufferData, size_t BufferLength,
- [[maybe_unused]] ArgumentMap Arguments, size_t *DataSize) {
+char *Crop(string *type, char *BufferData, size_t BufferLength,
+ ArgumentMap Arguments, size_t *DataSize) {
VOption *options = VImage::option()->set("access", "sequential");
VImage in =
VImage::new_from_buffer(BufferData, BufferLength, "",
- type == "gif" ? options->set("n", -1) : options)
+ *type == "gif" ? options->set("n", -1) : options)
.colourspace(VIPS_INTERPRETATION_sRGB);
int width = in.width();
@@ -24,7 +24,7 @@ char *Crop(string type, string *outType, char *BufferData, size_t BufferLength,
int finalHeight = 0;
for (int i = 0; i < nPages; i++) {
VImage img_frame =
- type == "gif" ? in.crop(0, i * pageHeight, width, pageHeight) : in;
+ *type == "gif" ? in.crop(0, i * pageHeight, width, pageHeight) : in;
int frameWidth = img_frame.width();
int frameHeight = img_frame.height();
bool widthOrHeight = frameWidth / frameHeight >= 1;
@@ -42,10 +42,9 @@ char *Crop(string type, string *outType, char *BufferData, size_t BufferLength,
void *buf;
final.write_to_buffer(
- ("." + *outType).c_str(), &buf, DataSize,
- *outType == "gif"
- ? VImage::option()->set("dither", 0)->set("reoptimise", 1)
- : 0);
+ ("." + *type).c_str(), &buf, DataSize,
+ *type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1)
+ : 0);
return (char *)buf;
}
\ No newline at end of file
diff --git a/natives/crop.h b/natives/crop.h
index c7cad96..439b4d1 100644
--- a/natives/crop.h
+++ b/natives/crop.h
@@ -4,5 +4,5 @@
using std::string;
-char* Crop(string type, string* outType, char* BufferData, size_t BufferLength,
+char* Crop(string* type, char* BufferData, size_t BufferLength,
ArgumentMap Arguments, size_t* DataSize);
\ No newline at end of file
diff --git a/natives/deepfry.cc b/natives/deepfry.cc
index 9fe72a0..dce5b97 100644
--- a/natives/deepfry.cc
+++ b/natives/deepfry.cc
@@ -6,14 +6,13 @@
using namespace std;
using namespace vips;
-char *Deepfry(string type, string *outType, char *BufferData,
- size_t BufferLength, [[maybe_unused]] ArgumentMap Arguments,
- size_t *DataSize) {
+char *Deepfry(string *type, char *BufferData, size_t BufferLength,
+ ArgumentMap Arguments, size_t *DataSize) {
VOption *options = VImage::option()->set("access", "sequential");
VImage in =
VImage::new_from_buffer(BufferData, BufferLength, "",
- type == "gif" ? options->set("n", -1) : options)
+ *type == "gif" ? options->set("n", -1) : options)
.colourspace(VIPS_INTERPRETATION_sRGB);
if (!in.has_alpha()) in = in.bandjoin(255);
@@ -26,7 +25,7 @@ char *Deepfry(string type, string *outType, char *BufferData,
VImage fried = (in * 1.3 - (255.0 * 1.3 - 255.0)) * 1.5;
VImage final;
- if (totalHeight > 65500 && type == "gif") {
+ if (totalHeight > 65500 && *type == "gif") {
vector img;
for (int i = 0; i < nPages; i++) {
VImage img_frame = in.crop(0, i * pageHeight, width, pageHeight);
@@ -49,13 +48,13 @@ char *Deepfry(string type, string *outType, char *BufferData,
VImage::option()->set("Q", 1)->set("strip", true));
final = VImage::new_from_buffer(jpgBuf, jpgLength, "");
final.set(VIPS_META_PAGE_HEIGHT, pageHeight);
- if (type == "gif") final.set("delay", fried.get_array_int("delay"));
+ if (*type == "gif") final.set("delay", fried.get_array_int("delay"));
}
void *buf;
final.write_to_buffer(
- ("." + *outType).c_str(), &buf, DataSize,
- *outType == "gif" ? VImage::option()->set("dither", 0) : 0);
+ ("." + *type).c_str(), &buf, DataSize,
+ *type == "gif" ? VImage::option()->set("dither", 0) : 0);
return (char *)buf;
}
\ No newline at end of file
diff --git a/natives/deepfry.h b/natives/deepfry.h
index 9196438..00cc403 100644
--- a/natives/deepfry.h
+++ b/natives/deepfry.h
@@ -4,5 +4,5 @@
using std::string;
-char* Deepfry(string type, string* outType, char* BufferData, size_t BufferLength,
+char* Deepfry(string* type, char* BufferData, size_t BufferLength,
ArgumentMap Arguments, size_t* DataSize);
\ No newline at end of file
diff --git a/natives/explode.cc b/natives/explode.cc
index bc167e0..4d6d42c 100644
--- a/natives/explode.cc
+++ b/natives/explode.cc
@@ -1,52 +1,58 @@
-#include
-
#include "common.h"
+#include
+
+#include
+#include
+#include
+#include