Files
irc/commands/part.cpp
aortigos 94028a5215 part cmd
2026-04-19 01:47:20 +02:00

39 lines
1.4 KiB
C++

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* 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);
}
}