gg
This commit is contained in:
2
Makefile
2
Makefile
@@ -6,7 +6,7 @@
|
||||
# By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2023/08/09 15:08:49 by vavaas #+# #+# #
|
||||
# Updated: 2024/01/25 15:22:06 by maldavid ### ########.fr #
|
||||
# Updated: 2024/01/29 20:44:32 by vvaas ### ########.fr #
|
||||
# #
|
||||
#******************************************************************************#
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/21 10:33:17 by maldavid #+# #+# */
|
||||
/* Updated: 2024/01/26 00:58:20 by vvaas ### ########.fr */
|
||||
/* Updated: 2024/01/29 21:16:38 by vvaas ### ########.fr */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
|
||||
@@ -55,6 +55,7 @@ namespace irc
|
||||
void sendCode(const std::string& code, const std::string& msg0, const std::string& msg1);
|
||||
void sendMsg(const std::string& sender, const std::string& cmd, const std::string& trailing);
|
||||
void sendModular(std::string message, ...);
|
||||
void sendCodeInChannel(const std::string& code, const class Channel &chan, const std::string& msg);
|
||||
|
||||
~Client();
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
31
srcs_bonus/main.cpp
Normal file
31
srcs_bonus/main.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
/******************************************************************************/
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* main.cpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/29 20:36:23 by vvaas #+# #+# */
|
||||
/* Updated: 2024/01/29 20:41:45 by vvaas ### ########.fr */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
|
||||
#include <irc.hpp>
|
||||
#include <logs.hpp>
|
||||
|
||||
#define IP "127.0.0.1"
|
||||
#define PORT 6667
|
||||
int main()
|
||||
{
|
||||
struct sockaddr_in serv_addr;
|
||||
int fd = socket(AF_LOCAL, SOCK_STREAM, 0);
|
||||
if (fd == -1)
|
||||
irc::logs::report(irc::log_fatal_error, "FD error");
|
||||
serv_addr.sin_family = AF_INET;
|
||||
serv_addr.sin_port = htons(PORT);
|
||||
if (connect(fd, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0)
|
||||
{
|
||||
irc::logs::report(irc::log_fatal_error, "connect error");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user