Files
irc/commands/nick.cpp
2026-04-17 12:01:16 +02:00

38 lines
1.3 KiB
C++

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* nick.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/04/17 11:56:55 by aortigos #+# #+# */
/* Updated: 2026/04/17 11:59:33 by aortigos ### ########.fr */
/* */
/* ************************************************************************** */
#include "../Server/Server.hpp"
void Server::cmd_nick(int fd, std::istringstream &ss)
{
std::string args;
ss >> args;
if(!clients[fd].isAuthenticated())
{
send(fd, ERR_NOPASS.c_str(), ERR_NOPASS.size(), 0);
return ;
}
if (!args.empty())
{
clients[fd].setNick(args);
std::string msg = "Your nick has been updated!\r\n";
send(fd, msg.c_str(), msg.size(), 0);
}
else
{
send(fd, ERR_NONICK.c_str(), ERR_NONICK.size(), 0);
}
}