From 2ba04ebcfe2e009e13e3ce922d13b997c32b1f22 Mon Sep 17 00:00:00 2001 From: Kbz-8 Date: Wed, 24 Jan 2024 19:33:14 +0100 Subject: [PATCH] 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()) {