From 6716df3af4818e5a93861496a5786001f7890f02 Mon Sep 17 00:00:00 2001 From: Raphael Date: Sat, 21 Jun 2025 11:59:59 +0200 Subject: [PATCH 1/3] init(make/bonus): bonus rules done --- Makefile | 4 +++- include/core/core.hpp | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index c16f1b5..7c9244c 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: sben-tay +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2025/05/02 15:40:00 by rparodi #+# #+# # -# Updated: 2025/06/19 11:29:58 by rparodi ### ########.fr # +# Updated: 2025/06/21 11:58:21 by rparodi ### ########.fr # # # # **************************************************************************** # @@ -72,6 +72,8 @@ END = \033[0m # All (make all) all: header $(NAME) footer +bonus: CPPFLAGS += -D BONUS=1 +bonus: all # Clean (make clean) clean: @printf '$(GREY) Removing $(END)$(RED)Objects$(END)\n' diff --git a/include/core/core.hpp b/include/core/core.hpp index 95590bf..1f53655 100644 --- a/include/core/core.hpp +++ b/include/core/core.hpp @@ -6,14 +6,14 @@ /* By: omoudni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/05/12 14:16:03 by rparodi #+# #+# */ -/* Updated: 2025/06/05 11:10:45 by rparodi ### ########.fr */ +/* Updated: 2025/06/21 11:59:02 by rparodi ### ########.fr */ /* */ /******************************************************************************/ #pragma once -#ifdef DEBUG -#define LOG std::endl << CLR_CYAN << "Debug: " << __FILE__ << ":" << __LINE__ << std::endl << CLR_RESET +#ifndef BONUS +#define BONUS 0 #endif enum e_code { From 3af74931c72b90953b6033d185fbad8568f3ee29 Mon Sep 17 00:00:00 2001 From: Samy Ben Tayeb Date: Sat, 21 Jun 2025 19:25:31 +0200 Subject: [PATCH 2/3] need fix kick from bot --- include/bonus.hpp | 18 ++++++++++++++++++ include/channel.hpp | 7 +++++-- include/commands.hpp | 4 ++-- include/user.hpp | 9 ++++++--- sources/channel/channel.cpp | 21 ++++++++++++++++++++- sources/commands/join.cpp | 11 +++++++++-- sources/commands/kick.cpp | 23 ++++++++++++++++++++--- sources/commands/privmsg.cpp | 26 ++++++++++++++++++++++++-- sources/commands/topic.cpp | 8 ++++---- sources/core/check.cpp | 4 ++-- sources/user/user.cpp | 8 +++++--- 11 files changed, 115 insertions(+), 24 deletions(-) create mode 100644 include/bonus.hpp diff --git a/include/bonus.hpp b/include/bonus.hpp new file mode 100644 index 0000000..64421b1 --- /dev/null +++ b/include/bonus.hpp @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* bonus.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: sben-tay +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/06/21 12:09:57 by sben-tay #+# #+# */ +/* Updated: 2025/06/21 18:55:38 by sben-tay ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef BONUS_HPP +# define BONUS_HPP + +// # define BONUS 0 + +#endif diff --git a/include/channel.hpp b/include/channel.hpp index bab998d..ec2a6a5 100644 --- a/include/channel.hpp +++ b/include/channel.hpp @@ -6,7 +6,7 @@ /* By: sben-tay +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/05/20 22:18:17 by rparodi #+# #+# */ -/* Updated: 2025/06/19 13:42:03 by sben-tay ### ########.fr */ +/* Updated: 2025/06/21 14:36:38 by sben-tay ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,7 +20,7 @@ class Channel { public: Channel(const std::string &name, User *owner, size_t maxUsers, bool needInvite); - + ~Channel(); // getters std::string getName() const; std::string getTopic() const; @@ -47,6 +47,8 @@ class Channel { bool isInvited(User *user) const; void removeUser(User *user); void removeOperator(User *user); + void setBotChannel(bool isBot); + bool getBotChannel() const; // utility functions void sendAllClientInAChannel(const std::string &toSend, User *exclude = NULL); @@ -62,6 +64,7 @@ class Channel { std::list _operators; std::list _users; std::list _invited; + bool _botChannel; }; diff --git a/include/commands.hpp b/include/commands.hpp index ed7434c..acd43ca 100644 --- a/include/commands.hpp +++ b/include/commands.hpp @@ -6,7 +6,7 @@ /* By: sben-tay +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/05/20 23:31:58 by rparodi #+# #+# */ -/* Updated: 2025/06/19 13:00:30 by rparodi ### ########.fr */ +/* Updated: 2025/06/21 17:53:03 by sben-tay ### ########.fr */ /* */ /* ************************************************************************** */ @@ -65,6 +65,6 @@ namespace cmd class userCmd; class Whois; class Whowas; -}; +}; #include "./commands/commands.tpp" diff --git a/include/user.hpp b/include/user.hpp index 2427bfe..c01516d 100644 --- a/include/user.hpp +++ b/include/user.hpp @@ -6,7 +6,7 @@ /* By: sben-tay +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/05/20 21:57:49 by rparodi #+# #+# */ -/* Updated: 2025/06/20 19:17:53 by sben-tay ### ########.fr */ +/* Updated: 2025/06/21 14:38:06 by sben-tay ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,6 +15,7 @@ #include #include "PollManager.hpp" + class User { private: @@ -38,6 +39,7 @@ class User public: User(short unsigned fd, PollManager& poll); + User( void ); // default constructor for bot service short unsigned int getFd() const; void appendToReadBuffer(const std::string &data); void appendToWriteBuffer(const std::string &data); @@ -61,10 +63,11 @@ class User const std::string getRealname(void) const; const std::string getNickname() const; const std::string getWriteBuffer() const; - const std::string& getHostname() const; - const std::string& getIpAddress() const; + const std::string getHostname() const; + const std::string getIpAddress() const; const std::string getName() const; const std::string getPrefix() const; + const std::string getReadBuffer() const; bool hasDataToSend() const; bool getHasPass() const; diff --git a/sources/channel/channel.cpp b/sources/channel/channel.cpp index 0480080..81872e4 100644 --- a/sources/channel/channel.cpp +++ b/sources/channel/channel.cpp @@ -6,7 +6,7 @@ /* By: sben-tay +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/05/20 22:43:24 by rparodi #+# #+# */ -/* Updated: 2025/06/19 13:58:39 by rparodi ### ########.fr */ +/* Updated: 2025/06/21 19:04:34 by sben-tay ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,10 +16,25 @@ Channel::Channel(const std::string &name, User *owner, size_t maxUsers, bool needInvite) : _name(name), _owner(owner), _maxUsers(maxUsers), _needInvite(needInvite) { this->_protectTopic = false; + if (BONUS) + this->_botChannel = true; + else + this->_botChannel = false; this->_maxUsers = ~0; this->_topic = ""; } +Channel::~Channel() { + for (std::list::iterator it = _users.begin(); it != _users.end(); ++it) { + if (*it != _owner) { + delete *it; + } + } + _users.clear(); + _operators.clear(); + _invited.clear(); +} + /** * @brief Get the name of the channel * @@ -258,3 +273,7 @@ bool Channel::isInvited(User *user) const { std::cerr << user->getName() << " is not invited to the channel " << this->_name << std::endl; return false; } + +void Channel::setBotChannel(bool isBot) { _botChannel = isBot; } + +bool Channel::getBotChannel() const { return _botChannel; } \ No newline at end of file diff --git a/sources/commands/join.cpp b/sources/commands/join.cpp index 1613f16..932d826 100644 --- a/sources/commands/join.cpp +++ b/sources/commands/join.cpp @@ -6,7 +6,7 @@ /* By: sben-tay +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/05/24 17:29:48 by rparodi #+# #+# */ -/* Updated: 2025/06/19 02:27:50 by sben-tay ### ########.fr */ +/* Updated: 2025/06/21 18:51:55 by sben-tay ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,6 +14,7 @@ #include "commands.hpp" #include "logs.hpp" #include +#include "bonus.hpp" using namespace cmd; @@ -65,7 +66,13 @@ void Join::execute() { for (std::list::iterator it = _cTarget->getUsers().begin(); it != _cTarget->getUsers().end(); ++it) { msg353 += (*it)->getNickname() + " "; } - _sender->appendToWriteBuffer(msgJoin + msg332 + msg353 + "\r\n"); + if (BONUS) { + _cTarget->setBotChannel(true); + std::string msgJoinBot = ":bot!ircbot@localhost JOIN #" + _cTarget->getName() + "\r\n"; + _sender->appendToWriteBuffer(msgJoinBot + msgJoin + msg332 + msg353 + "\r\n"); + } + else + _sender->appendToWriteBuffer(msgJoin + msg332 + msg353 + "\r\n"); return; } diff --git a/sources/commands/kick.cpp b/sources/commands/kick.cpp index 20c9289..a6c23c8 100644 --- a/sources/commands/kick.cpp +++ b/sources/commands/kick.cpp @@ -6,13 +6,15 @@ /* By: sben-tay +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/05/24 17:29:48 by rparodi #+# #+# */ -/* Updated: 2025/06/20 17:01:49 by rparodi ### ########.fr */ +/* Updated: 2025/06/21 19:19:30 by sben-tay ### ########.fr */ /* */ /* ************************************************************************** */ #include "kick.hpp" #include "commands.hpp" #include "logs.hpp" +#include "bonus.hpp" + using namespace cmd; @@ -40,7 +42,11 @@ e_code Kick::checkArgs() { return ERR_CHANOPRIVSNEEDED; } _uTarget = searchList(this->_users, _args.at(2)); - if (this->_uTarget == NULL) { + + if (BONUS && _args.at(2) == "bot" && _cTarget->getBotChannel() == true) { + return _PARSING_OK; + } + else if (this->_uTarget == NULL) { WARNING_MSG("User not found"); return ERR_NOSUCHNICK; } @@ -66,8 +72,19 @@ void Kick::execute() { ERROR_MSG("Invalid arguments for INVITE command (see warning message)"); return; } + std::cout << "MODE BONUS ?" << BONUS << std::endl; + if (BONUS && _args.at(2) == "bot") { + if (_cTarget->getBotChannel() == true) { + std::cout << "Bot is already in the channel, kicking it" << std::endl; + std::string msgKickBot = ":bot!ircbot@localhost KICK #" + _cTarget->getName() + " bot :Bot kicked from channel\r\n"; + this->_sender->appendToWriteBuffer(msgKickBot); + _cTarget->setBotChannel(false); + } + std::cout << "peace" << std::endl; + return; + } std::string msgPart = ":" + this->_uTarget->getPrefix() + " PART #" + _cTarget->getName() + "\r\n"; - std::string msgKick = ":" + this->_uTarget->getPrefix() + " KICK #" + this->_cTarget->getName(); + std::string msgKick = ":" + this->_uTarget->getPrefix() + " KICK #" + this->_cTarget->getName() + " " + this->_uTarget->getName() + " :kicked from channel\r\n"; if (_args.size() > 4) msgKick += " :" + _args.at(4); msgKick += "\r\n"; diff --git a/sources/commands/privmsg.cpp b/sources/commands/privmsg.cpp index 10c7b70..782ab66 100644 --- a/sources/commands/privmsg.cpp +++ b/sources/commands/privmsg.cpp @@ -6,13 +6,14 @@ /* By: sben-tay +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/05/24 17:29:48 by rparodi #+# #+# */ -/* Updated: 2025/06/19 02:28:16 by sben-tay ### ########.fr */ +/* Updated: 2025/06/21 18:52:06 by sben-tay ### ########.fr */ /* */ /* ************************************************************************** */ #include "privmsg.hpp" #include "commands.hpp" #include "logs.hpp" +#include "bonus.hpp" using namespace cmd; @@ -61,12 +62,33 @@ void PrivMsg::execute() { std::string content = _args.at(2); std::string msg = ":" + _sender->getPrefix() + " PRIVMSG " + target + " :" + content + "\r\n"; + //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 + " :- 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 + " :- !help → Affiche cette aide\r\n"; + + // Envoi vers un channel if (target[0] == '#') { target.erase(0, 1); if (_cTarget) - _cTarget->sendAllClientInAChannel(msg, _sender); // Optionnel: évite d'envoyer au sender + _cTarget->sendAllClientInAChannel(msg, _sender); + + if (BONUS) { + if (_args.at(2) == "!help") { + std::cout << "BONUS: PING command received, sending PONG" << std::endl; + _cTarget->sendAllClientInAChannel(msgBot); + } + } } + // Envoi vers un user else { if (_uTarget) diff --git a/sources/commands/topic.cpp b/sources/commands/topic.cpp index 84bc55a..4238f9a 100644 --- a/sources/commands/topic.cpp +++ b/sources/commands/topic.cpp @@ -6,7 +6,7 @@ /* By: sben-tay +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/05/24 17:29:48 by rparodi #+# #+# */ -/* Updated: 2025/06/20 17:55:27 by sben-tay ### ########.fr */ +/* Updated: 2025/06/21 14:30:19 by sben-tay ### ########.fr */ /* */ /* ************************************************************************** */ @@ -55,10 +55,10 @@ void Topic::execute() { if (this->_args.size() == 1) { if (this->_cTarget->getTopic().empty()) { - std::string msg331 = ":localhost 331 " + this->_sender->getNickname() + " " + this->_cTarget->getName() + " :No topic is set\r\n"; + std::string msg331 = ":localhost 331 " + this->_sender->getNickname() + " #" + this->_cTarget->getName() + " :No topic is set\r\n"; this->_sender->appendToWriteBuffer(msg331); } else { - std::string msg332 = ":localhost 332 " + this->_sender->getNickname() + " " + this->_cTarget->getName() + " :" + this->_cTarget->getTopic() + "\r\n"; + std::string msg332 = ":localhost 332 " + this->_sender->getNickname() + " #" + this->_cTarget->getName() + " :" + this->_cTarget->getTopic() + "\r\n"; this->_sender->appendToWriteBuffer(msg332); } } else { @@ -70,7 +70,7 @@ void Topic::execute() { } this->_cTarget->setTopic(newTopic); - std::string topicMsg = ":" + this->_sender->getPrefix() + " TOPIC " + this->_cTarget->getName() + " :" + newTopic + "\r\n"; + std::string topicMsg = ":" + this->_sender->getPrefix() + " TOPIC #" + this->_cTarget->getName() + " :" + newTopic + "\r\n"; this->_cTarget->sendAllClientInAChannel(topicMsg); } } diff --git a/sources/core/check.cpp b/sources/core/check.cpp index fd4c884..a35da1d 100644 --- a/sources/core/check.cpp +++ b/sources/core/check.cpp @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* check.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: rparodi +#+ +:+ +#+ */ +/* By: sben-tay +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/05/13 11:25:04 by rparodi #+# #+# */ -/* Updated: 2025/05/13 14:20:47 by rparodi ### ########.fr */ +/* Updated: 2025/06/21 18:49:43 by sben-tay ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/sources/user/user.cpp b/sources/user/user.cpp index 8e3301f..c320d59 100644 --- a/sources/user/user.cpp +++ b/sources/user/user.cpp @@ -6,7 +6,7 @@ /* By: sben-tay +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/05/21 20:37:12 by omoudni #+# #+# */ -/* Updated: 2025/06/20 19:18:27 by sben-tay ### ########.fr */ +/* Updated: 2025/06/21 14:38:31 by sben-tay ### ########.fr */ /* */ /* ************************************************************************** */ @@ -163,9 +163,11 @@ const std::string User::getPrefix() const { return _nickname + "!" + _username + const std::string User::getUsername() const { return _username; } -const std::string& User::getHostname() const { return _hostname; } +const std::string User::getHostname() const { return _hostname; } -const std::string& User::getIpAddress() const { return _ipAdress; } +const std::string User::getIpAddress() const { return _ipAdress; } + +const std::string User::getReadBuffer() const { return _read_buffer; } void User::setHostname(const std::string &hostname) { _hostname = hostname; } From 5720847b9becba74d5b5c5aa291f96f9b734a921 Mon Sep 17 00:00:00 2001 From: Samy BEN TAYEB Date: Sun, 22 Jun 2025 19:42:08 +0200 Subject: [PATCH 3/3] bot finished. update command: kick, privmsg, part and topic --- sources/commands/kick.cpp | 61 ++++++++++++++++++------------------ sources/commands/privmsg.cpp | 4 +-- 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/sources/commands/kick.cpp b/sources/commands/kick.cpp index a6c23c8..0598ffa 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/21 19:19:30 by sben-tay ### ########.fr */ +/* Updated: 2025/06/22 19:38:09 by sben-tay ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,7 +15,6 @@ #include "logs.hpp" #include "bonus.hpp" - using namespace cmd; e_code Kick::checkArgs() { @@ -28,68 +27,68 @@ e_code Kick::checkArgs() { WARNING_MSG("Invalid channel name for KICK command"); INFO_MSG("Channel names must start with a '#' character"); return ERR_NOSUCHCHANNEL; - } else - _args.at(1).erase(0, 1); + } + _args.at(1).erase(0, 1); // On enlève le '#' pour chercher le nom réel _cTarget = searchList(this->_server->getChannelsList(), _args.at(1)); if (_cTarget == NULL) { WARNING_MSG("Channel not found for KICK command"); - INFO_MSG("You can only KICK users to channels you are in"); return ERR_NOSUCHCHANNEL; - } else - _args.at(1).erase(0, 1); + } if (searchList(_cTarget->getOperators(), _sender->getName()) == NULL) { WARNING_MSG("You are not an operator in the channel for KICK command"); return ERR_CHANOPRIVSNEEDED; } - _uTarget = searchList(this->_users, _args.at(2)); - if (BONUS && _args.at(2) == "bot" && _cTarget->getBotChannel() == true) { + if (BONUS && _args.at(2) == "bot" && _cTarget->getBotChannel()) { return _PARSING_OK; } - else if (this->_uTarget == NULL) { - WARNING_MSG("User not found"); + + _uTarget = searchList(this->_users, _args.at(2)); + if (_uTarget == NULL || !_uTarget->isRegistered()) { + WARNING_MSG("User not found or not registered"); return ERR_NOSUCHNICK; } - if (this->_uTarget->isRegistered() == false) { - WARNING_MSG("User is not registered for KICK command"); - INFO_MSG("You can only KICK registered users"); - return ERR_NOSUCHNICK; - } - if (searchList(this->_cTarget->getUsers(), this->_uTarget->getName()) == NULL) { - WARNING_MSG("User is already in the channel for KICK command"); - INFO_MSG("You cannot KICK a user who is already in the channel"); - return ERR_USERONCHANNEL; + if (searchList(this->_cTarget->getUsers(), _uTarget->getName()) == NULL) { + WARNING_MSG("User is not in the channel for KICK command"); + return ERR_USERNOTINCHANNEL; } return _PARSING_OK; } /** - * @brief Execute the kick command - * @note To kick a user from a channel + * @brief Execute the KICK command + * @note Operator removes a user from a channel */ void Kick::execute() { if (checkArgs() != _PARSING_OK) { - ERROR_MSG("Invalid arguments for INVITE command (see warning message)"); + ERROR_MSG("Invalid arguments for KICK command (see warning message)"); return; } - std::cout << "MODE BONUS ?" << BONUS << std::endl; + if (BONUS && _args.at(2) == "bot") { - if (_cTarget->getBotChannel() == true) { - std::cout << "Bot is already in the channel, kicking it" << std::endl; - std::string msgKickBot = ":bot!ircbot@localhost KICK #" + _cTarget->getName() + " bot :Bot kicked from channel\r\n"; - this->_sender->appendToWriteBuffer(msgKickBot); + if (_cTarget->getBotChannel()) { + std::string msgKickBot = ":bot!ircbot@localhost KICK #" + _cTarget->getName() + " " + "bot"; + if (_args.size() > 4) + msgKickBot += " :" + _args.at(3); + msgKickBot += "\r\n"; + std::cout << " msgKickBot: " << msgKickBot << std::endl; + _cTarget->sendAllClientInAChannel(msgKickBot); _cTarget->setBotChannel(false); } - std::cout << "peace" << std::endl; return; } + + std::string msgPart = ":" + this->_uTarget->getPrefix() + " PART #" + _cTarget->getName() + "\r\n"; - std::string msgKick = ":" + this->_uTarget->getPrefix() + " KICK #" + this->_cTarget->getName() + " " + this->_uTarget->getName() + " :kicked from channel\r\n"; + std::string msgKick = ":" + this->_uTarget->getPrefix() + " KICK #" + this->_cTarget->getName(); if (_args.size() > 4) msgKick += " :" + _args.at(4); msgKick += "\r\n"; - this->_uTarget->appendToWriteBuffer(msgKick + msgPart); + std::cout << " msgKick: " << msgKick << "msgPart: " << msgPart << std::endl; + _cTarget->sendAllClientInAChannel(msgKick); + _uTarget->appendToWriteBuffer(msgPart); + _cTarget->removeUser(this->_uTarget); _cTarget->removeOperator(this->_uTarget); diff --git a/sources/commands/privmsg.cpp b/sources/commands/privmsg.cpp index 782ab66..fa36e38 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/21 18:52:06 by sben-tay ### ########.fr */ +/* Updated: 2025/06/22 01:53:33 by sben-tay ### ########.fr */ /* */ /* ************************************************************************** */ @@ -81,7 +81,7 @@ void PrivMsg::execute() { if (_cTarget) _cTarget->sendAllClientInAChannel(msg, _sender); - if (BONUS) { + if (BONUS && _cTarget->getBotChannel()) { if (_args.at(2) == "!help") { std::cout << "BONUS: PING command received, sending PONG" << std::endl; _cTarget->sendAllClientInAChannel(msgBot);