IRC SERVER
The goal of this project is to make you write your own IRC server.
User.hpp
Go to the documentation of this file.
1 #ifndef USER_H
2 #define USER_H
3 
4 // Our includes
5 #include "../Command.hpp"
6 
7 class User : public Command
8 {
9  public:
10  User()
11  {
12  //_name = "user";
13  _description = "termina una sesiĆ³n";
14  _usage = "user";
15  _example[0] = "user <nombre de usuario> <nombre de host> <nombre de "
16  "servidor>: <nombre real>";
17  _example[1] = "user telnet";
18  _needs_auth = false;
19  }
20 
21  bool validate(void)
22  {
23  std::map<size_t, std::string> p = _message->getParams();
24 
25  if (_sender->getNick() == "")
26  {
27  return (false);
28  }
29  if (p.size() < 4)
30  {
32  _message->getCmd()));
33  return (false);
34  }
35  if (_sender->isAuthenticated())
36  {
38  return (false);
39  }
40  return (true);
41  }
42 
43  void execute()
44  {
45  std::string username = _message->getParams()[0];
46  std::string realname = _message->getParams()[3];
47  _sender->setUsername(username);
48  _sender->setRealName(realname);
51  }
52 };
53 #endif
User::validate
bool validate(void)
Definition: User.hpp:21
Command::_description
std::string _description
Definition: Command.hpp:12
User::execute
void execute()
Definition: User.hpp:43
Client::getNick
const std::string getNick(void) const
Definition: Client.hpp:142
Command
Definition: Command.hpp:7
Message::getCmd
std::string getCmd(void) const
Definition: message.cpp:74
Client::message
void message(char const *message)
Definition: client.cpp:15
Client::isAuthenticated
bool isAuthenticated(void) const
Definition: Client.hpp:132
ERR_ALREADYREGISTRED
#define ERR_ALREADYREGISTRED(servername, nick)
Definition: Replies.hpp:133
Client::setUsername
void setUsername(std::string const &username)
Definition: Client.hpp:192
Command::_needs_auth
bool _needs_auth
Definition: Command.hpp:15
Command::_message
Message * _message
Definition: Command.hpp:21
ERR_NEEDMOREPARAMS
#define ERR_NEEDMOREPARAMS(servername, nick, command)
Definition: Replies.hpp:131
Command::_example
std::map< size_t, std::string > _example
Definition: Command.hpp:16
Client::_is_passLogged
bool _is_passLogged
Definition: Client.hpp:36
Message::getParams
std::map< size_t, std::string > getParams(void) const
Definition: message.cpp:79
Command::_usage
std::string _usage
Definition: Command.hpp:13
Command::_sender
Client * _sender
Definition: Command.hpp:19
Client::setRealName
void setRealName(std::string const &realname)
Definition: Client.hpp:196
User
Definition: User.hpp:7
Client::_nick
std::string _nick
Definition: Client.hpp:26
Client::_servername
std::string _servername
Definition: Client.hpp:30
User::User
User()
Definition: User.hpp:10
Client::authenticate
void authenticate(void)
Definition: Client.hpp:98