forked from zoovely/IRC
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommand.hpp
More file actions
81 lines (73 loc) · 3.34 KB
/
Command.hpp
File metadata and controls
81 lines (73 loc) · 3.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#ifndef COMMAND_H
#define COMMAND_H
#include <list>
#include <ctype.h>
#include <unistd.h>
#include <sys/socket.h>
#include "Client.hpp"
#include "Channel.hpp"
#include "Define.hpp"
#define CONNECT 1
#define PASS 2
#define JOIN 3
#define PART 4
#define INVITE 5
#define KICK 6
#define NICK 7
#define USER 8
#define LIST 9
#define WHOIS 10
#define QUIT 11
#define PING 12
#define OP 13
#define DEOP 14
#define PRIVMSG 15
#define PRIVCH 16
#define NOTICE 17
#define NOTICH 18
#define MODE_I 19
#define MODE_N 20
class Command {
private:
std::string _msg;
std::vector<std::string> _splitMsg;
std::list<Channel>::iterator _chit;
std::list<Channel>::const_iterator _coChit;
std::list<Client>::iterator _cit;
std::list<Client>::const_iterator _coCit;
public:
Command(std::string msg);
void splitMsg(void);
int checkMsgType(void);
void sendFd(int fd, std::string str);
void sendAll(std::vector<int> fds, std::string str);
std::list<Channel>::const_iterator checkValidChannel(const std::string chName, const std::list<Channel> &chList);
std::list<Client>::const_iterator checkValidClient(const std::string nick, const std::list<Client> &cList);
int checkValidNick(const std::string nick);
int chkNick(std::string nickName, std::list<Client> &cList, int fd);
std::list<Client>::iterator getClientByFd(int fd, std::list<Client> cList);
void delChannel(std::list<Channel> &chList, std::string name);
void welcomeMsg(Client &client);
//command list
int connect(int fd, std::string pwd, std::list<Client> &cList);
int pass(Client &client, std::string pwd, std::list<Client> &cList);
int join(const Client &client, std::list<Channel> &chList);
int part(const Client &client, std::list<Channel> &chList);
int invite(const Client &client, const std::list<Channel> &chList, const std::list<Client> &cList);
int kick(const Client &client, std::list<Channel> &chList);
int nick(Client &client, std::list<Client> &cList, const std::list<Channel> &chList);
int user(Client &client);
int list(const Client &client, const std::list<Channel> &chList);
int whois(const Client &client, const std::list<Client> &cList);
int quit(std::list<Client>::iterator cIt, std::list<Channel> &chList, std::list<Client> &cList);
int ping(const Client &client);
int op(const Client &client, std::list<Channel> &chList);
int deop(const Client &client, std::list<Channel> &chList);
int privmsg(const Client &sender, const std::list<Client> &cList);
int privmsg(const Client &sender, const std::list<Channel> &chList);
int notice(const Client &sender, const std::list<Client> &cList);
int notice(const Client &sender, const std::list<Channel> &chList);
int modeI(const Client &sender);
int modeN(const Client &sender, const std::list<Channel> &chList);
};
#endif