blabla/Who.cpp

61 lines
2.5 KiB
C++
Raw Normal View History

2024-08-03 21:04:44 +02:00
#include "Who.hpp"
#include "../IRC.hpp"
#include <string>
bool Who::validate(const User &user, const std::string &msg)
{
std::istringstream iss(msg);
std::string word;
std::string current;
iss >> word; // should be WHO
iss >> word; // should be the channel we want the userlist for
this->targetChannel = IRCManager::getChannelFromName(word);
if (this->targetChannel)
{
std::istringstream userList(this->targetChannel->getUserList());
userList >> current;
while (current[0])
{
if (user->getNickName() == current)
return (true);
userList >> current;
}
}
return (false);
}
int Who::run(User &user, IRC::t_send_f &send)
{
std::istringstream userList(this->targetChannel->getUserList());
std::string current;
User userObj;
send(user, ":" + IRCManager::getHostName() + " 324 " user->getNickName() + this->targetChannel->getChannelName() + "need to extract modes"; // better do this when I get Channel.hpp
send(user, ":" + IRCManager::getHostName() + " 329 " user->getNickName() + this->targetChannel->getChannelName() + "1621432263"; // not sure what this code is for, Maybe the age of the channel or something
userList >> current;
while (current[0])
{
userObj = IRCManager::getUserFromName(current);
send(user, ":" + IRCManager::getHostName() + " 354 " user->getNickName() + " 152 " + this->targetChannel->getChannelName() + " ~" userObj->getUserName() + " " + userObj->getHostName() + " " + IRCManager::getHostName() + " " + userObj->getNickName " H 0 :" userObj->getRealName();
userList >> current;
}
return (0);
}
//+n Disallows external messages.
//+t Only op/hops can set the topic.
//+p Sets the channel as invisible in /list.
//+s Sets the channel as invisible in /list and /whois.
//+i Sets the channel as closed unless the person was invited.
//+k [pass] Sets a password for the channel which users must enter to join.
//+l [number] Sets a limit on the number of users who are allowed in the channel at the same time.
//+m Prevents users who are not opped/hopped/voiced from talking.
//+R Sets the channel so only registered nicks are allowed in.
//+M Sets the channel so only registered nicks are allowed to talk.
//+S Strips formatting from messages, rendering them as plaintext.
//+c Blocks messages containing color codes.
//+i A user must be invited to join the channel.
//+N No nick changes permitted in the channel.