mirror of
https://github.com/Ladebeze66/ft_irc.git
synced 2025-12-17 06:28:03 +01:00
Merge branch 'save' of github.com:Ladebeze66/ft_irc into jcheca
This commit is contained in:
commit
ad3f0bae39
100
.vscode/settings.json
vendored
100
.vscode/settings.json
vendored
@ -57,53 +57,55 @@
|
|||||||
"C_Cpp_Runner.useLinkTimeOptimization": false,
|
"C_Cpp_Runner.useLinkTimeOptimization": false,
|
||||||
"C_Cpp_Runner.msvcSecureNoWarnings": false,
|
"C_Cpp_Runner.msvcSecureNoWarnings": false,
|
||||||
"files.associations": {
|
"files.associations": {
|
||||||
"array": "cpp",
|
"array": "cpp",
|
||||||
"atomic": "cpp",
|
"atomic": "cpp",
|
||||||
"bit": "cpp",
|
"bit": "cpp",
|
||||||
"*.tcc": "cpp",
|
"*.tcc": "cpp",
|
||||||
"cctype": "cpp",
|
"cctype": "cpp",
|
||||||
"clocale": "cpp",
|
"clocale": "cpp",
|
||||||
"cmath": "cpp",
|
"cmath": "cpp",
|
||||||
"compare": "cpp",
|
"compare": "cpp",
|
||||||
"concepts": "cpp",
|
"concepts": "cpp",
|
||||||
"cstdarg": "cpp",
|
"cstdarg": "cpp",
|
||||||
"cstddef": "cpp",
|
"cstddef": "cpp",
|
||||||
"cstdint": "cpp",
|
"cstdint": "cpp",
|
||||||
"cstdio": "cpp",
|
"cstdio": "cpp",
|
||||||
"cstdlib": "cpp",
|
"cstdlib": "cpp",
|
||||||
"cstring": "cpp",
|
"cstring": "cpp",
|
||||||
"cwchar": "cpp",
|
"cwchar": "cpp",
|
||||||
"cwctype": "cpp",
|
"cwctype": "cpp",
|
||||||
"deque": "cpp",
|
"deque": "cpp",
|
||||||
"string": "cpp",
|
"string": "cpp",
|
||||||
"unordered_map": "cpp",
|
"unordered_map": "cpp",
|
||||||
"vector": "cpp",
|
"vector": "cpp",
|
||||||
"exception": "cpp",
|
"exception": "cpp",
|
||||||
"algorithm": "cpp",
|
"algorithm": "cpp",
|
||||||
"functional": "cpp",
|
"functional": "cpp",
|
||||||
"iterator": "cpp",
|
"iterator": "cpp",
|
||||||
"memory": "cpp",
|
"memory": "cpp",
|
||||||
"memory_resource": "cpp",
|
"memory_resource": "cpp",
|
||||||
"numeric": "cpp",
|
"numeric": "cpp",
|
||||||
"random": "cpp",
|
"random": "cpp",
|
||||||
"string_view": "cpp",
|
"string_view": "cpp",
|
||||||
"system_error": "cpp",
|
"system_error": "cpp",
|
||||||
"tuple": "cpp",
|
"tuple": "cpp",
|
||||||
"type_traits": "cpp",
|
"type_traits": "cpp",
|
||||||
"utility": "cpp",
|
"utility": "cpp",
|
||||||
"initializer_list": "cpp",
|
"initializer_list": "cpp",
|
||||||
"iosfwd": "cpp",
|
"iosfwd": "cpp",
|
||||||
"iostream": "cpp",
|
"iostream": "cpp",
|
||||||
"istream": "cpp",
|
"istream": "cpp",
|
||||||
"limits": "cpp",
|
"limits": "cpp",
|
||||||
"new": "cpp",
|
"new": "cpp",
|
||||||
"numbers": "cpp",
|
"numbers": "cpp",
|
||||||
"ostream": "cpp",
|
"ostream": "cpp",
|
||||||
"sstream": "cpp",
|
"sstream": "cpp",
|
||||||
"stdexcept": "cpp",
|
"stdexcept": "cpp",
|
||||||
"streambuf": "cpp",
|
"streambuf": "cpp",
|
||||||
"typeinfo": "cpp",
|
"typeinfo": "cpp",
|
||||||
"ctime": "cpp",
|
"ctime": "cpp",
|
||||||
"map": "cpp"
|
"map": "cpp",
|
||||||
}
|
"set": "cpp",
|
||||||
|
"fstream": "cpp"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/15 12:41:35 by fgras-ca #+# #+# */
|
/* Created: 2024/05/15 12:41:35 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/01 18:49:53 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/04 16:12:23 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -51,6 +51,7 @@ class Channel
|
|||||||
const std::string &getTopicSetter() const;
|
const std::string &getTopicSetter() const;
|
||||||
time_t getTopicTime() const;
|
time_t getTopicTime() const;
|
||||||
void setTopic(const std::string &topic, const std::string &setter);
|
void setTopic(const std::string &topic, const std::string &setter);
|
||||||
|
std::string getKey();
|
||||||
|
|
||||||
void setClientLimit(size_t limit);
|
void setClientLimit(size_t limit);
|
||||||
size_t getClientLimit() const;
|
size_t getClientLimit() const;
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/15 12:15:42 by fgras-ca #+# #+# */
|
/* Created: 2024/05/15 12:15:42 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/01 18:47:36 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/05 09:34:30 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -43,7 +43,6 @@ public:
|
|||||||
void setAway(bool away);
|
void setAway(bool away);
|
||||||
std::string getKey() const;
|
std::string getKey() const;
|
||||||
void setkey(const std::string &key);
|
void setkey(const std::string &key);
|
||||||
|
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
char buffer2[1024];
|
char buffer2[1024];
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/15 18:30:07 by fgras-ca #+# #+# */
|
/* Created: 2024/05/15 18:30:07 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/01 18:50:30 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/05 09:37:10 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/30 11:12:57 by fgras-ca #+# #+# */
|
/* Created: 2024/05/30 11:12:57 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/01 18:52:10 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/04 14:00:47 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ class ModeHandler
|
|||||||
|
|
||||||
void setChannelMode(Client *client, Channel* channel, const std::string& mode, bool adding, const std::string& argument);
|
void setChannelMode(Client *client, Channel* channel, const std::string& mode, bool adding, const std::string& argument);
|
||||||
void applyModeL(Client *client, Channel* channel, bool adding, const std::string& argument);
|
void applyModeL(Client *client, Channel* channel, bool adding, const std::string& argument);
|
||||||
void applyModeI(Channel* channel, bool adding);
|
void applyModeI(Client *client, Channel* channel, bool adding);
|
||||||
void applyModeK(Client *client, Channel* channel, bool adding, const std::string& argument);
|
void applyModeK(Client *client, Channel* channel, bool adding, const std::string& argument);
|
||||||
void applyModeT(Channel* channel, bool adding);
|
void applyModeT(Channel* channel, bool adding);
|
||||||
void applyModeO(Client *client, Channel* channel, bool adding, const std::string& argument);
|
void applyModeO(Client *client, Channel* channel, bool adding, const std::string& argument);
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/19 15:12:47 by fgras-ca #+# #+# */
|
/* Created: 2024/05/19 15:12:47 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/01 18:58:37 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/04 16:06:40 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include "Client.hpp"
|
#include "Client.hpp"
|
||||||
#include "Utils.hpp"
|
#include "Utils.hpp"
|
||||||
|
#include "Channel.hpp"
|
||||||
|
|
||||||
#define SERVER_NAME "IRC_Server"
|
#define SERVER_NAME "IRC_Server"
|
||||||
#define SERVER_VERSION "1.0"
|
#define SERVER_VERSION "1.0"
|
||||||
@ -411,6 +412,22 @@ inline std::string ERR_INVALIDKEY(Client* client, const std::string& channel)
|
|||||||
return oss.str();
|
return oss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline std::string ERR_KEYSET(Client* client, const std::string& channel)
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << ":" << SERVER_NAME << " 467 " << CLIENT_NICK(client) << " " << channel
|
||||||
|
<< " :Channel key already set\r\n";
|
||||||
|
return oss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::string ERR_LINKSET(Client* client, const std::string& channel)
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << ":" << SERVER_NAME << " 469 " << CLIENT_NICK(client) << " " << channel
|
||||||
|
<< " :No key set\r\n";
|
||||||
|
return oss.str();
|
||||||
|
}
|
||||||
|
|
||||||
inline std::string ERR_CHANNELISFULL(Client* client, const std::string& channel)
|
inline std::string ERR_CHANNELISFULL(Client* client, const std::string& channel)
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
@ -517,4 +534,11 @@ inline std::string RPL_CAPEND(Client *client)
|
|||||||
return oss.str();
|
return oss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline std::string MODEACCEPTMESSAGE(Client *client, std::string channel, const std::string& mode)
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << ":" << client->getNickname() << " MODE " << channel << " " << mode << " :" << "\r\n";
|
||||||
|
return oss.str();
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/15 12:15:13 by fgras-ca #+# #+# */
|
/* Created: 2024/05/15 12:15:13 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/01 19:01:40 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/04 15:03:28 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -83,9 +83,6 @@ class Server
|
|||||||
private:
|
private:
|
||||||
void initServer();
|
void initServer();
|
||||||
void handleServerCommands();
|
void handleServerCommands();
|
||||||
void acceptClient();
|
|
||||||
void removeClient(int client_fd);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/16 15:27:29 by fgras-ca #+# #+# */
|
/* Created: 2024/05/16 15:27:29 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/01 19:05:15 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/04 13:55:09 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/15 12:42:57 by fgras-ca #+# #+# */
|
/* Created: 2024/05/15 12:42:57 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/01 19:06:40 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/04 16:12:22 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -141,6 +141,11 @@ void Channel::setKey(const std::string &key)
|
|||||||
_key = key;
|
_key = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Channel::getKey()
|
||||||
|
{
|
||||||
|
return _key;
|
||||||
|
}
|
||||||
|
|
||||||
void Channel::setTopicProtection(bool protection)
|
void Channel::setTopicProtection(bool protection)
|
||||||
{
|
{
|
||||||
_topicProtection = protection;
|
_topicProtection = protection;
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/15 18:32:23 by fgras-ca #+# #+# */
|
/* Created: 2024/05/15 18:32:23 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/01 19:07:39 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/05 10:12:30 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -79,7 +79,6 @@ void ClientManager::handleClient(int client_fd)
|
|||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ClientManager::handleClientNext(int client_fd, char * buffer, int bytes_received)
|
void ClientManager::handleClientNext(int client_fd, char * buffer, int bytes_received)
|
||||||
{
|
{
|
||||||
std::string message(buffer, bytes_received);
|
std::string message(buffer, bytes_received);
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/15 18:26:34 by fgras-ca #+# #+# */
|
/* Created: 2024/05/15 18:26:34 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/01 19:10:48 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/05 09:57:55 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/30 11:13:08 by fgras-ca #+# #+# */
|
/* Created: 2024/05/30 11:13:08 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/01 19:15:05 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/04 16:12:50 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ void ModeHandler::setChannelMode(Client *client, Channel* channel, const std::st
|
|||||||
}
|
}
|
||||||
else if (mode == "i")
|
else if (mode == "i")
|
||||||
{
|
{
|
||||||
applyModeI(channel, adding);
|
applyModeI(client, channel, adding);
|
||||||
}
|
}
|
||||||
else if (mode == "k")
|
else if (mode == "k")
|
||||||
{
|
{
|
||||||
@ -171,16 +171,34 @@ void ModeHandler::applyModeL(Client *client, Channel* channel, bool adding, cons
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModeHandler::applyModeI(Channel* channel, bool adding)
|
void ModeHandler::applyModeI(Client *client, Channel *channel, bool adding)
|
||||||
{
|
{
|
||||||
_server->log("Applying mode I: " + std::string(adding ? "Setting invite-only" : "Removing invite-only"), GREEN);
|
std::string modeChange;
|
||||||
channel->setInviteOnly(adding);
|
bool isAlreadySet;
|
||||||
|
|
||||||
|
modeChange = adding ? "+i" : "-i";
|
||||||
|
isAlreadySet = channel->isInviteOnly() == adding;
|
||||||
|
if (!isAlreadySet)
|
||||||
|
{
|
||||||
|
_server->sendToClient(client->getFd(), MODEACCEPTMESSAGE(client, channel->getName(), modeChange));
|
||||||
|
_server->log("Applying mode I: " + std::string(adding ? "Setting invite-only" : "Removing invite-only"), GREEN);
|
||||||
|
channel->setInviteOnly(adding);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModeHandler::applyModeK(Client *client, Channel* channel, bool adding, const std::string& argument)
|
void ModeHandler::applyModeK(Client *client, Channel *channel, bool adding, const std::string &argument)
|
||||||
{
|
{
|
||||||
|
bool isAlreadyProtected;
|
||||||
|
|
||||||
|
isAlreadyProtected = !channel->getKey().empty();
|
||||||
if (adding)
|
if (adding)
|
||||||
{
|
{
|
||||||
|
if (isAlreadyProtected)
|
||||||
|
{
|
||||||
|
_server->sendToClient(client->getFd(), ERR_KEYSET(client, channel->getName()));
|
||||||
|
_server->log("Mode +k error: Channel already has a key set", RED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (argument.empty())
|
if (argument.empty())
|
||||||
{
|
{
|
||||||
_server->sendToClient(client->getFd(), ERR_NEEDMOREPARAMS(client, "MODE +k"));
|
_server->sendToClient(client->getFd(), ERR_NEEDMOREPARAMS(client, "MODE +k"));
|
||||||
@ -193,11 +211,19 @@ void ModeHandler::applyModeK(Client *client, Channel* channel, bool adding, cons
|
|||||||
_server->log("Invalid key for mode +k: contains spaces", RED);
|
_server->log("Invalid key for mode +k: contains spaces", RED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
_server->sendToClient(client->getFd(), MODEACCEPTMESSAGE(client, channel->getName(), "+k " + argument));
|
||||||
_server->log("Applying mode K: Setting key to " + argument, GREEN);
|
_server->log("Applying mode K: Setting key to " + argument, GREEN);
|
||||||
channel->setKey(argument);
|
channel->setKey(argument);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (!isAlreadyProtected)
|
||||||
|
{
|
||||||
|
_server->sendToClient(client->getFd(), ERR_LINKSET(client, channel->getName()));
|
||||||
|
_server->log("Mode -k error: No key to remove", RED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_server->sendToClient(client->getFd(), MODEACCEPTMESSAGE(client, channel->getName(), "-k"));
|
||||||
_server->log("Applying mode K: Removing key", RED);
|
_server->log("Applying mode K: Removing key", RED);
|
||||||
channel->setKey("");
|
channel->setKey("");
|
||||||
}
|
}
|
||||||
@ -205,8 +231,16 @@ void ModeHandler::applyModeK(Client *client, Channel* channel, bool adding, cons
|
|||||||
|
|
||||||
void ModeHandler::applyModeT(Channel* channel, bool adding)
|
void ModeHandler::applyModeT(Channel* channel, bool adding)
|
||||||
{
|
{
|
||||||
_server->log("Applying mode T: " + std::string(adding ? "Setting topic protection" : "Removing topic protection"), GREEN);
|
std::string modeChange;
|
||||||
channel->setTopicProtection(adding);
|
bool isAlreadySet;
|
||||||
|
|
||||||
|
modeChange = adding ? "+t" : "-t";
|
||||||
|
isAlreadySet = channel->isInviteOnly() == adding;
|
||||||
|
if (!isAlreadySet)
|
||||||
|
{
|
||||||
|
_server->log("Applying mode T: " + std::string(adding ? "Setting topic protection" : "Removing topic protection"), GREEN);
|
||||||
|
channel->setTopicProtection(adding);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModeHandler::applyModeO(Client* client, Channel* channel, bool adding, const std::string& argument)
|
void ModeHandler::applyModeO(Client* client, Channel* channel, bool adding, const std::string& argument)
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/15 12:17:12 by fgras-ca #+# #+# */
|
/* Created: 2024/05/15 12:17:12 by fgras-ca #+# #+# */
|
||||||
/* Updated: 2024/06/01 19:16:36 by fgras-ca ### ########.fr */
|
/* Updated: 2024/06/05 10:18:02 by fgras-ca ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -245,4 +245,4 @@ void Server::disconnectClient(int clientFd)
|
|||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << "Client disconnected: " << clientFd;
|
oss << "Client disconnected: " << clientFd;
|
||||||
log(oss.str(), YELLOW);
|
log(oss.str(), YELLOW);
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user