Added MODE and invite only functionality
This commit is contained in:
41
cmds/mode.cpp
Normal file
41
cmds/mode.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* mode.cpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: iherman- <iherman-@student.42malaga.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2026/05/23 17:15:27 by iherman- #+# #+# */
|
||||
/* Updated: 2026/05/23 18:35:51 by iherman- ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../Server/Server.hpp"
|
||||
|
||||
void Server::mode_cmd(User &client, std::istringstream &ss)
|
||||
{
|
||||
std::string target;
|
||||
std::string mode;
|
||||
std::string args;
|
||||
|
||||
ss >> target >> mode;
|
||||
std::getline(ss, args);
|
||||
|
||||
if (!client.isRegistered()) return (client.send(":" SERVER_NAME " 451 * :You have not registered\r\n"));
|
||||
if (target.empty() || mode.empty()) return (client.send(":" SERVER_NAME " 461 " + client.getNick() + " MODE :Not enough parameters\r\n"));
|
||||
|
||||
std::map<std::string, Channel>::iterator channel = channels_.find(target);
|
||||
if (channel == channels_.end())
|
||||
{
|
||||
client.send(":" SERVER_NAME " 403 " + client.getNick() + target + ":No such channel");
|
||||
return ;
|
||||
}
|
||||
|
||||
if (!channel->second.hasOperator(client.getFd()))
|
||||
{
|
||||
client.send(std::string(":") + SERVER_NAME + " 482 " + client.getNick() + " " + channel->second.getName() + " :You're not channel operator\r\n");
|
||||
return ;
|
||||
}
|
||||
|
||||
channel->second.setMode(mode, args);
|
||||
}
|
||||
Reference in New Issue
Block a user