diff options
author | Niklas Halle <niklas@niklashalle.net> | 2020-08-23 12:41:55 +0200 |
---|---|---|
committer | Niklas Halle <niklas@niklashalle.net> | 2020-08-23 12:43:23 +0200 |
commit | 3314a53d0cf0a135fe6f82fcc7b6f4df84f70436 (patch) | |
tree | c17358c94c6211ba5408935a170a7d66f9c83bb4 /src/N-Commands | |
parent | 70d5a9cf40546e0013a4761a2b0060963a21b13c (diff) | |
download | n_core-3314a53d0cf0a135fe6f82fcc7b6f4df84f70436.tar.gz n_core-3314a53d0cf0a135fe6f82fcc7b6f4df84f70436.zip |
clean start, clean CMakeLists.txt
Diffstat (limited to 'src/N-Commands')
-rw-r--r-- | src/N-Commands/KlingerHandler.cpp | 11 | ||||
-rw-r--r-- | src/N-Commands/KlingerHandler.hpp | 17 | ||||
-rw-r--r-- | src/N-Commands/RelationshipHandler.cpp | 130 | ||||
-rw-r--r-- | src/N-Commands/RelationshipHandler.hpp | 10 |
4 files changed, 0 insertions, 168 deletions
diff --git a/src/N-Commands/KlingerHandler.cpp b/src/N-Commands/KlingerHandler.cpp deleted file mode 100644 index c596952..0000000 --- a/src/N-Commands/KlingerHandler.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// -// Created by max on 11.08.20. -// - -#include "KlingerHandler.hpp" - -void KlingerHandler::onCall(const Mongoose::Request& request, Mongoose::JsonResponse& response) { - - std::cout << "Klinger was called\n"; - response["text"] = "Bonjour!"; -} diff --git a/src/N-Commands/KlingerHandler.hpp b/src/N-Commands/KlingerHandler.hpp deleted file mode 100644 index c078303..0000000 --- a/src/N-Commands/KlingerHandler.hpp +++ /dev/null @@ -1,17 +0,0 @@ -// -// Created by max on 11.08.20. -// -#include <mongoose/Server.h> -#include <mongoose/JsonResponse.h> -#include <string> -#ifndef DORGODBOTBACKEND_KLINGERHANDLER_H -#define DORGODBOTBACKEND_KLINGERHANDLER_H - - -class KlingerHandler { -public: - void onCall(const Mongoose::Request& request, Mongoose::JsonResponse& response) ; -}; - - -#endif //DORGODBOTBACKEND_KLINGERHANDLER_H diff --git a/src/N-Commands/RelationshipHandler.cpp b/src/N-Commands/RelationshipHandler.cpp deleted file mode 100644 index 46991a3..0000000 --- a/src/N-Commands/RelationshipHandler.cpp +++ /dev/null @@ -1,130 +0,0 @@ -#include "RelationshipHandler.hpp" -#include<string> -#include<vector> -#include <algorithm> -using namespace std; - -//Takk til https://www.geeksforgeeks.org/split-a-sentence-into-words-in-cpp/ -//fucking c++ does not has a split function like every other programming language in the world -vector<string> removeDupWord(const string& str) { - vector<string> v = {}; - string word; // = ""; - for(auto x : str) { - if(x == ' ') { - if(word != "/relation") { - v.push_back(word); - } - word = ""; - } else { - word += x; - } - } - v.push_back(word); - return v; -} -vector<int> buildCalArr(vector<string> nameV) { - string ges = nameV.at(0) + nameV.at(1); - - for(auto& c : ges) { - c = tolower(c); - } - - vector<int> v = {}; - for(auto c1 : ges) { - //cout << c1 << '\n'; - int count = 0; - for(auto c2: ges) { - if(c1==c2) { - ++count; - } - } - v.push_back(count); - } - //cout << ges << endl; - - /*for(auto i: v) { - cout << i << ' '; - } - cout << v.size() << "\n";*/ - return v; -} - -int calculate(vector<string> names) { - sort(names.begin(), names.end()); - vector<int> nums = buildCalArr(names); - - while(nums.size() > 2) { - vector<int> tempNums = {}; - for(std::size_t i=0;i<nums.size()/2;i++) { - int temp = nums.at(i) + nums.at(nums.size()-i-1); - if(nums.size()%2==1 && i==nums.size()/2) { - tempNums.push_back(nums.at(i)); - } else { - if(temp < 10) { - tempNums.push_back(temp); - } else { - tempNums.push_back(temp/10); - tempNums.push_back(temp%10); - } - } - } - if(nums.size()%2==1) { - tempNums.push_back(nums.at(nums.size()/2)); - } - nums.clear(); - for(auto i: tempNums) { - nums.push_back(i); - } - /*for(auto i: nums) { - cout << i << ' '; - } - cout << "\n";*/ - } - - return 10*nums.at(0)+nums.at(1); -} - -bool isAlphaNum(const string& str) { - //if(!std::for_each(str.begin(), str.end(), [](char& c) { if(!std::isalnum(c)) return false;})) return false; - - for(char i: str) { - if(!isalnum(i)) { - return false; - } - } - return true; -} - -string rsStart(vector<string> names) { - //vector<string> names = removeDupWord(str); - if(names.size() != 2) { - return "Gib zwei Namen ein Du Troll!"; - } - if(!isAlphaNum(names.at(0))) { - return "Seit wann enthælt ein Name Sonderzeichen oder Zahlen? Spüre den Zorn von N!"; - } - if(!isAlphaNum(names.at(1))) { - return "Seit wann enthælt ein Name Sonderzeichen oder Zahlen? Spüre den Zorn von N!"; - } - int result = calculate(names); - - return (names.at(0) + " und " + names.at(1) + " passen nach Angaben von N zu " + to_string(result) + "% zusammen. Gratuliere!\n"); -} - -void RelationshipHandler::onCall(Mongoose::Request& request, Mongoose::JsonResponse& response) { - - std::cout << "/relation was called\n"; - - response["text"] = rsStart(vector<string>{request.get("name1", "Lukas"), request.get("name2", "cpp")}); - - response["success"] = "1"; - response["session"] = "NULL"; - /*if (messagePtr->date > telegram->getBootDate()) { - - log(messagePtr->from->username + ": "+messagePtr->text); - - telegram->sendMessage(messagePtr->chat->id, rsStart(messagePtr->text)); - - }*/ - -} diff --git a/src/N-Commands/RelationshipHandler.hpp b/src/N-Commands/RelationshipHandler.hpp deleted file mode 100644 index fe9c0ea..0000000 --- a/src/N-Commands/RelationshipHandler.hpp +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once -#include <mongoose.h> -#include <mongoose/Request.h> -#include <mongoose/JsonResponse.h> - -class RelationshipHandler { -public: - void onCall(Mongoose::Request& request, Mongoose::JsonResponse& response); - -}; |