2016-07-10 01:18:13 +01:00
|
|
|
#include "http/HTTPHelper.hpp"
|
|
|
|
|
|
|
|
#include <cstdio>
|
|
|
|
|
|
|
|
#include "APIHelper.hpp"
|
|
|
|
|
2016-07-10 19:17:35 +01:00
|
|
|
APIHelper::APIHelper() : BASE_URL("https://discordapp.com/api"), CHANNELS_URL(BASE_URL + "/channels"),
|
2016-07-20 22:57:47 +01:00
|
|
|
JSON_CTYPE("application/json") {
|
2016-07-10 01:18:13 +01:00
|
|
|
http = new HTTPHelper();
|
|
|
|
}
|
|
|
|
|
|
|
|
void APIHelper::send_message(std::string channel_id, std::string message) {
|
2016-07-20 22:57:47 +01:00
|
|
|
const std::string url = CHANNELS_URL + "/" + channel_id + "/messages";
|
2016-07-10 01:18:13 +01:00
|
|
|
json data = {
|
|
|
|
{ "content", message }
|
|
|
|
};
|
|
|
|
|
|
|
|
const std::string response = http->post_request(url, JSON_CTYPE, data.dump());
|
2016-07-10 19:17:35 +01:00
|
|
|
// TODO: verify success
|
2016-07-10 01:18:13 +01:00
|
|
|
}
|