Added support for jpeg(stb) and webp(libwebp)
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#include "../Common.hpp"
|
||||
#include "../Utility/CairoTools.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <dpp/dispatcher.h>
|
||||
#include <dpp/dpp.h>
|
||||
#include <dpp/guild.h>
|
||||
@@ -25,11 +27,22 @@ void commandGenerateReport(const dpp::slashcommand_t &event,
|
||||
bot.request(
|
||||
file.url, dpp::http_method::m_get,
|
||||
[event, &bot, fileType](const dpp::http_request_completion_t &result) {
|
||||
std::string responseData = GenerateReportImage(
|
||||
fileType->second(
|
||||
result.body), // Image itself processed for cario to handle
|
||||
std::get<std::string>(event.get_parameter("headline")));
|
||||
auto imageAsSurface = fileType->second(result.body);
|
||||
if (imageAsSurface == nullptr) {
|
||||
event.edit_response("Failed to load the background image :(");
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't forget that its only funny if it is all in upper case
|
||||
std::string headline =
|
||||
std::get<std::string>(event.get_parameter("headline"));
|
||||
|
||||
// Never seen this method before but looks awesome
|
||||
std::transform(headline.begin(), headline.end(), headline.data(),
|
||||
::toupper);
|
||||
|
||||
std::string responseData =
|
||||
GenerateReportImage(imageAsSurface, headline);
|
||||
dpp::message response(event.command.channel_id, "");
|
||||
response.add_file("report.png", responseData);
|
||||
event.edit_response(response);
|
||||
|
Reference in New Issue
Block a user