forked from rcxpony/sparkle
.h -> .hpp
This commit is contained in:
parent
ebdefba4e2
commit
2da2fb1ca2
@ -1,5 +1,5 @@
|
||||
#ifndef INCLUDE_API_H_
|
||||
#define INCLUDE_API_H_
|
||||
#ifndef INCLUDE_API_HPP_
|
||||
#define INCLUDE_API_HPP_
|
||||
#include <api/Author.hpp>
|
||||
#include <api/Message.hpp>
|
||||
#include <api/Channel.hpp>
|
@ -1,5 +1,5 @@
|
||||
#ifndef INCLUDE_INCLUDES_H_
|
||||
#define INCLUDE_INCLUDES_H_
|
||||
#ifndef INCLUDE_INCLUDES_HPP_
|
||||
#define INCLUDE_INCLUDES_HPP_
|
||||
#include <utils/types.hpp>
|
||||
#include <utils/json.hpp>
|
||||
#include <utils/log.hpp>
|
@ -1,5 +1,5 @@
|
||||
#ifndef INCLUDE_NET_H_
|
||||
#define INCLUDE_NET_H_
|
||||
#ifndef INCLUDE_NET_HPP_
|
||||
#define INCLUDE_NET_HPP_
|
||||
#include <gateway/Websocket.hpp>
|
||||
#include <network/Network.hpp>
|
||||
#endif
|
@ -1,7 +1,7 @@
|
||||
#ifndef API_AUTHOR_HPP_
|
||||
#define API_AUTHOR_HPP_
|
||||
#include <includes.h>
|
||||
#include <net.h>
|
||||
#include <includes.hpp>
|
||||
#include <net.hpp>
|
||||
class Author {
|
||||
private:
|
||||
nlohmann::json data;
|
||||
@ -25,7 +25,8 @@ public:
|
||||
discriminator(d["author"]["discriminator"]),
|
||||
message_id(d["id"]),
|
||||
isPinned(d["pinned"]),
|
||||
isBot(d["author"].contains("bot") ? d["author"]["bot"].get<bool>() : false) {};
|
||||
isBot(d["author"].contains("bot") ? d["author"]["bot"].get<bool>() : false) {
|
||||
};
|
||||
std::string send(const nlohmann::json& msg) {
|
||||
return req.request(HttpMethods::POST, DiscordEndpoints::details::latest + "/channels/" + d["channel_id"].get<std::string>() + "/messages", msg.dump());
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
#ifndef API_BOT_HPP_
|
||||
#define API_BOT_HPP_
|
||||
#include <includes.h>
|
||||
#include <includes.hpp>
|
||||
template<typename...Args>
|
||||
class Discord {
|
||||
private:
|
||||
@ -33,8 +33,7 @@ public:
|
||||
bool isBot() const {
|
||||
try {
|
||||
return data["d"]["bot"];
|
||||
}
|
||||
catch (...) {
|
||||
} catch (...) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef API_CHANNEL_HPP_
|
||||
#define API_CHANNEL_HPP_
|
||||
#include <includes.h>
|
||||
#include <net.h>
|
||||
#include <includes.hpp>
|
||||
#include <net.hpp>
|
||||
class Channel {
|
||||
private:
|
||||
nlohmann::json data;
|
||||
|
@ -1,6 +1,6 @@
|
||||
#ifndef API_EMBED_HPP_
|
||||
#define API_EMBED_HPP_
|
||||
#include <includes.h>
|
||||
#include <includes.hpp>
|
||||
class EmbedBuilder {
|
||||
private:
|
||||
nlohmann::json embed = {
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef API_GUILD_HPP_
|
||||
#define API_GUILD_HPP_
|
||||
#include <includes.h>
|
||||
#include <net.h>
|
||||
#include <includes.hpp>
|
||||
#include <net.hpp>
|
||||
class Guild {
|
||||
private:
|
||||
nlohmann::json data;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef API_MESSAGE_HPP_
|
||||
#define API_MESSAGE_HPP_
|
||||
#include <includes.h>
|
||||
#include <net.h>
|
||||
#include <includes.hpp>
|
||||
#include <net.hpp>
|
||||
class Message {
|
||||
private:
|
||||
nlohmann::json data;
|
||||
@ -15,8 +15,7 @@ public:
|
||||
std::string getMessages(const std::string& id, const std::string& count, const std::string& before = "") {
|
||||
if (before.empty()) {
|
||||
return req.request(HttpMethods::GET, DiscordEndpoints::details::latest + "/channels/" + id + "/messages?limit=" + count);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return req.request(HttpMethods::GET, DiscordEndpoints::details::latest + "/channels/" + id + "/messages?before=" + before + "&limit=" + count);
|
||||
}
|
||||
return "";
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef API_USER_HPP_
|
||||
#define API_USER_HPP_
|
||||
#include <includes.h>
|
||||
#include <net.h>
|
||||
#include <includes.hpp>
|
||||
#include <net.hpp>
|
||||
#include <vector>
|
||||
class User {
|
||||
private:
|
||||
@ -18,8 +18,7 @@ public:
|
||||
for (const auto& key : d) {
|
||||
if (current.contains(key)) {
|
||||
current = current[key];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return "Key not found.";
|
||||
}
|
||||
}
|
||||
@ -32,8 +31,7 @@ public:
|
||||
bool isBot() const {
|
||||
try {
|
||||
return data["d"]["author"]["bot"];
|
||||
}
|
||||
catch (...) {
|
||||
} catch (...) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
#ifndef GATEWAY_WEBSOCKET_HPP_
|
||||
#define GATEWAY_WEBSOCKET_HPP_
|
||||
#include <includes.h>
|
||||
#include <includes.hpp>
|
||||
#include <thread>
|
||||
#include <ixwebsocket/IXNetSystem.h>
|
||||
#include <ixwebsocket/IXWebSocket.h>
|
||||
|
@ -1,6 +1,6 @@
|
||||
#ifndef TLS_NETWORK_HPP_
|
||||
#define TLS_NETWORK_HPP_
|
||||
#include <includes.h>
|
||||
#include <includes.hpp>
|
||||
#include <gateway/Websocket.hpp>
|
||||
#include <curl/curl.h>
|
||||
class NetworkManager {
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <api.h>
|
||||
#include <includes.h>
|
||||
#include <api.hpp>
|
||||
#include <includes.hpp>
|
||||
int main(int argc, char* argv[]) {
|
||||
if (argc != 3) return -1;
|
||||
WebSocket* bot = &WebSocket::getInstance(argv[2], GatewayIntents::AllIntents);
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <includes.h>
|
||||
#include <net.h>
|
||||
#include <includes.hpp>
|
||||
#include <net.hpp>
|
||||
TEST(NetworkManagerTest, RequestReturnsExpectedValue) {
|
||||
NetworkManager& networkManager = NetworkManager::getInstance();
|
||||
EXPECT_FALSE(networkManager.request(HttpMethods::POST, DiscordEndpoints::details::latest + "/channels/939957962972229634/messages", { "content", "test" }).empty());
|
||||
|
Loading…
x
Reference in New Issue
Block a user