This commit is contained in:
2024-01-29 21:20:02 +01:00
parent a09fc23bd1
commit cd455bf3f6
6 changed files with 53 additions and 6 deletions

View File

@@ -6,7 +6,7 @@
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/21 10:36:21 by maldavid #+# #+# */
/* Updated: 2024/01/29 20:16:47 by maldavid ### ########.fr */
/* Updated: 2024/01/29 21:08:18 by vvaas ### ########.fr */
/* */
/******************************************************************************/
@@ -166,6 +166,10 @@ namespace irc
}
if (modevalue)
_channel_size = std::atoi(msg.getTokens()[3].c_str());
break ;
default :
client->sendCode(":yipirc " ERR_UNKNOWNMODE " @", getName().c_str(), "Unknown mode");
return ;
}
logs::report(log_message, "%s MODES : i:%d t:%d k:%s l:%d", getName().c_str(), _invite_only, _topic_op_restrict, _password.c_str(), _channel_size);
showModesModify(client, msg);

View File

@@ -6,7 +6,7 @@
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/21 10:35:52 by maldavid #+# #+# */
/* Updated: 2024/01/26 02:26:04 by vvaas ### ########.fr */
/* Updated: 2024/01/29 21:18:33 by vvaas ### ########.fr */
/* */
/******************************************************************************/
@@ -21,6 +21,7 @@
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <channel.hpp>
namespace irc
{
@@ -46,6 +47,16 @@ namespace irc
logs::report(log_error, "server failed to send a code to '%s' (:sadge:)", _username.c_str());
}
void Client::sendCodeInChannel(const std::string& code, const Channel &chan, const std::string& msg)
{
const std::string command = ":yipirc " + code + " " + getNickName() + " " + chan.getName() + " :" + msg + "\r\n";
#ifdef DEBUG
logs::report(log_message, "sending '%s'", command.c_str());
#endif
if(send(_fd, command.c_str(), command.size(), 0) != static_cast<ssize_t>(command.length()))
logs::report(log_error, "server failed to send a code to '%s' (:sadge:)", _username.c_str());
}
void Client::sendPlainText(const std::string& str)
{
#ifdef DEBUG

View File

@@ -6,7 +6,7 @@
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/22 17:31:06 by maldavid #+# #+# */
/* Updated: 2024/01/29 20:01:48 by vvaas ### ########.fr */
/* Updated: 2024/01/29 21:16:00 by vvaas ### ########.fr */
/* */
/******************************************************************************/
@@ -429,7 +429,7 @@ namespace irc
return ;
}
if(!chan->isOp(client))
client->sendCode(ERR_CHANOPRIVSNEEDED, "You need operator privileges to execute this command");
client->sendCodeInChannel(ERR_CHANOPRIVSNEEDED, *chan, "You need operator privileges to execute this command");
if(msg.getTokens()[2][0] != '-' && msg.getTokens()[2][0] != '+')
return ;
chan->changeMode(client, msg);