-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathircbot.h
128 lines (103 loc) · 2.91 KB
/
ircbot.h
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#ifndef IRCBOT_H
#define IRCBOT_H
using namespace std;
class IRCBot;
#include <string>
#include <iostream>
#include <sys/select.h>
#include <netdb.h>
#include <strings.h>
#include <string.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <set>
#include "common.h"
#include "apiserver.h"
#define CRLF "\r\n"
#define BUFSIZE 512
#define WHITE "00"
#define BLACK "01"
#define DARKBLUE "02"
#define GREEN "03"
#define RED "04"
#define DARKRED "05"
#define VIOLET "06"
#define ORANGE "07"
#define YELLOW "08"
#define LIGHTGREEN "09"
#define TURQUOISE "10"
#define LIGHTBLUE "11"
#define BLUE "12"
#define PINK "13"
#define GREY "14"
#define LIGHTGREY "15"
#define COLOR "\x03"
#define BOLD "\x02"
struct schannel {
string name;
string modes;
string topic;
set<string> ops;
set<string> peons;
set<string> users;
};
typedef map<string, schannel> channel_map;
class IRCBot
{
public:
IRCBot();
~IRCBot();
IRCBot(APIServer* api);
void setNick(string nick) { this->nick = nick; }
void setPassword(string password) { this->password = password; }
void setUser(string user) { this->user = user; }
void setServer(string server) { this->server = server; }
void setPort(string port) { this->port = port; }
void Connect();
void Send(string msg);
void Raw(string msg);
void Run();
void Parse(string msg);
void Disconnect();
void killbot();
void Login();
void Perform();
void Privmsg(string target, string message);
void Join(string channel, string key = "");
void Part(string channel);
void Nick(string newnick);
void Quit(string message);
string Color(string text, string fg, string bg = "");
string Bold(string text);
int ConnectToIRC();
channel_map channels;
private:
int server_socket;
APIServer* api;
bool connected;
bool performed;
string nick;
string password;
string user;
string server;
string port;
void OnPing(string ping_id);
void OnPrivmsg(string nick, string hostname, string args);
void OnJoin(string nick, string hostname, string args);
void OnPart(string nick, string hostname, string args);
void OnNotice(string nick, string hostname, string args);
void OnKick(string nick, string hostname, string args);
void OnNickInUse(string nick);
void OnInitialTopic(string args);
void OnTopic(string nick, string hostname, string args);
void OnInitialUsers(string args);
void OnMode(string nick,string hostname, string args);
void OnOp(string nick,string hostname, string channel, string user);
void OnDeOp(string nick,string hostname, string channel, string user);
void OnVoice(string nick,string hostname, string channel, string user);
void OnDeVoice(string nick,string hostname, string channel, string user);
void OnQuit(string nick, string hostname, string args);
void ChanInfo(string c);
};
#endif // IRCBOT_H