From 2ba04ebcfe2e009e13e3ce922d13b997c32b1f22 Mon Sep 17 00:00:00 2001 From: Kbz-8 Date: Wed, 24 Jan 2024 19:33:14 +0100 Subject: [PATCH 1/2] sfjhbsdabdsfjbd --- .vscode/settings.json | 57 --------------------------------------- srcs/server_functions.cpp | 30 +++++++++++++++++---- 2 files changed, 25 insertions(+), 62 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 5b3d663..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "files.associations": { - "array": "cpp", - "atomic": "cpp", - "bit": "cpp", - "*.tcc": "cpp", - "cctype": "cpp", - "clocale": "cpp", - "cmath": "cpp", - "compare": "cpp", - "concepts": "cpp", - "csignal": "cpp", - "cstdarg": "cpp", - "cstddef": "cpp", - "cstdint": "cpp", - "cstdio": "cpp", - "cstdlib": "cpp", - "cstring": "cpp", - "cwchar": "cpp", - "cwctype": "cpp", - "deque": "cpp", - "map": "cpp", - "set": "cpp", - "unordered_map": "cpp", - "vector": "cpp", - "exception": "cpp", - "algorithm": "cpp", - "functional": "cpp", - "iterator": "cpp", - "memory": "cpp", - "memory_resource": "cpp", - "numeric": "cpp", - "optional": "cpp", - "random": "cpp", - "string": "cpp", - "string_view": "cpp", - "system_error": "cpp", - "tuple": "cpp", - "type_traits": "cpp", - "utility": "cpp", - "initializer_list": "cpp", - "iosfwd": "cpp", - "iostream": "cpp", - "istream": "cpp", - "limits": "cpp", - "new": "cpp", - "numbers": "cpp", - "ostream": "cpp", - "ranges": "cpp", - "span": "cpp", - "sstream": "cpp", - "stdexcept": "cpp", - "streambuf": "cpp", - "cinttypes": "cpp", - "typeinfo": "cpp" - } -} \ No newline at end of file diff --git a/srcs/server_functions.cpp b/srcs/server_functions.cpp index f319dbc..3334f8e 100644 --- a/srcs/server_functions.cpp +++ b/srcs/server_functions.cpp @@ -6,7 +6,7 @@ /* By: vvaas +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/22 17:31:06 by maldavid #+# #+# */ -/* Updated: 2024/01/24 19:23:56 by vvaas ### ########.fr */ +/* Updated: 2024/01/24 19:32:55 by maldavid ### ########.fr */ /* */ /******************************************************************************/ @@ -177,7 +177,6 @@ namespace irc logs::report(log_error, "PRIVMSG, invalid command '%s'", msg.getRawMsg().c_str()); return; } - channel_it it; if (msg.getTokens()[1][0] != '&' && msg.getTokens()[1][0] != '#') { for (client_it itc = _client.begin(); itc != _client.end(); ++itc) @@ -200,7 +199,7 @@ namespace irc } return ; } - for(it = _channels.begin(); it != _channels.end(); ++it) + for(channel_it it = _channels.begin(); it != _channels.end(); ++it) { if(msg.getTokens()[1] == it->getName()) { @@ -227,8 +226,29 @@ namespace irc logs::report(log_error, "NOTICE, invalid command '%s'", msg.getRawMsg().c_str()); return; } - channel_it it; - for(it = _channels.begin(); it != _channels.end(); ++it) + if (msg.getTokens()[1][0] != '&' && msg.getTokens()[1][0] != '#') + { + for (client_it itc = _client.begin(); itc != _client.end(); ++itc) + { + if ((*itc)->getNickName() == msg.getTokens()[1] && (*itc)->getNickName() != client->getNickName()) + { + std::string complete_msg; + if(msg.getTokens().size() > 2) + { + for(std::vector::const_iterator tit = msg.getTokens().begin() + 2; tit < msg.getTokens().end(); ++tit) + { + complete_msg.append(*tit); + complete_msg.append(" "); + } + complete_msg.erase(complete_msg.begin()); + } + (*itc)->sendMsg(client->getNickName(), "NOTICE " + (*itc)->getNickName(), complete_msg); + break; + } + } + return ; + } + for(channel_it it = _channels.begin(); it != _channels.end(); ++it) { if(msg.getTokens()[1] == it->getName()) { From 0519dc42b8a070dee7fa81f717cb184c31d810c7 Mon Sep 17 00:00:00 2001 From: Kbz-8 Date: Wed, 24 Jan 2024 19:57:21 +0100 Subject: [PATCH 2/2] sfjhbsdabdsfjbd2 --- includes/server.hpp | 3 ++- srcs/server.cpp | 4 +++- srcs/server_functions.cpp | 8 +++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/includes/server.hpp b/includes/server.hpp index 1585d99..0c0802c 100644 --- a/includes/server.hpp +++ b/includes/server.hpp @@ -6,7 +6,7 @@ /* By: vvaas +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/21 09:12:28 by maldavid #+# #+# */ -/* Updated: 2024/01/24 15:14:05 by maldavid ### ########.fr */ +/* Updated: 2024/01/24 19:57:00 by maldavid ### ########.fr */ /* */ /******************************************************************************/ @@ -54,6 +54,7 @@ namespace irc void handleQuit(unstd::SharedPtr client, const class Message& msg); void handlePart(unstd::SharedPtr client, const class Message& msg); void handleJoin(unstd::SharedPtr client, const class Message& msg); + void handleInvite(unstd::SharedPtr client, const class Message& msg); void handlePrivMsg(unstd::SharedPtr client, const class Message& msg); void handleNotice(unstd::SharedPtr client, const class Message& msg); void handleKick(unstd::SharedPtr client, const class Message& msg); diff --git a/srcs/server.cpp b/srcs/server.cpp index f728f1b..c89bff9 100644 --- a/srcs/server.cpp +++ b/srcs/server.cpp @@ -6,7 +6,7 @@ /* By: vvaas +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/21 09:31:17 by maldavid #+# #+# */ -/* Updated: 2024/01/24 19:06:59 by vvaas ### ########.fr */ +/* Updated: 2024/01/24 19:56:43 by maldavid ### ########.fr */ /* */ /******************************************************************************/ @@ -141,6 +141,8 @@ namespace irc handlePart(client, msg); else if(msg.getCmd() == "JOIN") handleJoin(client, msg); + else if(msg.getCmd() == "INVITE") + handlePrivMsg(client, msg); else if(msg.getCmd() == "PRIVMSG") handlePrivMsg(client, msg); else if(msg.getCmd() == "NOTICE") diff --git a/srcs/server_functions.cpp b/srcs/server_functions.cpp index 3334f8e..0453a72 100644 --- a/srcs/server_functions.cpp +++ b/srcs/server_functions.cpp @@ -6,7 +6,7 @@ /* By: vvaas +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/22 17:31:06 by maldavid #+# #+# */ -/* Updated: 2024/01/24 19:32:55 by maldavid ### ########.fr */ +/* Updated: 2024/01/24 19:57:12 by maldavid ### ########.fr */ /* */ /******************************************************************************/ @@ -268,6 +268,12 @@ namespace irc } } + void Server::handleInvite(unstd::SharedPtr client, const Message& msg) + { + (void)client; + (void)msg; + } + void Server::handleKick(unstd::SharedPtr client, const Message& msg) { (void)client;