#include "Invite.hpp" #include "../IRC.hpp" #include bool Invite::validate(const User &user, const std::string &msg) { size_t pos; size_t leng; std::istringstream iss(msg); std::string word; iss >> word; // should be INVITE iss >> word; // should be the user you want to invite this->targetUser = IRCManager::getUserByName(word); iss >> word; // should be the channel you want to invite to this->targetChannel = IRCManager::getChannelByName(word); if (this->targetChannel) // Check if the channel exists { if (this->targetUser) // Check if the user exists { return (true); } return (false); } return (true); } int Invite::run(User &user, IRC::t_send_f &send) { this->targetChannel->inviteUser(this->targetUser); send(this->targetUser, user.getNickName() + "!~" + user.getUserName() + "@" + user.getHostName() + " INVITE " + this->targetUser->getNickName() + " :" + this->targetChannel->getChannelName()); return (0); }