Adding join channels and privmsg

This commit is contained in:
2026-04-17 19:12:05 +02:00
parent b3c190293a
commit 1c8ad9ba68
5 changed files with 64 additions and 14 deletions

View File

@@ -6,7 +6,7 @@
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/04/17 16:26:18 by aortigos #+# #+# */
/* Updated: 2026/04/17 18:44:02 by aortigos ### ########.fr */
/* Updated: 2026/04/17 18:54:46 by aortigos ### ########.fr */
/* */
/* ************************************************************************** */
@@ -20,15 +20,26 @@ void Server::cmd_join(int fd, std::istringstream &ss)
if (!clients[fd].isRegistered())
{
std::string msg = "You are not registered";
std::string msg = "You are not registered\r\n";
send(fd, msg.c_str(), msg.size(), 0);
return ;
}
if (channels.find(channelName) == channels.end())
if (channels.find(args) == channels.end())
{
channels.insert(std::make_pair(args, Channel(args)));
channels[args].addMember(fd);
std::string msg = "Channel created\r\n";
send(fd, msg.c_str(), msg.size(), 0);
} else {
channels[args].addMember(fd);
std::string msg = "Channel already exists\r\n";
send(fd, msg.c_str(), msg.size(), 0);
return ;
}
}