now broadcast send message to every member of channel, excluding the author of message

This commit is contained in:
aortigos
2026-05-15 23:11:02 +02:00
parent 9a2d7919fb
commit a21bac6e47
8 changed files with 65 additions and 14 deletions

View File

@@ -6,7 +6,7 @@
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/05/15 15:35:16 by aortigos #+# #+# */
/* Updated: 2026/05/15 22:06:36 by aortigos ### ########.fr */
/* Updated: 2026/05/15 22:18:52 by aortigos ### ########.fr */
/* */
/* ************************************************************************** */
@@ -18,14 +18,13 @@ void Server::join_cmd(User &client, std::istringstream &ss)
std::string args;
ss >> args;
if (!client.isRegistered()) return (client.send("You are not registered"));
if (!client.isRegistered()) return (client.send("You are not registered\r\n"));
if (args.empty()) return (client.send("No name specified\r\n"));
std::map<std::string, Channel>::iterator it = channels_.find(args);
if (it == channels_.end())
{
// Channel doesnt exists, create and join
channels_[args] = Channel(args);
channels_[args].addMember(client.getFd());
channels_[args].addOperator(client.getFd());
@@ -33,7 +32,9 @@ void Server::join_cmd(User &client, std::istringstream &ss)
}
else
{
if (it->second.hasMember(client.getFd())) return (client.send("You are already in this channel\r\n"));
it->second.addMember(client.getFd());
if (it->second.hasMember(client.getFd()))
client.send("You are already in this channel\r\n");
else
it->second.addMember(client.getFd());
}
}