forked from joshuaeckroth/TuringText
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
58 lines (51 loc) · 1.58 KB
/
main.cpp
File metadata and controls
58 lines (51 loc) · 1.58 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
//
// Created by josh on 4/29/23.
//
#include <iostream>
#include "TwilioClient.h"
#include "TwilioServer.h"
#include "Delegator.h"
#include "AI.h"
int main() {
srand(time(NULL));
// read Twilio credentials from environment variables
// if env var exists
string account_sid;
if(getenv("TWILIO_ACCOUNT_SID") != NULL) {
account_sid = getenv("TWILIO_ACCOUNT_SID");
}
string auth_token;
if(getenv("TWILIO_ACCOUNT_SID") != NULL) {
auth_token = getenv("TWILIO_ACCOUNT_SID");
}
string from_number;
if(getenv("TWILIO_ACCOUNT_SID") != NULL) {
from_number = getenv("TWILIO_ACCOUNT_SID");
}
TwilioClient *client = new TwilioClient(account_sid, auth_token, from_number);
if(getenv("OPENAI_API_KEY") == NULL || getenv("OPENAI_API_KEY") == "") {
cout << "Error: OPENAI_API_KEY not set" << endl;
return 1;
}
AI *ai = new AI(getenv("OPENAI_API_KEY"));
GameBook *gb = new GameBook;
HelpTool *helptool = new HelpTool;
delegator = new Delegator(client, ai, gb, helptool);
// send a message
//client.send_message("+16142027904", "Hello, world!");
try
{
auto const address = net::ip::make_address("0.0.0.0");
unsigned short port = static_cast<unsigned short>(8000);
net::io_context ioc{1};
tcp::acceptor acceptor{ioc, {address, port}};
tcp::socket socket{ioc};
http_server(acceptor, socket);
ioc.run();
}
catch(std::exception const& e)
{
std::cerr << "Error: " << e.what() << std::endl;
return EXIT_FAILURE;
}
}