diff --git a/includes/channel.hpp b/includes/channel.hpp index dcd0cbe..ab73e15 100644 --- a/includes/channel.hpp +++ b/includes/channel.hpp @@ -6,7 +6,7 @@ /* By: vvaas +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/21 10:34:25 by maldavid #+# #+# */ -/* Updated: 2024/01/29 18:31:14 by vvaas ### ########.fr */ +/* Updated: 2024/01/29 20:04:19 by vvaas ### ########.fr */ /* */ /******************************************************************************/ @@ -54,7 +54,7 @@ namespace irc inline bool isInviteOnly() const { return _invite_only; } void setTopic(unstd::SharedPtr client, const std::string& new_topic); - void relayTopic(unstd::SharedPtr client); + void relayTopic(unstd::SharedPtr client, bool broadcast = false); void showModesModify(unstd::SharedPtr client, const Message& msg) const; void showModes(unstd::SharedPtr client); bool kick(unstd::SharedPtr op, unstd::SharedPtr target, const std::string& reason); diff --git a/srcs/channel.cpp b/srcs/channel.cpp index e14ae2c..a7f07e7 100644 --- a/srcs/channel.cpp +++ b/srcs/channel.cpp @@ -6,7 +6,7 @@ /* By: vvaas +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/21 10:36:21 by maldavid #+# #+# */ -/* Updated: 2024/01/29 19:57:34 by vvaas ### ########.fr */ +/* Updated: 2024/01/29 20:10:28 by vvaas ### ########.fr */ /* */ /******************************************************************************/ @@ -189,16 +189,24 @@ namespace irc return; } _topic = new_topic; - relayTopic(client); + relayTopic(client, true); } - void Channel::relayTopic(unstd::SharedPtr client) + void Channel::relayTopic(unstd::SharedPtr client, bool broadcast) { if(!hasClient(client)) return; if(_topic.empty()) - return client->sendCode(":yipirc" RPL_NOTOPIC, client->getNickName() + " " + _name, "no topic is set"); - return client->sendCode(":yipirc " RPL_TOPIC, client->getNickName() + " " + _name, _topic); + { + if (!broadcast) + return (client->sendCode(":yipirc " RPL_NOTOPIC, client->getNickName() + " " + _name, "no topic is set")); + for (client_it it = _clients.begin(); it != _clients.end(); ++ it) + const_cast&>(*it)->sendCode(":yipirc " RPL_NOTOPIC, client->getNickName() + " " + _name, "no topic is set"); + } + if (!broadcast) + return (client->sendCode(":yipirc " RPL_TOPIC, client->getNickName() + " " + _name, _topic)); + for (client_it it = _clients.begin(); it != _clients.end(); ++ it) + const_cast&>(*it)->sendCode(":yipirc " RPL_TOPIC, client->getNickName() + " " + _name, _topic); } bool Channel::isOp(unstd::SharedPtr client) const diff --git a/srcs/server_functions.cpp b/srcs/server_functions.cpp index 1daebee..d364853 100644 --- a/srcs/server_functions.cpp +++ b/srcs/server_functions.cpp @@ -6,7 +6,7 @@ /* By: vvaas +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/22 17:31:06 by maldavid #+# #+# */ -/* Updated: 2024/01/29 17:12:21 by vvaas ### ########.fr */ +/* Updated: 2024/01/29 20:01:48 by vvaas ### ########.fr */ /* */ /******************************************************************************/