From a3b4e597a44138c9e4d943b13f36d3b745b5318b Mon Sep 17 00:00:00 2001 From: Samy Ben Tayeb Date: Mon, 23 Jun 2025 16:23:59 +0200 Subject: [PATCH 1/8] multi-closed fd fixed --- sources/core/Server.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sources/core/Server.cpp b/sources/core/Server.cpp index 48ccbe7..f8bff12 100644 --- a/sources/core/Server.cpp +++ b/sources/core/Server.cpp @@ -6,7 +6,7 @@ /* By: sben-tay +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/05/13 11:11:07 by rparodi #+# #+# */ -/* Updated: 2025/06/23 14:46:53 by sben-tay ### ########.fr */ +/* Updated: 2025/06/23 16:18:12 by sben-tay ### ########.fr */ /* */ /* ************************************************************************** */ @@ -152,7 +152,6 @@ void Server::start() std::cout << "Poll loop finished" << std::endl; } std::cout << "[INFO] CTRL+C dรฉtectรฉ. Fermeture du serveur..." << std::endl; - close(_serverFd); } /** From 7f804c5754544c7b2858cdd1cd5d82642d4e0e75 Mon Sep 17 00:00:00 2001 From: Samy BEN TAYEB Date: Tue, 24 Jun 2025 05:10:09 +0200 Subject: [PATCH 2/8] bonus emoji ok-tiers --- sources/commands/privmsg.cpp | 37 +++++++++++++++++++++++++----------- sources/core/main.cpp | 3 ++- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/sources/commands/privmsg.cpp b/sources/commands/privmsg.cpp index fa36e38..af046ff 100644 --- a/sources/commands/privmsg.cpp +++ b/sources/commands/privmsg.cpp @@ -6,7 +6,7 @@ /* By: sben-tay +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/05/24 17:29:48 by rparodi #+# #+# */ -/* Updated: 2025/06/22 01:53:33 by sben-tay ### ########.fr */ +/* Updated: 2025/06/24 05:07:56 by sben-tay ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,6 +14,7 @@ #include "commands.hpp" #include "logs.hpp" #include "bonus.hpp" +#include using namespace cmd; @@ -64,34 +65,48 @@ void PrivMsg::execute() { //bonus msgBot std::string msgBot = ":bot!ircbot@localhost PRIVMSG " + target + " :๐Ÿ“œ Liste des commandes disponibles :\r\n"; - msgBot += ":bot!ircbot@localhost PRIVMSG " + target + " :- JOIN #channel โ†’ Rejoindre un canal\r\n"; - msgBot += ":bot!ircbot@localhost PRIVMSG " + target + " :- PART #channel โ†’ Quitter un canal\r\n"; - msgBot += ":bot!ircbot@localhost PRIVMSG " + target + " :- PRIVMSG msg โ†’ Envoyer un message\r\n"; - msgBot += ":bot!ircbot@localhost PRIVMSG " + target + " :- TOPIC #channel :txt โ†’ Voir / modifier le topic\r\n"; + msgBot += ":bot!ircbot@localhost PRIVMSG " + target + " :- JOIN #channel โ†’ Rejoindre un canal\r\n"; + msgBot += ":bot!ircbot@localhost PRIVMSG " + target + " :- PART #channel โ†’ Quitter un canal\r\n"; + msgBot += ":bot!ircbot@localhost PRIVMSG " + target + " :- PRIVMSG msg โ†’ Envoyer un message\r\n"; + msgBot += ":bot!ircbot@localhost PRIVMSG " + target + " :- TOPIC #channel :txt โ†’ Voir / modifier le topic\r\n"; msgBot += ":bot!ircbot@localhost PRIVMSG " + target + " :- MODE #channel +o nick โ†’ Ajouter un opรฉrateur\r\n"; msgBot += ":bot!ircbot@localhost PRIVMSG " + target + " :- INVITE nick #channel โ†’ Inviter un utilisateur\r\n"; msgBot += ":bot!ircbot@localhost PRIVMSG " + target + " :- KICK #channel nick โ†’ ร‰jecter un utilisateur\r\n"; msgBot += ":bot!ircbot@localhost PRIVMSG " + target + " :- WHO / WHOIS โ†’ Infos sur les utilisateurs\r\n"; + msgBot += ":bot!ircbot@localhost PRIVMSG " + target + " :- DCC SEND nick /PATH โ†’ Transferer des fichiers ร  l'utilisateur\r\n"; + msgBot += ":bot!ircbot@localhost PRIVMSG " + target + " :- DCC GET /PATH โ†’ Accepter le transfert des fichiers reรงu\r\n"; + msgBot += ":bot!ircbot@localhost PRIVMSG " + target + " :- !emote โ†’ Affiche la liste d'emoji\r\n"; msgBot += ":bot!ircbot@localhost PRIVMSG " + target + " :- !help โ†’ Affiche cette aide\r\n"; + std::string msgEmote = ":bot!ircbot@localhost PRIVMSG " + target + " : ๐Ÿ“œ Emote list :\r\n"; + msgEmote += ":bot!ircbot@localhost PRIVMSG " + target + " : ๐Ÿ˜€๐Ÿ˜๐Ÿ˜‚๐Ÿ˜ƒ๐Ÿ˜„๐Ÿ˜…๐Ÿ˜†๐Ÿ˜‡๐Ÿ˜ˆ๐Ÿ˜‰๐Ÿ˜Š๐Ÿ˜‹๐Ÿ˜Œ๐Ÿ˜๐Ÿ˜Ž๐Ÿ˜\r\n"; + msgEmote += ":bot!ircbot@localhost PRIVMSG " + target + " : ๐Ÿ˜๐Ÿ˜‘๐Ÿ˜’๐Ÿ˜“๐Ÿ˜”๐Ÿ˜•๐Ÿ˜–๐Ÿ˜—๐Ÿ˜˜๐Ÿ˜™๐Ÿ˜š๐Ÿ˜›๐Ÿ˜œ๐Ÿ˜๐Ÿ˜ž๐Ÿ˜Ÿ\r\n"; + msgEmote += ":bot!ircbot@localhost PRIVMSG " + target + " : ๐Ÿ˜ ๐Ÿ˜ก๐Ÿ˜ข๐Ÿ˜ฃ๐Ÿ˜ค๐Ÿ˜ฅ๐Ÿ˜ฆ๐Ÿ˜ง๐Ÿ˜จ๐Ÿ˜ฉ๐Ÿ˜ช๐Ÿ˜ซ๐Ÿ˜ฌ๐Ÿ˜ญ๐Ÿ˜ฎ๐Ÿ˜ฏ\r\n"; + msgEmote += ":bot!ircbot@localhost PRIVMSG " + target + " : ๐Ÿ˜ฐ๐Ÿ˜ฑ๐Ÿ˜ฒ๐Ÿ˜ณ๐Ÿ˜ด๐Ÿ˜ต๐Ÿ˜ถ๐Ÿ˜ท๐Ÿ˜ธ๐Ÿ˜น๐Ÿ˜บ๐Ÿ˜ป๐Ÿ˜ผ๐Ÿ˜ฝ๐Ÿ˜พ๐Ÿ˜ฟ\r\n"; + msgEmote += ":bot!ircbot@localhost PRIVMSG " + target + " : ๐Ÿ™€๐Ÿ™๐Ÿ™‚๐Ÿ™ƒ๐Ÿ™„๐Ÿ™…๐Ÿ™†๐Ÿ™‡๐Ÿ™ˆ๐Ÿ™‰๐Ÿ™Š๐Ÿ™‹๐Ÿ™Œ๐Ÿ™๐Ÿ™Ž๐Ÿ™\r\n"; + msgEmote += ":bot!ircbot@localhost PRIVMSG " + target + " : ๐Ÿค๐Ÿค‘๐Ÿค’๐Ÿค“๐Ÿคค๐Ÿค”๐Ÿค•๐Ÿค–๐Ÿค—๐Ÿค˜๐Ÿค™๐Ÿคš๐Ÿค›๐Ÿคœ๐Ÿค๐ŸคŸ\r\n"; + msgEmote += ":bot!ircbot@localhost PRIVMSG " + target + " : ๐Ÿ’๐Ÿ’‘๐Ÿ’’๐Ÿ’“๐Ÿ’”๐Ÿ’•๐Ÿ’–๐Ÿ’—๐Ÿ’˜๐Ÿ’™๐Ÿ’š๐Ÿ’›๐Ÿ’œ๐Ÿ’๐Ÿ’ž๐Ÿ’Ÿ\r\n"; + msgEmote += ":bot!ircbot@localhost PRIVMSG " + target + " : ๐Ÿ’ ๐Ÿ’ก๐Ÿ’ข๐Ÿ’ฃ๐Ÿ’ค๐Ÿ’ฅ๐Ÿ’ฆ๐Ÿ’ง๐Ÿ’จ๐Ÿ’ฉ๐Ÿ’ช๐Ÿ’ซ๐Ÿ’ฌ๐Ÿ’ญ๐Ÿ’ฏ๐Ÿคจ\r\n"; // Envoi vers un channel if (target[0] == '#') { target.erase(0, 1); - if (_cTarget) + if (_cTarget && !BONUS) _cTarget->sendAllClientInAChannel(msg, _sender); if (BONUS && _cTarget->getBotChannel()) { - if (_args.at(2) == "!help") { - std::cout << "BONUS: PING command received, sending PONG" << std::endl; - _cTarget->sendAllClientInAChannel(msgBot); - } + if (_args.at(2) == "!help") + _sender->appendToWriteBuffer(msgBot); + else if (_args.at(2) == "!emote") + _sender->appendToWriteBuffer(msgEmote); } } // Envoi vers un user else { - if (_uTarget) + for(std::list::iterator it = _server->getUsersList().begin(); it != _server->getUsersList().end(); ++it) { + if ((*it)->getName() == target) _uTarget->appendToWriteBuffer(msg); + } } } diff --git a/sources/core/main.cpp b/sources/core/main.cpp index 8fd050b..be0642f 100644 --- a/sources/core/main.cpp +++ b/sources/core/main.cpp @@ -6,7 +6,7 @@ /* By: sben-tay +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/05/13 11:03:13 by rparodi #+# #+# */ -/* Updated: 2025/06/23 14:38:53 by sben-tay ### ########.fr */ +/* Updated: 2025/06/24 00:47:18 by sben-tay ### ########.fr */ /* */ /* ************************************************************************** */ @@ -28,3 +28,4 @@ int main(int argc, char *argv[]) { server.start(); return 0; } + From 58bf620c099a42d74be0b98d91c0cfe387422494 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 24 Jun 2025 12:36:19 +0200 Subject: [PATCH 3/8] style(42header): removing the non-working people (except for braces issues xD) --- Makefile | 2 +- include/PollManager.hpp | 6 +++--- include/core/core.hpp | 10 +++++----- include/core/parser.hpp | 8 ++++---- sources/core/parser.cpp | 8 ++++---- sources/user/user.cpp | 6 +++--- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index 7962ace..fd4e17d 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: sben-tay +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2025/05/02 15:40:00 by rparodi #+# #+# # -# Updated: 2025/06/23 14:15:57 by rparodi ### ########.fr # +# Updated: 2025/06/24 12:32:31 by rparodi ### ########.fr # # # # **************************************************************************** # diff --git a/include/PollManager.hpp b/include/PollManager.hpp index bf5238c..ddd4088 100644 --- a/include/PollManager.hpp +++ b/include/PollManager.hpp @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* PollManager.hpp :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: sben-tay +#+ +:+ +#+ */ +/* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ -/* Created: 2025/05/19 19:15:13 by omoudni #+# #+# */ -/* Updated: 2025/06/18 01:26:38 by sben-tay ### ########.fr */ +/* Created: 2025/06/24 12:33:07 by rparodi #+# #+# */ +/* Updated: 2025/06/24 12:33:09 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/include/core/core.hpp b/include/core/core.hpp index 1f53655..076ea22 100644 --- a/include/core/core.hpp +++ b/include/core/core.hpp @@ -1,14 +1,14 @@ -/******************************************************************************/ +/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* core.hpp :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: omoudni +#+ +:+ +#+ */ +/* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ -/* Created: 2025/05/12 14:16:03 by rparodi #+# #+# */ -/* Updated: 2025/06/21 11:59:02 by rparodi ### ########.fr */ +/* Created: 2025/06/24 12:33:56 by rparodi #+# #+# */ +/* Updated: 2025/06/24 12:33:58 by rparodi ### ########.fr */ /* */ -/******************************************************************************/ +/* ************************************************************************** */ #pragma once diff --git a/include/core/parser.hpp b/include/core/parser.hpp index 3becac5..9fdeaf7 100644 --- a/include/core/parser.hpp +++ b/include/core/parser.hpp @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* parser.hpp :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: omoudni +#+ +:+ +#+ */ +/* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ -/* Created: 2025/05/19 14:47:46 by omoudni #+# #+# */ -/* Updated: 2025/05/19 15:14:31 by omoudni ### ########.fr */ +/* Created: 2025/06/24 12:34:11 by rparodi #+# #+# */ +/* Updated: 2025/06/24 12:34:12 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -27,4 +27,4 @@ public: unsigned short int getPort() const; const std::string& getPassword() const; const std::string& getErrorMsg() const; -}; \ No newline at end of file +}; diff --git a/sources/core/parser.cpp b/sources/core/parser.cpp index 362fb97..f3d0023 100644 --- a/sources/core/parser.cpp +++ b/sources/core/parser.cpp @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* parser.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: omoudni +#+ +:+ +#+ */ +/* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ -/* Created: 2025/05/19 14:48:52 by omoudni #+# #+# */ -/* Updated: 2025/05/19 15:08:18 by omoudni ### ########.fr */ +/* Created: 2025/06/24 12:34:29 by rparodi #+# #+# */ +/* Updated: 2025/06/24 12:34:30 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -40,4 +40,4 @@ Parser::Parser(int argc, char* argv[]) : _port(0), _valid(false) { bool Parser::isValid() const { return _valid; } unsigned short int Parser::getPort() const { return _port; } const std::string& Parser::getPassword() const { return _password; } -const std::string& Parser::getErrorMsg() const { return _errorMsg; } \ No newline at end of file +const std::string& Parser::getErrorMsg() const { return _errorMsg; } diff --git a/sources/user/user.cpp b/sources/user/user.cpp index c320d59..b862ced 100644 --- a/sources/user/user.cpp +++ b/sources/user/user.cpp @@ -5,8 +5,8 @@ /* +:+ +:+ +:+ */ /* By: sben-tay +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ -/* Created: 2025/05/21 20:37:12 by omoudni #+# #+# */ -/* Updated: 2025/06/21 14:38:31 by sben-tay ### ########.fr */ +/* Created: 2025/05/21 20:37:12 by sben-tay #+# #+# */ +/* Updated: 2025/06/24 12:33:39 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -202,4 +202,4 @@ void User::consumeWriteBuffer(size_t len) { _write_buffer.clear(); else _write_buffer.erase(0, len); -} \ No newline at end of file +} From 0b02aabcc3c548f8cbeebd67981235e36bfbfb72 Mon Sep 17 00:00:00 2001 From: Samy Ben Tayeb Date: Tue, 24 Jun 2025 14:36:47 +0200 Subject: [PATCH 4/8] fix(cmd/kick): wrong order becuase we are the order --- sources/commands/kick.cpp | 7 +++--- sources/commands/part.cpp | 3 +-- sources/commands/privmsg.cpp | 41 +++++++++++++++++++----------------- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/sources/commands/kick.cpp b/sources/commands/kick.cpp index 47c8e6a..1b1800e 100644 --- a/sources/commands/kick.cpp +++ b/sources/commands/kick.cpp @@ -6,7 +6,7 @@ /* By: sben-tay +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/05/24 17:29:48 by rparodi #+# #+# */ -/* Updated: 2025/06/23 15:27:38 by sben-tay ### ########.fr */ +/* Updated: 2025/06/24 14:35:17 by sben-tay ### ########.fr */ /* */ /* ************************************************************************** */ @@ -78,9 +78,10 @@ void Kick::execute() { return; } + // std::string msgPart = ":" + _sender->getPrefix() + " PART #" + _cTarget->getName(); std::string msgPart = ":" + this->_uTarget->getPrefix() + " PART #" + _cTarget->getName() + "\r\n"; - std::string msgKick = ":" + this->_uTarget->getPrefix() + " KICK #" + this->_cTarget->getName() + " " + _uTarget->getName(); + std::string msgKick = ":" + _sender->getPrefix() + " KICK #" + this->_cTarget->getName() + " " + _uTarget->getName(); if (_args.size() > 3) { DEBUG_MSG("Je rajoute le message de kick avec un motif"); @@ -89,8 +90,8 @@ void Kick::execute() { msgKick += "\r\n"; std::cout << " msgKick: " << msgKick << "msgPart: " << msgPart << std::endl; - _cTarget->sendAllClientInAChannel(msgKick); _uTarget->appendToWriteBuffer(msgPart); + _cTarget->sendAllClientInAChannel(msgKick); _cTarget->removeUser(this->_uTarget); _cTarget->removeOperator(this->_uTarget); diff --git a/sources/commands/part.cpp b/sources/commands/part.cpp index 6c4014d..9a2f66d 100644 --- a/sources/commands/part.cpp +++ b/sources/commands/part.cpp @@ -6,7 +6,7 @@ /* By: sben-tay +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/05/24 17:29:48 by rparodi #+# #+# */ -/* Updated: 2025/06/19 01:13:28 by sben-tay ### ########.fr */ +/* Updated: 2025/06/24 14:31:15 by sben-tay ### ########.fr */ /* */ /* ************************************************************************** */ @@ -69,7 +69,6 @@ void Part::execute() { _cTarget->sendAllClientInAChannel(msgPart); _cTarget->removeUser(_sender); _cTarget->removeOperator(_sender); - // remove invited list if (_cTarget->getUsers().empty()) { std::list& allChannels = _server->getChannelsList(); diff --git a/sources/commands/privmsg.cpp b/sources/commands/privmsg.cpp index af046ff..6de46aa 100644 --- a/sources/commands/privmsg.cpp +++ b/sources/commands/privmsg.cpp @@ -6,7 +6,7 @@ /* By: sben-tay +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/05/24 17:29:48 by rparodi #+# #+# */ -/* Updated: 2025/06/24 05:07:56 by sben-tay ### ########.fr */ +/* Updated: 2025/06/24 14:02:33 by sben-tay ### ########.fr */ /* */ /* ************************************************************************** */ @@ -79,34 +79,37 @@ void PrivMsg::execute() { msgBot += ":bot!ircbot@localhost PRIVMSG " + target + " :- !help โ†’ Affiche cette aide\r\n"; std::string msgEmote = ":bot!ircbot@localhost PRIVMSG " + target + " : ๐Ÿ“œ Emote list :\r\n"; - msgEmote += ":bot!ircbot@localhost PRIVMSG " + target + " : ๐Ÿ˜€๐Ÿ˜๐Ÿ˜‚๐Ÿ˜ƒ๐Ÿ˜„๐Ÿ˜…๐Ÿ˜†๐Ÿ˜‡๐Ÿ˜ˆ๐Ÿ˜‰๐Ÿ˜Š๐Ÿ˜‹๐Ÿ˜Œ๐Ÿ˜๐Ÿ˜Ž๐Ÿ˜\r\n"; - msgEmote += ":bot!ircbot@localhost PRIVMSG " + target + " : ๐Ÿ˜๐Ÿ˜‘๐Ÿ˜’๐Ÿ˜“๐Ÿ˜”๐Ÿ˜•๐Ÿ˜–๐Ÿ˜—๐Ÿ˜˜๐Ÿ˜™๐Ÿ˜š๐Ÿ˜›๐Ÿ˜œ๐Ÿ˜๐Ÿ˜ž๐Ÿ˜Ÿ\r\n"; - msgEmote += ":bot!ircbot@localhost PRIVMSG " + target + " : ๐Ÿ˜ ๐Ÿ˜ก๐Ÿ˜ข๐Ÿ˜ฃ๐Ÿ˜ค๐Ÿ˜ฅ๐Ÿ˜ฆ๐Ÿ˜ง๐Ÿ˜จ๐Ÿ˜ฉ๐Ÿ˜ช๐Ÿ˜ซ๐Ÿ˜ฌ๐Ÿ˜ญ๐Ÿ˜ฎ๐Ÿ˜ฏ\r\n"; - msgEmote += ":bot!ircbot@localhost PRIVMSG " + target + " : ๐Ÿ˜ฐ๐Ÿ˜ฑ๐Ÿ˜ฒ๐Ÿ˜ณ๐Ÿ˜ด๐Ÿ˜ต๐Ÿ˜ถ๐Ÿ˜ท๐Ÿ˜ธ๐Ÿ˜น๐Ÿ˜บ๐Ÿ˜ป๐Ÿ˜ผ๐Ÿ˜ฝ๐Ÿ˜พ๐Ÿ˜ฟ\r\n"; - msgEmote += ":bot!ircbot@localhost PRIVMSG " + target + " : ๐Ÿ™€๐Ÿ™๐Ÿ™‚๐Ÿ™ƒ๐Ÿ™„๐Ÿ™…๐Ÿ™†๐Ÿ™‡๐Ÿ™ˆ๐Ÿ™‰๐Ÿ™Š๐Ÿ™‹๐Ÿ™Œ๐Ÿ™๐Ÿ™Ž๐Ÿ™\r\n"; - msgEmote += ":bot!ircbot@localhost PRIVMSG " + target + " : ๐Ÿค๐Ÿค‘๐Ÿค’๐Ÿค“๐Ÿคค๐Ÿค”๐Ÿค•๐Ÿค–๐Ÿค—๐Ÿค˜๐Ÿค™๐Ÿคš๐Ÿค›๐Ÿคœ๐Ÿค๐ŸคŸ\r\n"; - msgEmote += ":bot!ircbot@localhost PRIVMSG " + target + " : ๐Ÿ’๐Ÿ’‘๐Ÿ’’๐Ÿ’“๐Ÿ’”๐Ÿ’•๐Ÿ’–๐Ÿ’—๐Ÿ’˜๐Ÿ’™๐Ÿ’š๐Ÿ’›๐Ÿ’œ๐Ÿ’๐Ÿ’ž๐Ÿ’Ÿ\r\n"; - msgEmote += ":bot!ircbot@localhost PRIVMSG " + target + " : ๐Ÿ’ ๐Ÿ’ก๐Ÿ’ข๐Ÿ’ฃ๐Ÿ’ค๐Ÿ’ฅ๐Ÿ’ฆ๐Ÿ’ง๐Ÿ’จ๐Ÿ’ฉ๐Ÿ’ช๐Ÿ’ซ๐Ÿ’ฌ๐Ÿ’ญ๐Ÿ’ฏ๐Ÿคจ\r\n"; + msgEmote += ":bot!ircbot@localhost PRIVMSG " + target + " :๐Ÿ˜€๐Ÿ˜๐Ÿ˜‚๐Ÿ˜ƒ๐Ÿ˜„๐Ÿ˜…๐Ÿ˜†๐Ÿ˜‡๐Ÿ˜ˆ๐Ÿ˜‰๐Ÿ˜Š๐Ÿ˜‹๐Ÿ˜Œ๐Ÿ˜๐Ÿ˜Ž๐Ÿ˜\r\n"; + msgEmote += ":bot!ircbot@localhost PRIVMSG " + target + " :๐Ÿ˜๐Ÿ˜‘๐Ÿ˜’๐Ÿ˜“๐Ÿ˜”๐Ÿ˜•๐Ÿ˜–๐Ÿ˜—๐Ÿ˜˜๐Ÿ˜™๐Ÿ˜š๐Ÿ˜›๐Ÿ˜œ๐Ÿ˜๐Ÿ˜ž๐Ÿ˜Ÿ\r\n"; + msgEmote += ":bot!ircbot@localhost PRIVMSG " + target + " :๐Ÿ˜ ๐Ÿ˜ก๐Ÿ˜ข๐Ÿ˜ฃ๐Ÿ˜ค๐Ÿ˜ฅ๐Ÿ˜ฆ๐Ÿ˜ง๐Ÿ˜จ๐Ÿ˜ฉ๐Ÿ˜ช๐Ÿ˜ซ๐Ÿ˜ฌ๐Ÿ˜ญ๐Ÿ˜ฎ๐Ÿ˜ฏ\r\n"; + msgEmote += ":bot!ircbot@localhost PRIVMSG " + target + " :๐Ÿ˜ฐ๐Ÿ˜ฑ๐Ÿ˜ฒ๐Ÿ˜ณ๐Ÿ˜ด๐Ÿ˜ต๐Ÿ˜ถ๐Ÿ˜ท๐Ÿ˜ธ๐Ÿ˜น๐Ÿ˜บ๐Ÿ˜ป๐Ÿ˜ผ๐Ÿ˜ฝ๐Ÿ˜พ๐Ÿ˜ฟ\r\n"; + msgEmote += ":bot!ircbot@localhost PRIVMSG " + target + " :๐Ÿ™€๐Ÿ™๐Ÿ™‚๐Ÿ™ƒ๐Ÿ™„๐Ÿ™…๐Ÿ™†๐Ÿ™‡๐Ÿ™ˆ๐Ÿ™‰๐Ÿ™Š๐Ÿ™‹๐Ÿ™Œ๐Ÿ™๐Ÿ™Ž๐Ÿ™\r\n"; + msgEmote += ":bot!ircbot@localhost PRIVMSG " + target + " :๐Ÿค๐Ÿค‘๐Ÿค’๐Ÿค“๐Ÿคค๐Ÿค”๐Ÿค•๐Ÿค–๐Ÿค—๐Ÿค˜๐Ÿค™๐Ÿคš๐Ÿค›๐Ÿคœ๐Ÿค๐ŸคŸ\r\n"; + msgEmote += ":bot!ircbot@localhost PRIVMSG " + target + " :๐Ÿ’๐Ÿ’‘๐Ÿ’’๐Ÿ’“๐Ÿ’”๐Ÿ’•๐Ÿ’–๐Ÿ’—๐Ÿ’˜๐Ÿ’™๐Ÿ’š๐Ÿ’›๐Ÿ’œ๐Ÿ’๐Ÿ’ž๐Ÿ’Ÿ\r\n"; + msgEmote += ":bot!ircbot@localhost PRIVMSG " + target + " :๐Ÿ’ ๐Ÿ’ก๐Ÿ’ข๐Ÿ’ฃ๐Ÿ’ค๐Ÿ’ฅ๐Ÿ’ฆ๐Ÿ’ง๐Ÿ’จ๐Ÿ’ฉ๐Ÿ’ช๐Ÿ’ซ๐Ÿ’ฌ๐Ÿ’ญ๐Ÿ’ฏ๐Ÿคจ\r\n"; + std::cout << "target = " << target << std::endl; // Envoi vers un channel if (target[0] == '#') { target.erase(0, 1); - if (_cTarget && !BONUS) - _cTarget->sendAllClientInAChannel(msg, _sender); - - if (BONUS && _cTarget->getBotChannel()) { - if (_args.at(2) == "!help") + + if (_cTarget) { + if (BONUS && _cTarget->getBotChannel() && _args.at(2) == "!help") _sender->appendToWriteBuffer(msgBot); - else if (_args.at(2) == "!emote") + else if (BONUS && _cTarget->getBotChannel() && _args.at(2) == "!emote") _sender->appendToWriteBuffer(msgEmote); + else + _cTarget->sendAllClientInAChannel(msg, _sender); } } // Envoi vers un user - else { - for(std::list::iterator it = _server->getUsersList().begin(); it != _server->getUsersList().end(); ++it) { - if ((*it)->getName() == target) - _uTarget->appendToWriteBuffer(msg); + const std::list& users = _server->getUsersList(); + + for (std::list::const_iterator it = users.begin(); it != users.end(); ++it) { + if ((*it)->getName() == target) { + (*it)->appendToWriteBuffer(msg); + break; } } } From b5bb9a65034766326ec6983ae154e095e3cc2386 Mon Sep 17 00:00:00 2001 From: Samy Ben Tayeb Date: Tue, 24 Jun 2025 14:42:37 +0200 Subject: [PATCH 5/8] style(global): removing all the std::cout --- sources/commands/kick.cpp | 3 +-- sources/commands/privmsg.cpp | 3 +-- sources/core/Server.cpp | 6 +++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/sources/commands/kick.cpp b/sources/commands/kick.cpp index 1b1800e..7ff898c 100644 --- a/sources/commands/kick.cpp +++ b/sources/commands/kick.cpp @@ -6,7 +6,7 @@ /* By: sben-tay +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/05/24 17:29:48 by rparodi #+# #+# */ -/* Updated: 2025/06/24 14:35:17 by sben-tay ### ########.fr */ +/* Updated: 2025/06/24 14:40:17 by sben-tay ### ########.fr */ /* */ /* ************************************************************************** */ @@ -89,7 +89,6 @@ void Kick::execute() { } msgKick += "\r\n"; - std::cout << " msgKick: " << msgKick << "msgPart: " << msgPart << std::endl; _uTarget->appendToWriteBuffer(msgPart); _cTarget->sendAllClientInAChannel(msgKick); diff --git a/sources/commands/privmsg.cpp b/sources/commands/privmsg.cpp index 6de46aa..0ddba52 100644 --- a/sources/commands/privmsg.cpp +++ b/sources/commands/privmsg.cpp @@ -6,7 +6,7 @@ /* By: sben-tay +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/05/24 17:29:48 by rparodi #+# #+# */ -/* Updated: 2025/06/24 14:02:33 by sben-tay ### ########.fr */ +/* Updated: 2025/06/24 14:40:03 by sben-tay ### ########.fr */ /* */ /* ************************************************************************** */ @@ -88,7 +88,6 @@ void PrivMsg::execute() { msgEmote += ":bot!ircbot@localhost PRIVMSG " + target + " :๐Ÿ’๐Ÿ’‘๐Ÿ’’๐Ÿ’“๐Ÿ’”๐Ÿ’•๐Ÿ’–๐Ÿ’—๐Ÿ’˜๐Ÿ’™๐Ÿ’š๐Ÿ’›๐Ÿ’œ๐Ÿ’๐Ÿ’ž๐Ÿ’Ÿ\r\n"; msgEmote += ":bot!ircbot@localhost PRIVMSG " + target + " :๐Ÿ’ ๐Ÿ’ก๐Ÿ’ข๐Ÿ’ฃ๐Ÿ’ค๐Ÿ’ฅ๐Ÿ’ฆ๐Ÿ’ง๐Ÿ’จ๐Ÿ’ฉ๐Ÿ’ช๐Ÿ’ซ๐Ÿ’ฌ๐Ÿ’ญ๐Ÿ’ฏ๐Ÿคจ\r\n"; - std::cout << "target = " << target << std::endl; // Envoi vers un channel if (target[0] == '#') { target.erase(0, 1); diff --git a/sources/core/Server.cpp b/sources/core/Server.cpp index f8bff12..26bec2b 100644 --- a/sources/core/Server.cpp +++ b/sources/core/Server.cpp @@ -6,7 +6,7 @@ /* By: sben-tay +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/05/13 11:11:07 by rparodi #+# #+# */ -/* Updated: 2025/06/23 16:18:12 by sben-tay ### ########.fr */ +/* Updated: 2025/06/24 14:41:14 by sben-tay ### ########.fr */ /* */ /* ************************************************************************** */ @@ -43,7 +43,7 @@ void handle_sigint(int sig) { */ Server::Server(int port, const std::string &password) : _port(port), _password(password) { - std::cout << CLR_GREY << "Info: Server constructor called" << CLR_RESET << std::endl; + INFO_MSG("Info: Server constructor called"); } /** @@ -51,7 +51,7 @@ Server::Server(int port, const std::string &password) : _port(port), _password(p */ Server::~Server() { - std::cout << CLR_GREY << "Info: Server destructor called" << CLR_RESET << std::endl; + INFO_MSG("Info: Server destructor called"); if (_serverFd != -1) { close(_serverFd); } From c395dea89da45c0aa9e9418da657bb3899c525db Mon Sep 17 00:00:00 2001 From: Samy Ben Tayeb Date: Tue, 24 Jun 2025 14:53:14 +0200 Subject: [PATCH 6/8] few changes before push --- Makefile | 14 +++++--------- sources/core/Server.cpp | 3 ++- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index fd4e17d..0debbc4 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: sben-tay +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2025/05/02 15:40:00 by rparodi #+# #+# # -# Updated: 2025/06/24 12:32:31 by rparodi ### ########.fr # +# Updated: 2025/06/24 14:49:42 by sben-tay ### ########.fr # # # # **************************************************************************** # @@ -116,13 +116,9 @@ test: debug @tmux new-session -d -s $(SESSION) \ 'bash -lc "./$(NAME) $(PORT) irc; exec bash"' @tmux split-window -h -p 70 -t $(SESSION):0 \ - 'bash -lc "irssi -c localhost -p $(PORT) -w irc || exec yes \"irssi exit code: $?\""' + 'bash -lc "irssi -c localhost -p $(PORT) -w irc -n test_haut || exec yes \"irssi exit code: $?\""' @tmux split-window -v -p 50 -t $(SESSION):0.1 \ - 'bash -lc "nc localhost $(PORT) || exec yes \"netcat exit code: $?\""' - @tmux split-window -v -p 50 -t $(SESSION):0.2 \ - 'bash -lc "nc localhost $(PORT) || exec yes \"netcat exit code: $?\""' - @tmux split-window -v -p 50 -t $(SESSION):0.3 \ - 'bash -lc "nc localhost $(PORT) || exec yes \"netcat exit code: $?\""' + 'bash -lc "irssi -c localhost -p $(PORT) -w irc -n test_bas || exec yes \"irssi exit code: $?\""' @tmux attach -t $(SESSION) run: all @@ -133,9 +129,9 @@ run: all @tmux new-session -d -s $(SESSION) \ 'bash -lc "./$(NAME) $(PORT) irc; exec bash"' @tmux split-window -h -p 70 -t $(SESSION):0 \ - 'bash -lc "irssi -c localhost -p $(PORT) -w irc || exec yes \"irssi exit code: $?\""' + 'bash -lc "irssi -c localhost -p $(PORT) -w irc -n test_haut || exec yes \"irssi exit code: $?\""' @tmux split-window -v -p 50 -t $(SESSION):0.1 \ - 'bash -lc "nc localhost $(PORT) || exec yes \"netcat exit code: $?\""' + 'bash -lc "irssi -c localhost -p $(PORT) -w irc -n test_bas || exec yes \"irssi exit code: $?\""' @tmux attach -t $(SESSION) diff --git a/sources/core/Server.cpp b/sources/core/Server.cpp index 26bec2b..75d2475 100644 --- a/sources/core/Server.cpp +++ b/sources/core/Server.cpp @@ -6,7 +6,7 @@ /* By: sben-tay +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/05/13 11:11:07 by rparodi #+# #+# */ -/* Updated: 2025/06/24 14:41:14 by sben-tay ### ########.fr */ +/* Updated: 2025/06/24 14:51:44 by sben-tay ### ########.fr */ /* */ /* ************************************************************************** */ @@ -67,6 +67,7 @@ std::vector splitLines(const std::string& input); void Server::start() { + signal(SIGQUIT, SIG_IGN); signal(SIGINT, handle_sigint); _serverFd = socket(AF_INET, SOCK_STREAM, 0); if (_serverFd == -1) { From 28bfda390e97e55921eda091cf2f241efcbe91db Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 25 Dec 2025 02:16:43 +0100 Subject: [PATCH 7/8] build(make): removing the lld flags --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 0debbc4..cbde13f 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: sben-tay +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2025/05/02 15:40:00 by rparodi #+# #+# # -# Updated: 2025/06/24 14:49:42 by sben-tay ### ########.fr # +# Updated: 2025/09/01 16:22:45 by rparodi ### ########.fr # # # # **************************************************************************** # @@ -93,7 +93,7 @@ re: header fclean all $(NAME): $(OBJ) @mkdir -p $(OBJDIRNAME) @printf '$(GREY) Creating $(END)$(GREEN)$(OBJDIRNAME)$(END)\n' - @$(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $(NAME) $(OBJ) #-fuse-ld=lld + @$(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $(NAME) $(OBJ) # Creating the objects $(OBJDIRNAME)/%.o: %.cpp From dfe4f13bcb7e563aa766ba779d0099d359c8984a Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 25 Dec 2025 02:17:00 +0100 Subject: [PATCH 8/8] build(flake/shell): remocing the auto fetch --- flake.nix | 2 -- 1 file changed, 2 deletions(-) diff --git a/flake.nix b/flake.nix index 9af1162..6584ead 100644 --- a/flake.nix +++ b/flake.nix @@ -28,8 +28,6 @@ ); shellHook = '' - git fetch origin - git merge origin/master export CXX=clang++ export CXXFLAGS="-std=cpp98 -Wall -Werror -Wextra" printf "\n\033[0;90mCPP env loaded for: \033[38;5;220m${system}\033[0m\n"