mode -o done
This commit is contained in:
32
Server.cpp
32
Server.cpp
@@ -802,6 +802,38 @@ void Server::handleClientData(int fd) {
|
|||||||
send(fd, errorMessage.c_str(), errorMessage.size(), 0);
|
send(fd, errorMessage.c_str(), errorMessage.size(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (startsWith(command, "MODE "))
|
||||||
|
{
|
||||||
|
std::string channelName, mode , nick;
|
||||||
|
std::istringstream iss(command.substr(6));
|
||||||
|
iss >> channelName >> mode >> nick;
|
||||||
|
channelName = trim(channelName);
|
||||||
|
mode = trim(mode);
|
||||||
|
nick = trim(nick);
|
||||||
|
|
||||||
|
|
||||||
|
std::cout << "this is the mode : " << mode << std::endl;
|
||||||
|
if (mode == "+o")
|
||||||
|
{
|
||||||
|
if (channels.find(channelName) != channels.end() && channels[channelName].isOperator(fd)) {
|
||||||
|
channels[channelName].addOperator(nick, channels[channelName].getUserFd(nick));
|
||||||
|
std::string modeMessage = ":" + nick + " MODE #" + channelName + " +o " + nick + "\n";
|
||||||
|
send(fd, modeMessage.c_str(), modeMessage.length(), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (mode == "-o")
|
||||||
|
{
|
||||||
|
if (channels.find(channelName) != channels.end() && channels[channelName].isOperator(fd)) {
|
||||||
|
channels[channelName].removeOperator(nick);
|
||||||
|
std::string modeMessage = ":" + nick + " MODE #" + channelName + " -o " + nick + "\n";
|
||||||
|
send(fd, modeMessage.c_str(), modeMessage.length(), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// else if (mode == "-i")
|
||||||
|
// {
|
||||||
|
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
//**************** STOOOOOOP HERE TOP G ...
|
//**************** STOOOOOOP HERE TOP G ...
|
||||||
break;
|
break;
|
||||||
|
13
channel.hpp
13
channel.hpp
@@ -142,6 +142,19 @@ std::string getOperatorNickname(int fd) const {
|
|||||||
return ""; // Return empty string if operator not found
|
return ""; // Return empty string if operator not found
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void removeOperator(const std::string& operatorName )
|
||||||
|
{
|
||||||
|
// Iterate through the map to find the operator
|
||||||
|
std::map<std::string, int>::iterator it;
|
||||||
|
for (it = operators.begin(); it != operators.end(); ++it) {
|
||||||
|
if (it->first == operatorName) {
|
||||||
|
// Erase the operator from the map
|
||||||
|
operators.erase(it);
|
||||||
|
return; // Exit the function after removing the operator
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Remove an operator from the channel
|
// Remove an operator from the channel
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user