This commit is contained in:
aortigos
2026-04-19 01:47:20 +02:00
parent 1c8ad9ba68
commit 94028a5215
7 changed files with 58 additions and 7 deletions

View File

@@ -0,0 +1,39 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* part.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/04/19 01:31:40 by aortigos #+# #+# */
/* Updated: 2026/04/19 01:44:14 by aortigos ### ########.fr */
/* */
/* ************************************************************************** */
#include "../Server/Server.hpp"
void Server::cmd_part(int fd, std::istringstream &ss)
{
std::string args;
ss >> args;
if (!clients[fd].isRegistered())
{
std::string msg = "You are not registered\r\n";
send(fd, msg.c_str(), msg.size(), 0);
return ;
}
if (channels.find(args) != channels.end() && channels[args].isMember(fd))
{
channels[args].removeMember(fd);
std::string msg = "You left the channel\r\n";
send(fd, msg.c_str(), msg.size(), 0);
} else {
std::string msg = "You dont belong to this channel\r\n";
send(fd, msg.c_str(), msg.size(), 0);
}
}