-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathPhantomBot.cpp
More file actions
73 lines (60 loc) · 1.33 KB
/
PhantomBot.cpp
File metadata and controls
73 lines (60 loc) · 1.33 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
/**
PhantomBot.cpp
PhantomBot Project
By: Robert F. (Phantom139)
**/
#include "PhantomBot.h"
/*
PhantomBot Class
*/
PhantomBot::PhantomBot() : irc(NULL) {
initialized = false;
wantsQuit = false;
}
PhantomBot::~PhantomBot() {
}
PhantomBot &PhantomBot::fetchInstance() {
if (managedSingleton<PhantomBot>::instance() == NULL) {
managedSingleton<PhantomBot>::createInstance();
}
return *(managedSingleton<PhantomBot>::instance());
}
void PhantomBot::init(vector<string> &conf) {
if (initialized) {
return;
}
//Initialize IRC Module and Input Module
irc = new TwitchIRC(conf[0].c_str(), conf[0].c_str(), conf[4].c_str(), conf[1].c_str(), (U32)atoi(conf[2].c_str()), conf[3].c_str());
initialized = true;
run();
}
void PhantomBot::run() {
while (irc->SocketActive()) {
irc->Update();
}
}
/*
MAIN METHOD
ENTRY POINT
*/
int main(void) {
srand((U32)time(NULL));
//read the config
ACHAR line[512];
vector<string> config;
fstream f("botconfig.txt", ios::in);
while(!f.eof()) {
f.getline(line, 512);
config.push_back(line);
memset(&line[0], 0, sizeof(line));
}
//Set stuff up...
if(config.size() >= 5) {
PhantomBot::fetchInstance().init(config);
}
else {
cout << "There was an error in your 'botconfig.txt' file, contact Phantom139 for support" << endl;
}
cout << "Closing program..." << endl;
return 0;
}