This commit is contained in:
2024-01-29 20:12:18 +01:00
parent fbcb5873bb
commit ce9e6d7b02
3 changed files with 16 additions and 8 deletions

View File

@@ -6,7 +6,7 @@
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */ /* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/21 10:34:25 by maldavid #+# #+# */ /* 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; } inline bool isInviteOnly() const { return _invite_only; }
void setTopic(unstd::SharedPtr<Client> client, const std::string& new_topic); void setTopic(unstd::SharedPtr<Client> client, const std::string& new_topic);
void relayTopic(unstd::SharedPtr<Client> client); void relayTopic(unstd::SharedPtr<Client> client, bool broadcast = false);
void showModesModify(unstd::SharedPtr<Client> client, const Message& msg) const; void showModesModify(unstd::SharedPtr<Client> client, const Message& msg) const;
void showModes(unstd::SharedPtr<Client> client); void showModes(unstd::SharedPtr<Client> client);
bool kick(unstd::SharedPtr<Client> op, unstd::SharedPtr<Client> target, const std::string& reason); bool kick(unstd::SharedPtr<Client> op, unstd::SharedPtr<Client> target, const std::string& reason);

View File

@@ -6,7 +6,7 @@
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */ /* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/21 10:36:21 by maldavid #+# #+# */ /* 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; return;
} }
_topic = new_topic; _topic = new_topic;
relayTopic(client); relayTopic(client, true);
} }
void Channel::relayTopic(unstd::SharedPtr<Client> client) void Channel::relayTopic(unstd::SharedPtr<Client> client, bool broadcast)
{ {
if(!hasClient(client)) if(!hasClient(client))
return; return;
if(_topic.empty()) 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<unstd::SharedPtr<irc::Client>&>(*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<unstd::SharedPtr<irc::Client>&>(*it)->sendCode(":yipirc " RPL_TOPIC, client->getNickName() + " " + _name, _topic);
} }
bool Channel::isOp(unstd::SharedPtr<Client> client) const bool Channel::isOp(unstd::SharedPtr<Client> client) const

View File

@@ -6,7 +6,7 @@
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */ /* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/22 17:31:06 by maldavid #+# #+# */ /* 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 */
/* */ /* */
/******************************************************************************/ /******************************************************************************/