Compare commits
No commits in common. "dfe4f13bcb7e563aa766ba779d0099d359c8984a" and "d6847bd3fed43fcd97a42f05aa6875997d99c916" have entirely different histories.
dfe4f13bcb
...
d6847bd3fe
12 changed files with 58 additions and 69 deletions
16
Makefile
16
Makefile
|
|
@ -6,7 +6,7 @@
|
|||
# By: sben-tay <sben-tay@student.42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2025/05/02 15:40:00 by rparodi #+# #+# #
|
||||
# Updated: 2025/09/01 16:22:45 by rparodi ### ########.fr #
|
||||
# Updated: 2025/06/23 14:15:57 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)
|
||||
@$(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $(NAME) $(OBJ) #-fuse-ld=lld
|
||||
|
||||
# Creating the objects
|
||||
$(OBJDIRNAME)/%.o: %.cpp
|
||||
|
|
@ -116,9 +116,13 @@ 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 -n test_haut || exec yes \"irssi exit code: $?\""'
|
||||
'bash -lc "irssi -c localhost -p $(PORT) -w irc || exec yes \"irssi exit code: $?\""'
|
||||
@tmux split-window -v -p 50 -t $(SESSION):0.1 \
|
||||
'bash -lc "irssi -c localhost -p $(PORT) -w irc -n test_bas || exec yes \"irssi exit code: $?\""'
|
||||
'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: $?\""'
|
||||
@tmux attach -t $(SESSION)
|
||||
|
||||
run: all
|
||||
|
|
@ -129,9 +133,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 -n test_haut || exec yes \"irssi exit code: $?\""'
|
||||
'bash -lc "irssi -c localhost -p $(PORT) -w irc || exec yes \"irssi exit code: $?\""'
|
||||
@tmux split-window -v -p 50 -t $(SESSION):0.1 \
|
||||
'bash -lc "irssi -c localhost -p $(PORT) -w irc -n test_bas || exec yes \"irssi exit code: $?\""'
|
||||
'bash -lc "nc localhost $(PORT) || exec yes \"netcat exit code: $?\""'
|
||||
@tmux attach -t $(SESSION)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@
|
|||
);
|
||||
|
||||
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"
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
/* ::: :::::::: */
|
||||
/* PollManager.hpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: sben-tay <sben-tay@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/06/24 12:33:07 by rparodi #+# #+# */
|
||||
/* Updated: 2025/06/24 12:33:09 by rparodi ### ########.fr */
|
||||
/* Created: 2025/05/19 19:15:13 by omoudni #+# #+# */
|
||||
/* Updated: 2025/06/18 01:26:38 by sben-tay ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
/* ************************************************************************** */
|
||||
/******************************************************************************/
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* core.hpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: omoudni <omoudni@student.42paris.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/06/24 12:33:56 by rparodi #+# #+# */
|
||||
/* Updated: 2025/06/24 12:33:58 by rparodi ### ########.fr */
|
||||
/* Created: 2025/05/12 14:16:03 by rparodi #+# #+# */
|
||||
/* Updated: 2025/06/21 11:59:02 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
/******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
/* ::: :::::::: */
|
||||
/* parser.hpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: omoudni <omoudni@student.42paris.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/06/24 12:34:11 by rparodi #+# #+# */
|
||||
/* Updated: 2025/06/24 12:34:12 by rparodi ### ########.fr */
|
||||
/* Created: 2025/05/19 14:47:46 by omoudni #+# #+# */
|
||||
/* Updated: 2025/05/19 15:14:31 by omoudni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: sben-tay <sben-tay@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/05/24 17:29:48 by rparodi #+# #+# */
|
||||
/* Updated: 2025/06/24 14:40:17 by sben-tay ### ########.fr */
|
||||
/* Updated: 2025/06/23 15:27:38 by sben-tay ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -78,10 +78,9 @@ 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 = ":" + _sender->getPrefix() + " KICK #" + this->_cTarget->getName() + " " + _uTarget->getName();
|
||||
std::string msgKick = ":" + this->_uTarget->getPrefix() + " KICK #" + this->_cTarget->getName() + " " + _uTarget->getName();
|
||||
if (_args.size() > 3)
|
||||
{
|
||||
DEBUG_MSG("Je rajoute le message de kick avec un motif");
|
||||
|
|
@ -89,8 +88,9 @@ void Kick::execute() {
|
|||
}
|
||||
msgKick += "\r\n";
|
||||
|
||||
_uTarget->appendToWriteBuffer(msgPart);
|
||||
std::cout << " msgKick: " << msgKick << "msgPart: " << msgPart << std::endl;
|
||||
_cTarget->sendAllClientInAChannel(msgKick);
|
||||
_uTarget->appendToWriteBuffer(msgPart);
|
||||
|
||||
_cTarget->removeUser(this->_uTarget);
|
||||
_cTarget->removeOperator(this->_uTarget);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: sben-tay <sben-tay@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/05/24 17:29:48 by rparodi #+# #+# */
|
||||
/* Updated: 2025/06/24 14:31:15 by sben-tay ### ########.fr */
|
||||
/* Updated: 2025/06/19 01:13:28 by sben-tay ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -69,6 +69,7 @@ void Part::execute() {
|
|||
_cTarget->sendAllClientInAChannel(msgPart);
|
||||
_cTarget->removeUser(_sender);
|
||||
_cTarget->removeOperator(_sender);
|
||||
// remove invited list
|
||||
|
||||
if (_cTarget->getUsers().empty()) {
|
||||
std::list<Channel*>& allChannels = _server->getChannelsList();
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: sben-tay <sben-tay@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/05/24 17:29:48 by rparodi #+# #+# */
|
||||
/* Updated: 2025/06/24 14:40:03 by sben-tay ### ########.fr */
|
||||
/* Updated: 2025/06/22 01:53:33 by sben-tay ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -14,7 +14,6 @@
|
|||
#include "commands.hpp"
|
||||
#include "logs.hpp"
|
||||
#include "bonus.hpp"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace cmd;
|
||||
|
||||
|
|
@ -65,50 +64,34 @@ 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 <cible> 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 <cible> 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)
|
||||
_cTarget->sendAllClientInAChannel(msg, _sender);
|
||||
|
||||
if (_cTarget) {
|
||||
if (BONUS && _cTarget->getBotChannel() && _args.at(2) == "!help")
|
||||
_sender->appendToWriteBuffer(msgBot);
|
||||
else if (BONUS && _cTarget->getBotChannel() && _args.at(2) == "!emote")
|
||||
_sender->appendToWriteBuffer(msgEmote);
|
||||
else
|
||||
_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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Envoi vers un user
|
||||
const std::list<User *>& users = _server->getUsersList();
|
||||
|
||||
for (std::list<User *>::const_iterator it = users.begin(); it != users.end(); ++it) {
|
||||
if ((*it)->getName() == target) {
|
||||
(*it)->appendToWriteBuffer(msg);
|
||||
break;
|
||||
}
|
||||
else {
|
||||
if (_uTarget)
|
||||
_uTarget->appendToWriteBuffer(msg);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: sben-tay <sben-tay@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/05/13 11:11:07 by rparodi #+# #+# */
|
||||
/* Updated: 2025/06/24 14:51:44 by sben-tay ### ########.fr */
|
||||
/* Updated: 2025/06/23 14:46:53 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)
|
||||
{
|
||||
INFO_MSG("Info: Server constructor called");
|
||||
std::cout << CLR_GREY << "Info: Server constructor called" << CLR_RESET << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -51,7 +51,7 @@ Server::Server(int port, const std::string &password) : _port(port), _password(p
|
|||
*/
|
||||
Server::~Server()
|
||||
{
|
||||
INFO_MSG("Info: Server destructor called");
|
||||
std::cout << CLR_GREY << "Info: Server destructor called" << CLR_RESET << std::endl;
|
||||
if (_serverFd != -1) {
|
||||
close(_serverFd);
|
||||
}
|
||||
|
|
@ -67,7 +67,6 @@ std::vector<std::string> 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) {
|
||||
|
|
@ -153,6 +152,7 @@ void Server::start()
|
|||
std::cout << "Poll loop finished" << std::endl;
|
||||
}
|
||||
std::cout << "[INFO] CTRL+C détecté. Fermeture du serveur..." << std::endl;
|
||||
close(_serverFd);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: sben-tay <sben-tay@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/05/13 11:03:13 by rparodi #+# #+# */
|
||||
/* Updated: 2025/06/24 00:47:18 by sben-tay ### ########.fr */
|
||||
/* Updated: 2025/06/23 14:38:53 by sben-tay ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -28,4 +28,3 @@ int main(int argc, char *argv[]) {
|
|||
server.start();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
/* ::: :::::::: */
|
||||
/* parser.cpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: omoudni <omoudni@student.42paris.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/06/24 12:34:29 by rparodi #+# #+# */
|
||||
/* Updated: 2025/06/24 12:34:30 by rparodi ### ########.fr */
|
||||
/* Created: 2025/05/19 14:48:52 by omoudni #+# #+# */
|
||||
/* Updated: 2025/05/19 15:08:18 by omoudni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
/* +:+ +:+ +:+ */
|
||||
/* By: sben-tay <sben-tay@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/05/21 20:37:12 by sben-tay #+# #+# */
|
||||
/* Updated: 2025/06/24 12:33:39 by rparodi ### ########.fr */
|
||||
/* Created: 2025/05/21 20:37:12 by omoudni #+# #+# */
|
||||
/* Updated: 2025/06/21 14:38:31 by sben-tay ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue