blabla/Quit.cpp
Danny Jonker d426297b2a bla
2024-08-03 21:04:44 +02:00

40 lines
785 B
C++

#include "Quit.hpp"
#include "../IRC.hpp"
#include <string>
#include <set>
Quit::Quit() {}
Quit::~Quit() {}
bool Quit::validate(const User &user, const std::string &msg)
{
size_t pos;
size_t leng;
leng = msg.length();
pos = msg.find(" ");
this->reason = msg.substr(pos, leng - pos);
return true;
}
int Quit::run(User &user, IRC::t_send_f &send)
{
std::istringstream iss(user->getChannelList());
std::string target;
iss >> target;
while (target[0])
{
send(IRCManager::getChannelFromName(target), user.getNickName() + user.getHostName() + " Quit " + this->reason);
iss >> target;
if (!user->getRegistered())
IRCManager::removeUserFromChannel(user, IRCManager::getChannelFromName(target));
}
if (!user->getRegistered())
{
IRCManager::delUser(user);
}
}