new methodes on class Channel(), command INVITE finished.
This commit is contained in:
parent
c94837e9dc
commit
a10815e1e2
3 changed files with 35 additions and 10 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: sben-tay <sben-tay@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/05/24 17:29:48 by rparodi #+# #+# */
|
||||
/* Updated: 2025/06/18 12:52:35 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/06/19 13:53:17 by sben-tay ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -28,14 +28,13 @@ e_code Invite::checkArgs() {
|
|||
return ERR_NOSUCHCHANNEL;
|
||||
} else
|
||||
_args.at(1).erase(0, 1);
|
||||
_cTarget = searchList(_channels, _args.at(1));
|
||||
_cTarget = searchList(_server->getChannelsList(), _args.at(1));
|
||||
if (_cTarget == NULL) {
|
||||
WARNING_MSG("Channel not found for INVITE command");
|
||||
INFO_MSG("You can only invite users to channels you are in");
|
||||
return ERR_NOSUCHCHANNEL;
|
||||
} else
|
||||
_args.at(1).erase(0, 1);
|
||||
if (searchList(_cTarget->getOperators(), _sender->getName()) != NULL) {
|
||||
}
|
||||
if (searchList(_cTarget->getOperators(), _sender->getName()) == NULL) {
|
||||
WARNING_MSG("You are not an operator in the channel for INVITE command");
|
||||
return ERR_NOPRIVILEGES;
|
||||
}
|
||||
|
|
@ -61,10 +60,18 @@ e_code Invite::checkArgs() {
|
|||
* @brief Execute the invite command
|
||||
* @note To invite a peapol to join a channel (from an operator)
|
||||
*/
|
||||
|
||||
void Invite::execute() {
|
||||
if (checkArgs() != _PARSING_OK) {
|
||||
ERROR_MSG("Invalid arguments for INVITE command (see warning message)");
|
||||
return;
|
||||
}
|
||||
// check how the com
|
||||
|
||||
_cTarget->addInvited(_uTarget);
|
||||
|
||||
std::string msgToInvited = ":" + _sender->getPrefix() + " INVITE " + _uTarget->getNickname() + " #" + _cTarget->getName() + "\r\n";
|
||||
_uTarget->appendToWriteBuffer(msgToInvited);
|
||||
|
||||
std::string msg341 = ":localhost 341 " + _sender->getNickname() + " " + _uTarget->getNickname() + " #" + _cTarget->getName() + "\r\n";
|
||||
_sender->appendToWriteBuffer(msg341);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue