Added libcairo as a dependancy
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# Minimum CMake version required, we'll just use the latest version.
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
# Project name, version and description
|
||||
project(TheBartender VERSION 1.0)
|
||||
project(TheBartender VERSION 0.3)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
||||
|
||||
@@ -12,13 +12,16 @@ add_executable(${PROJECT_NAME} src/Base/Entry.cpp src/Commands.cpp)
|
||||
find_package(DPP REQUIRED)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(SQLITE3 REQUIRED sqlite3)
|
||||
pkg_check_modules(CAIRO REQUIRED cairo)
|
||||
|
||||
# Link the pre-installed DPP package.
|
||||
target_link_libraries(${PROJECT_NAME} ${DPP_LIBRARIES} ${SQLITE3_LIBRARIES})
|
||||
target_link_libraries(${PROJECT_NAME} ${DPP_LIBRARIES} ${SQLITE3_LIBRARIES}
|
||||
${CAIRO_LIBRARIES})
|
||||
|
||||
# Include the DPP directories.
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE ${DPP_INCLUDE_DIR}
|
||||
${SQLITE3_INCLUDE_DIR})
|
||||
target_include_directories(
|
||||
${PROJECT_NAME} PRIVATE ${DPP_INCLUDE_DIR} ${SQLITE3_INCLUDE_DIR}
|
||||
${CAIRO_INCLUDE_DIR})
|
||||
|
||||
# Set C++ version
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 20
|
||||
|
@@ -27,7 +27,7 @@ void createCommands(const dpp::ready_t &event, dpp::cluster &bot) {
|
||||
dpp::slashcommand(COMMAND_GENERATE_REPORT,
|
||||
COMMAND_GENERATE_REPORT_DESCRIPTION, bot.me.id)
|
||||
.add_option(dpp::command_option(
|
||||
dpp::command_option_type::co_attachment, "background-image",
|
||||
dpp::command_option_type::co_attachment, "image",
|
||||
COMMAND_GENERATE_REPORT_ARGS_IMAGE_DESCRIPTION, true))
|
||||
.add_option(dpp::command_option(
|
||||
dpp::command_option_type::co_string, "headline",
|
||||
|
@@ -3,8 +3,46 @@
|
||||
#include <dpp/dispatcher.h>
|
||||
#include <dpp/dpp.h>
|
||||
#include <dpp/guild.h>
|
||||
#include <dpp/message.h>
|
||||
#include <dpp/misc-enum.h>
|
||||
#include <dpp/queues.h>
|
||||
#include <dpp/snowflake.h>
|
||||
#include <dpp/user.h>
|
||||
|
||||
#include <cairo/cairo.h>
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
void pngToCairoSurface(std::string data) {
|
||||
cairo_surface_t *image =
|
||||
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 300, 200);
|
||||
}
|
||||
void jpegToCairoSurface(std::string data) {}
|
||||
void webpToCairoSurface(std::string data) {}
|
||||
|
||||
std::unordered_map<std::string, std::function<void(std::string)>>
|
||||
supportedImageFileTypes{{"image/png", pngToCairoSurface},
|
||||
{"image/jpeg", jpegToCairoSurface},
|
||||
{"image/webp", webpToCairoSurface}};
|
||||
|
||||
void commandGenerateReport(const dpp::slashcommand_t &event,
|
||||
dpp::cluster &bot) {}
|
||||
dpp::cluster &bot) {
|
||||
event.thinking();
|
||||
dpp::snowflake fileId =
|
||||
std::get<dpp::snowflake>(event.get_parameter("image"));
|
||||
dpp::attachment file = event.command.get_resolved_attachment(fileId);
|
||||
auto fileType = supportedImageFileTypes.find(file.content_type);
|
||||
if (fileType != supportedImageFileTypes.end()) {
|
||||
bot.request(
|
||||
file.url, dpp::http_method::m_get,
|
||||
[event, &bot, fileType](const dpp::http_request_completion_t &result) {
|
||||
fileType->second(result.body);
|
||||
});
|
||||
} else {
|
||||
event.edit_response(
|
||||
"File type: " + file.content_type +
|
||||
" is not allowed. Only PNG, JPEG, and WEBP are allowed!");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user