-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello_assert_bot.cpp
More file actions
54 lines (41 loc) · 1006 Bytes
/
hello_assert_bot.cpp
File metadata and controls
54 lines (41 loc) · 1006 Bytes
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
#include <signal.h>
#include "IRCClient.h"
volatile bool running;
void signalHandler(int signal)
{
std::cout << "Stop!" << std::endl;
running = false;
}
void onAssertJoin(IRCMessage message, IRCClient* client)
{
if (message.prefix.nick != "assert") {
return;
}
client->SendIRC("PRIVMSG #grunndev :Hello assert!");
}
int main(int argc, char const *argv[])
{
IRCClient client;
std::string nick("hello_assert_bot");
std::string user("hello_assert_bot");
client.HookIRCCommand("JOIN", &onAssertJoin);
if (!client.InitSocket()) {
return 1;
}
if (!client.Connect("irc.dal.net", 6665)) {
return 1;
}
if (client.Login(nick, user))
{
running = true;
signal(SIGINT, signalHandler);
client.SendIRC("JOIN #grunndev");
while (client.Connected() && running) {
client.ReceiveData();
}
}
if (client.Connected()) {
client.Disconnect();
}
return 0;
}