forked from KrzaQ/boost-asio-irc-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
44 lines (40 loc) · 1.02 KB
/
main.cpp
File metadata and controls
44 lines (40 loc) · 1.02 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
#include <chat/chat.h>
#include <fstream>
#include <iostream>
#include <string>
/**
* [0] = nick
* [1] = token
* [2] = channel
*/
static std::vector<std::string> get_token() {
std::ifstream f;
std::string buf;
std::vector<std::string> ret(2);
f.open("config");
while (std::getline(f, buf)) {
if (ret[0].empty()) {
ret[0] = buf;
} else if (ret[1].empty()) {
ret[1] = buf;
} else {
ret[2] = buf;
break;
}
}
return ret;
}
int main() {
auto config = get_token();
std::string &nick = config[0];
std::string &token = config[1];
std::string &channel = config[2];
std::cout << "NICK: " << nick << '\n';
std::cout << "TOKEN: " << token << '\n';
std::cout << "CHANNEL: " << channel << '\n';
chat::irc::settings settings{nick, token, channel};
chat::Chat e(settings, [](std::string_view message) {
std::cout << "M: " << message << std::endl;
});
e.async_read_chat();
}