-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
42 lines (37 loc) · 1.16 KB
/
main.cpp
File metadata and controls
42 lines (37 loc) · 1.16 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
#include "main.h"
extern AdminClientClass* client;
extern std::unordered_map<std::string, void*> fptr_map;
extern std::unordered_map<std::string, void*> module_map;
int exists(const char *fname) {
FILE *file;
if ((file = fopen(fname, "r"))) {
fclose(file);
return 1;
}
return 0;
}
int main(int argc, char** argv){
//load configurations
config_t cfg;
config_init(&cfg);
if (!exists("discord.cfg")) {
printf("config file does not exist\ncreating empty file\n");
system("touch discord.cfg && echo \"token = \\\" \\\"\" >> discord.cfg");
return 0;
}
if(! config_read_file(&cfg, "discord.cfg")) {
fprintf(stderr, "%s:%d - %s\n", config_error_file(&cfg),
config_error_line(&cfg), config_error_text(&cfg));
config_destroy(&cfg);
return(EXIT_FAILURE);
}
const char* token;
if(!config_lookup_string(&cfg, "token", &token)) {
fprintf(stderr, "No 'token' setting in configuration file.\n");
return(EXIT_FAILURE);
}
//initialize bot
AdminClientClass bot(token, SleepyDiscord::USER_CONTROLED_THREADS);
client = ⊥
client->run();
}