diff --git a/srcs/channel.cpp b/srcs/channel.cpp index 61a3a43..e70aef2 100644 --- a/srcs/channel.cpp +++ b/srcs/channel.cpp @@ -6,7 +6,7 @@ /* By: vvaas +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/21 10:36:21 by maldavid #+# #+# */ -/* Updated: 2024/01/23 17:23:24 by vvaas ### ########.fr */ +/* Updated: 2024/01/23 17:43:02 by vvaas ### ########.fr */ /* */ /******************************************************************************/ @@ -21,16 +21,12 @@ namespace irc void Channel::addClient(unstd::SharedPtr client) { - for (std::set >::iterator it = _clients.begin(); it != _clients.end(); ++it) + if (!_clients.insert(client).second) { - if (const_cast&>(*it)->getNickName() == client->getNickName()) - { - logs::report(log_message, "%s is already is channel for", client->getNickName().c_str()); - client->sendCode(ERR_USERONCHANNEL, "You are already in the channel"); - return ; - } + logs::report(log_message, "%s is already is channel for", client->getNickName().c_str()); + client->sendCode(ERR_USERONCHANNEL, "You are already in the channel"); + return ; } - logs::report(log_message, "i tried to insert %s, success : %d", client->getNickName().c_str(), _clients.insert(client).second); for(std::set >::iterator it = _clients.begin(); it != _clients.end(); ++it) { const_cast&>(*it)->sendMsg(client->getNickName(), "JOIN", _name);