diff --git a/ft_irc3/includes/AdditionalCommands.hpp b/ft_irc3/includes/AdditionalCommands.hpp index 0d7fce0..4f31577 100644 --- a/ft_irc3/includes/AdditionalCommands.hpp +++ b/ft_irc3/includes/AdditionalCommands.hpp @@ -6,7 +6,7 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/21 18:09:05 by fgras-ca #+# #+# */ -/* Updated: 2024/06/10 13:28:55 by fgras-ca ### ########.fr */ +/* Updated: 2024/06/11 13:30:49 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ @@ -24,6 +24,7 @@ #include "TopicHandler.hpp" #include "KickHandler.hpp" #include "BotFilter.hpp" +#include "Join.hpp" #include #include diff --git a/ft_irc3/includes/Join.hpp b/ft_irc3/includes/Join.hpp index c44393a..e3a3c2b 100644 --- a/ft_irc3/includes/Join.hpp +++ b/ft_irc3/includes/Join.hpp @@ -6,7 +6,7 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/21 19:51:08 by fgras-ca #+# #+# */ -/* Updated: 2024/06/01 18:51:10 by fgras-ca ### ########.fr */ +/* Updated: 2024/06/11 13:50:53 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ @@ -22,6 +22,7 @@ #include "Server.hpp" #include "Channel.hpp" #include "Client.hpp" +#include "AdditionalCommands.hpp" #include #include diff --git a/ft_irc3/includes/Server.hpp b/ft_irc3/includes/Server.hpp index 6daab96..53fd493 100644 --- a/ft_irc3/includes/Server.hpp +++ b/ft_irc3/includes/Server.hpp @@ -6,7 +6,7 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/15 12:15:13 by fgras-ca #+# #+# */ -/* Updated: 2024/06/06 18:51:31 by fgras-ca ### ########.fr */ +/* Updated: 2024/06/11 13:33:28 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ @@ -78,6 +78,7 @@ class Server ModeHandler *_modeHandler; TopicHandler *_topicHandler; BotFilter *_botFilter; + AdditionalCommands *_additionalCommands; friend class ClientManager; friend class CommandHandler; diff --git a/ft_irc3/ircserv b/ft_irc3/ircserv new file mode 100755 index 0000000..7b10533 Binary files /dev/null and b/ft_irc3/ircserv differ diff --git a/ft_irc3/logs/irc_server.log b/ft_irc3/logs/irc_server.log new file mode 100644 index 0000000..e69de29 diff --git a/ft_irc3/obj/AdditionalCommands.o b/ft_irc3/obj/AdditionalCommands.o new file mode 100644 index 0000000..1ab0cad Binary files /dev/null and b/ft_irc3/obj/AdditionalCommands.o differ diff --git a/ft_irc3/obj/BotFilter.o b/ft_irc3/obj/BotFilter.o new file mode 100644 index 0000000..25c53b3 Binary files /dev/null and b/ft_irc3/obj/BotFilter.o differ diff --git a/ft_irc3/obj/Channel.o b/ft_irc3/obj/Channel.o new file mode 100644 index 0000000..5dce2f5 Binary files /dev/null and b/ft_irc3/obj/Channel.o differ diff --git a/ft_irc3/obj/Client.o b/ft_irc3/obj/Client.o new file mode 100644 index 0000000..14b9f80 Binary files /dev/null and b/ft_irc3/obj/Client.o differ diff --git a/ft_irc3/obj/ClientManager.o b/ft_irc3/obj/ClientManager.o new file mode 100644 index 0000000..1c41243 Binary files /dev/null and b/ft_irc3/obj/ClientManager.o differ diff --git a/ft_irc3/obj/CommandHandler.o b/ft_irc3/obj/CommandHandler.o new file mode 100644 index 0000000..7113314 Binary files /dev/null and b/ft_irc3/obj/CommandHandler.o differ diff --git a/ft_irc3/obj/InviteHandler.o b/ft_irc3/obj/InviteHandler.o new file mode 100644 index 0000000..03a529c Binary files /dev/null and b/ft_irc3/obj/InviteHandler.o differ diff --git a/ft_irc3/obj/Join.o b/ft_irc3/obj/Join.o new file mode 100644 index 0000000..ef59204 Binary files /dev/null and b/ft_irc3/obj/Join.o differ diff --git a/ft_irc3/obj/KickHandler.o b/ft_irc3/obj/KickHandler.o new file mode 100644 index 0000000..7b23edd Binary files /dev/null and b/ft_irc3/obj/KickHandler.o differ diff --git a/ft_irc3/obj/ModeHandler.o b/ft_irc3/obj/ModeHandler.o new file mode 100644 index 0000000..9e0192c Binary files /dev/null and b/ft_irc3/obj/ModeHandler.o differ diff --git a/ft_irc3/obj/Server.o b/ft_irc3/obj/Server.o new file mode 100644 index 0000000..bae96ec Binary files /dev/null and b/ft_irc3/obj/Server.o differ diff --git a/ft_irc3/obj/TopicHandler.o b/ft_irc3/obj/TopicHandler.o new file mode 100644 index 0000000..09b62d4 Binary files /dev/null and b/ft_irc3/obj/TopicHandler.o differ diff --git a/ft_irc3/obj/Utils.o b/ft_irc3/obj/Utils.o new file mode 100644 index 0000000..4853158 Binary files /dev/null and b/ft_irc3/obj/Utils.o differ diff --git a/ft_irc3/obj/Welcome.o b/ft_irc3/obj/Welcome.o new file mode 100644 index 0000000..4af8df2 Binary files /dev/null and b/ft_irc3/obj/Welcome.o differ diff --git a/ft_irc3/obj/Who.o b/ft_irc3/obj/Who.o new file mode 100644 index 0000000..82bd023 Binary files /dev/null and b/ft_irc3/obj/Who.o differ diff --git a/ft_irc3/obj/main.o b/ft_irc3/obj/main.o new file mode 100644 index 0000000..7579cff Binary files /dev/null and b/ft_irc3/obj/main.o differ diff --git a/ft_irc3/src/AdditionalCommands.cpp b/ft_irc3/src/AdditionalCommands.cpp index 35bec02..949ada1 100644 --- a/ft_irc3/src/AdditionalCommands.cpp +++ b/ft_irc3/src/AdditionalCommands.cpp @@ -6,7 +6,7 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/16 15:27:29 by fgras-ca #+# #+# */ -/* Updated: 2024/06/10 15:17:13 by fgras-ca ### ########.fr */ +/* Updated: 2024/06/11 11:45:43 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ @@ -206,7 +206,7 @@ void AdditionalCommands::handlePrivmsgCommand(Server *server, Client *client, co if (channelClients[i] != client) { std::stringstream privMsg; - privMsg << ":" << client->getNickname() << " PRIVMSG " << target << " :" << message << "\r\n"; + privMsg << ":" << client->getNickname() << " PRIVMSG " << target << message << "\r\n"; server->sendToClient(channelClients[i]->getFd(), privMsg.str()); _server->log("Sent PRIVMSG to " + channelClients[i]->getNickname(), GREEN); } @@ -229,7 +229,7 @@ void AdditionalCommands::handlePrivmsgCommand(Server *server, Client *client, co } std::stringstream privMsg; - privMsg << ":" << client->getNickname() << " PRIVMSG " << target << " :" << message << "\r\n"; + privMsg << ":" << client->getNickname() << " PRIVMSG " << target << message << "\r\n"; server->sendToClient(targetClient->getFd(), privMsg.str()); _server->log("Sent PRIVMSG to " + targetClient->getNickname(), GREEN); diff --git a/ft_irc3/src/Join.cpp b/ft_irc3/src/Join.cpp index 4929a15..eab6a02 100644 --- a/ft_irc3/src/Join.cpp +++ b/ft_irc3/src/Join.cpp @@ -46,7 +46,6 @@ void JoinHandler::handleJoinCommand(Client* client, const std::string& params, S if (channelName[0] == '0' && channelName.size() == 1) { - // Leave all channels return; } diff --git a/ft_irc3/src/ModeHandler.cpp b/ft_irc3/src/ModeHandler.cpp index de62ca8..212e209 100644 --- a/ft_irc3/src/ModeHandler.cpp +++ b/ft_irc3/src/ModeHandler.cpp @@ -6,7 +6,7 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/30 11:13:08 by fgras-ca #+# #+# */ -/* Updated: 2024/06/08 22:12:20 by fgras-ca ### ########.fr */ +/* Updated: 2024/06/11 11:27:28 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ @@ -158,13 +158,13 @@ void ModeHandler::applyModeL(Client *client, Channel* channel, bool adding, cons } std::ostringstream oss; oss << limit; - _server->sendToClient(client->getFd(), MODEACCEPTMESSAGE(client, channel->getName(), "+l", " " + argument)); + channel->broadcast(MODEACCEPTMESSAGE(client, channel->getName(), "+l", "" + argument), NULL, _server); _server->log("Applying mode L: Setting limit to " + oss.str(), GREEN); channel->setClientLimit(limit); } else { - _server->sendToClient(client->getFd(), MODEACCEPTMESSAGE(client, channel->getName(), "-l", " " + argument)); + channel->broadcast(MODEACCEPTMESSAGE(client, channel->getName(), "-l", "" + argument), NULL, _server); _server->log("Applying mode L: Removing limit", RED); channel->setClientLimit(0); } @@ -179,7 +179,7 @@ void ModeHandler::applyModeI(Client *client, Channel *channel, bool adding) isAlreadySet = channel->isInviteOnly() == adding; if (!isAlreadySet) { - _server->sendToClient(client->getFd(), MODEACCEPTMESSAGE(client, channel->getName(), modeChange, "")); + channel->broadcast(MODEACCEPTMESSAGE(client, channel->getName(), modeChange, ""), NULL, _server); _server->log("Applying mode I: " + std::string(adding ? "Setting invite-only" : "Removing invite-only"), GREEN); channel->setInviteOnly(adding); } @@ -210,7 +210,7 @@ void ModeHandler::applyModeK(Client *client, Channel *channel, bool adding, cons _server->log("Invalid key for mode +k: contains spaces", RED); return; } - _server->sendToClient(client->getFd(), MODEACCEPTMESSAGE(client, channel->getName(), "+k ", argument)); + channel->broadcast( MODEACCEPTMESSAGE(client, channel->getName(), "+k ", argument), NULL, _server); _server->log("Applying mode K: Setting key to " + argument, GREEN); channel->setKey(argument); } diff --git a/ft_irc3/src/Server.cpp b/ft_irc3/src/Server.cpp index c0cb20a..365d7d1 100644 --- a/ft_irc3/src/Server.cpp +++ b/ft_irc3/src/Server.cpp @@ -6,14 +6,14 @@ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/15 12:17:12 by fgras-ca #+# #+# */ -/* Updated: 2024/06/06 18:44:57 by fgras-ca ### ########.fr */ +/* Updated: 2024/06/11 13:34:13 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ #include "Server.hpp" Server::Server(int port, const std::string &password) - : _port(port), _password(password), _clientManager(new ClientManager(this)), _commandHandler(new CommandHandler(this)), _modeHandler(new ModeHandler(this)), _topicHandler(new TopicHandler(this)), _botFilter(new BotFilter(this)) + : _port(port), _password(password), _clientManager(new ClientManager(this)), _commandHandler(new CommandHandler(this)), _modeHandler(new ModeHandler(this)), _topicHandler(new TopicHandler(this)), _botFilter(new BotFilter(this)), _additionalCommands(new AdditionalCommands(this)) { initServer(); _botFilter = new BotFilter(this);