One file per command
This commit is contained in:
38
commands/nick.cpp
Normal file
38
commands/nick.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user