diff --git a/instance.cpp b/instance.cpp index 72c2ab5..33c49a5 100644 --- a/instance.cpp +++ b/instance.cpp @@ -399,7 +399,7 @@ async::result Instance::process(Event event) { if (event.args[1] == "SU") { // User logged in // Check args - argsSizeCheck("ENCAP (SU)", event.args, 5); + argsSizeCheck("ENCAP (SU)", event.args, 4); // Find user in cache auto res = cache.find_user_by_uid(event.args[2]); if (res == cache.users.end()) { diff --git a/services/test.cpp b/services/test.cpp index a075f44..4095bbe 100644 --- a/services/test.cpp +++ b/services/test.cpp @@ -29,7 +29,6 @@ async::result TestService::intitialize() { co_await mark_ready(user); co_await i->send_event(serviceChannel.get_sjoin(user.uid)); co_await i->send_event(serviceChannel.get_topic("IRC Service channel", user.uid)); - //co_await i->send_event(user.get_encap_su("serviceD")); DOES NOT YET WORK!! co_await i->send_event(user.get_notice("Test... Hello world!", serviceChannelName)); } @@ -39,8 +38,10 @@ async::result TestService::on_event(const Event& event) { async::result TestService::on_direct_privmsg(std::string_view msg, u_User &author) { auto cmd = Utility::strSplit(msg, ' ', 1); + auto command = Utility::lowers(cmd[0]); + Event response = user.get_notice("You need to log in first", author->uid); - if (cmd[0] == "SEND") { + if (command == "send") { if (author->loginName.value_or("") == "NetOP") { Event event; try { diff --git a/utility.cpp b/utility.cpp index fecc697..fad7258 100644 --- a/utility.cpp +++ b/utility.cpp @@ -38,7 +38,18 @@ void argsSizeCheck(std::string_view where, std::vector args, s throw InsufficientArgsError(where, expected, args.size()); } } + +std::string lowers(std::string_view str) { + std::string fres(str); + for (auto& character : fres) { + if (isalpha(character)) { + character = std::tolower(character); + } + } + return fres; } +} + static const char UUIDChars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; UUID Instance::UUIDGen() { diff --git a/utility.hpp b/utility.hpp index 0b9260c..de35db7 100644 --- a/utility.hpp +++ b/utility.hpp @@ -13,5 +13,6 @@ constexpr size_t strSplitInf = 0; std::vector strSplit(std::string_view s, char delimiter, size_t times = strSplitInf); std::tuple colonSplit(std::string_view s); void argsSizeCheck(std::string_view where, std::vector args, size_t expected); +std::string lowers(std::string_view str); } #endif