40 lines
785 B
C++
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);
|
|
}
|
|
}
|