diff --git a/srcs/commands/channelCommands.cpp b/srcs/commands/channelCommands.cpp index 86ba266..67672ec 100644 --- a/srcs/commands/channelCommands.cpp +++ b/srcs/commands/channelCommands.cpp @@ -283,6 +283,8 @@ int Server::kickCmd(const Message &msg, User &user) sendError(user, ERR_NOTONCHANNEL, msg.getParams()[0]); else if (!containsNickname(msg.getParams()[1])) sendError(user, ERR_NOSUCHNICK, msg.getParams()[1]); + else if (!channels.at(msg.getParams()[0])->containsNickname(msg.getParams()[1])) + sendError(user, ERR_USERNOTINCHANNEL, msg.getParams()[1], msg.getParams()[0]); else { Channel *chan = channels.at(msg.getParams()[0]); @@ -305,22 +307,20 @@ int Server::partCmd(const Message &msg, User &user) else { std::queue chans = split(msg.getParams()[0], ',', false); - std::vector chansInVector; while (chans.size() > 0) { if (!containsChannel(chans.front())) - return sendError(user, ERR_NOSUCHCHANNEL, chans.front()); - if (!user.isOnChannel(chans.front())) - return sendError(user, ERR_NOTONCHANNEL, chans.front()); - chansInVector.push_back(chans.front()); + sendError(user, ERR_NOSUCHCHANNEL, chans.front()); + else if (!user.isOnChannel(chans.front())) + sendError(user, ERR_NOTONCHANNEL, chans.front()); + else + { + channels.at(chans.front())->sendMessage("PART " + chans.front() + "\n", user, true); + channels.at(chans.front())->disconnect(user); + user.removeChannel(chans.front()); + } chans.pop(); } - for (size_t i = 0; i < chansInVector.size(); ++i) - { - channels.at(chansInVector[i])->sendMessage("PART " + chansInVector[i] + "\n", user, true); - channels.at(chansInVector[i])->disconnect(user); - user.removeChannel(chansInVector[i]); - } } return 0; } diff --git a/srcs/commands/ircOperatorCommands.cpp b/srcs/commands/ircOperatorCommands.cpp index 8f63d01..4323771 100644 --- a/srcs/commands/ircOperatorCommands.cpp +++ b/srcs/commands/ircOperatorCommands.cpp @@ -59,4 +59,4 @@ int Server::restartCmd(const Message &msg, User &user) { // Start listening. listenSocket(); return 0; -} \ No newline at end of file +}