aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp47
1 files changed, 27 insertions, 20 deletions
diff --git a/src/main.cpp b/src/main.cpp
index fd1be31..8a8e4ba 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -12,39 +12,49 @@
#include "GetEssen.hpp"
#include "SimpleHandlers.hpp"
#include "RelationshipHandler.hpp"
+
/* END Handlers */
int main() {
crow::SimpleApp app;
- auto createPlainDescriptionFromText = [](std::string const &text) -> std::vector<crow::json::wvalue> * {
- auto reply_vector = new std::vector<crow::json::wvalue>;
- reply_vector->emplace_back(Response::create_text(text));
+ auto createPlainDescriptionFromText = [](std::string const &text) -> std::vector<crow::json::wvalue> {
+ std::vector<crow::json::wvalue> reply_vector;
+ reply_vector.emplace_back(Response::create_text(text));
return reply_vector;
};
// command --> handler
std::vector<Handler::CommandHandler> commands;
commands.emplace_back(
- Handler::CommandHandler{"wiki", Handler::wikiHandler, createPlainDescriptionFromText(
- "Sends you to Wikipedia!")});
+ Handler::CommandHandler{"wiki", Handler::wikiHandler, [createPlainDescriptionFromText]() {
+ return createPlainDescriptionFromText("Sends you to Wikipedia!");
+ }});
commands.emplace_back(
- Handler::CommandHandler{"stop", Handler::stopHandler, createPlainDescriptionFromText(
- "Stops the bot"), &app});
+ Handler::CommandHandler{"stop", Handler::stopHandler, [createPlainDescriptionFromText]() {
+ return createPlainDescriptionFromText("Stops the bot");
+ }, &app});
commands.emplace_back(
- Handler::CommandHandler{"mensa", Handler::mensaHandler, createPlainDescriptionFromText(
- "{adlershof, nord, sued} Shows the daily menu of the mensa at various places.")});
+ Handler::CommandHandler{"mensa", Handler::mensaHandler, [createPlainDescriptionFromText]() {
+ return createPlainDescriptionFromText(
+ "{adlershof, nord, sued} Shows the daily menu of the mensa at various places.");
+ }});
commands.emplace_back(
- Handler::CommandHandler{"klinger", Handler::klingerHandler, createPlainDescriptionFromText(
- "Greats in french. Bonjour!")});
+ Handler::CommandHandler{"klinger", Handler::klingerHandler, [createPlainDescriptionFromText]() {
+ return createPlainDescriptionFromText("Greats in french. Bonjour!");
+ }});
commands.emplace_back(
- Handler::CommandHandler{"say", Handler::sayHandler, createPlainDescriptionFromText(
- "Say something!")});
+ Handler::CommandHandler{"say", Handler::sayHandler, [createPlainDescriptionFromText]() {
+ return createPlainDescriptionFromText("Say something!");
+ }});
commands.emplace_back(
- Handler::CommandHandler{"relation", Handler::relationShipHandler, createPlainDescriptionFromText(
- "[name1] [name2] Shows the result of an odd astrological religious pseudo-algorithm, based on the fact how much blessing a relationship receives by the glorious N.")});
- commands.emplace_back(Handler::CommandHandler{"help", Handler::helpHandler, createPlainDescriptionFromText(
- "This is my holy manual."), &commands});
+ Handler::CommandHandler{"relation", Handler::relationShipHandler, [createPlainDescriptionFromText]() {
+ return createPlainDescriptionFromText(
+ "[name1] [name2] Shows the result of an odd astrological religious pseudo-algorithm, based on the fact how much blessing a relationship receives by the glorious N.");
+ }});
+ commands.emplace_back(Handler::CommandHandler{"help", Handler::helpHandler, [createPlainDescriptionFromText]() {
+ return createPlainDescriptionFromText("This is my holy manual.");
+ }, &commands});
CROW_ROUTE(app, "/")
.methods("POST"_method)
@@ -78,8 +88,5 @@ int main() {
app.port(18080).multithreaded().run();
- for (auto &&it : commands)
- delete it.description;
-
std::cout << "Stopped successfully" << std::endl;
}