-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIrcserv.hpp
More file actions
92 lines (77 loc) · 3.19 KB
/
Ircserv.hpp
File metadata and controls
92 lines (77 loc) · 3.19 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
82
83
84
85
86
87
88
89
90
91
92
#ifndef IRC_SERV_HPP
# define IRC_SERV_HPP
# include "ft_irc.hpp"
# include "Client.hpp"
# include "Channel.hpp"
# define NOPASS_TIMEOUT 5
# define TIMEOUT 300
# define MYPING 15
# define OP_PASSWORD "operator123"
class Ircserv
{
public:
typedef int (*cmd_type)(Client*, Ircserv&, Command&);
Ircserv(int port, const std::string& password);
~Ircserv();
int setup();
void run();
int execCommand(Client* client, Command& command);
void addChannel(const std::string& name);
void addClientToWallops(Client *client);
void removeClient(Client *client);
void removeChannel(Channel *channel);
void removeClientFromWallops(Client *client);
int isChannel(const std::string& name) const ;
bool isClient(const std::string& name) const;
int availableNickname(const std::string& nickname);
void sendPong(Client*, const std::string&) const;
void sendPing();
void sendToClients(const std::string&) const;
const std::string& getPassword() const;
const std::string& getOpPassword() const;
const std::string& getName() const;
const std::string getPrefix() const;
const std::string getSettings() const;
const std::string getDate() const;
Client* getClient(const std::string& nickname) const;
Channel* getChannel(const std::string& name) const;
std::map<std::string, Channel *> getChannels() const;
int getNbChannels() const;
std::vector<Client *> getWallopsClients() const;
private:
int port;
const std::string password;
const std::string opPassword;
const std::string name;
time_t date;
time_t lastPing;
int fd;
struct sockaddr_in address;
std::vector<pollfd> client_fds;
std::map<int, Client *> clients;
std::map<std::string, cmd_type> commands;
std::map<std::string, Channel *> channels;
std::vector<Client *> wallops_clients;
};
int cap(Client *client, Ircserv& serv, Command& command);
int pass(Client *client, Ircserv& serv, Command& command);
int nick(Client *client, Ircserv& serv, Command& command);
int user(Client *client, Ircserv& serv, Command& command);
int oper(Client *client, Ircserv& serv, Command& command);
int mode(Client *client, Ircserv& serv, Command& command);
int quit(Client* client, Ircserv& serv, Command& command);
int msg(Client *client, Ircserv& serv, Command& command);
int join(Client *client, Ircserv& serv, Command& command);
int part(Client *client, Ircserv& serv, Command& command);
int ping(Client *client, Ircserv& serv, Command& command);
int pong(Client *client, Ircserv& serv, Command& command);
int topic(Client *client, Ircserv& serv, Command& command);
int list(Client *client, Ircserv& serv, Command& command);
int invite(Client *client, Ircserv& serv, Command& command);
int kick(Client *client, Ircserv& serv, Command& command);
int who(Client *client, Ircserv& serv, Command& command);
int kill(Client *client, Ircserv& serv, Command& command);
int wallops(Client *client, Ircserv& serv, Command& command);
int notice(Client *client, Ircserv& serv, Command& command);
int whois(Client *client, Ircserv& serv, Command& command);
#endif