From bb50404ad5e93c9ea4764806a2ab4b13740e5b52 Mon Sep 17 00:00:00 2001 From: fluttershy Date: Wed, 15 Jan 2025 13:34:41 +0500 Subject: [PATCH] include --- include/api.h | 10 ++++++++++ include/includes.h | 9 +++++++++ include/net.h | 5 +++++ libs/api/Author.hpp | 10 +++------- libs/api/Bot.hpp | 9 ++------- libs/api/Channel.hpp | 12 +++--------- libs/api/Embed.hpp | 8 ++------ libs/api/Guild.hpp | 10 +++------- libs/api/Message.hpp | 10 +++------- libs/api/User.hpp | 11 +++-------- libs/gateway/Websocket.hpp | 8 ++------ libs/tls/Network.hpp | 9 +++------ libs/utils/logs.hpp | 3 +-- libs/utils/types.hpp | 4 ---- sources/main.cpp | 14 +++----------- 15 files changed, 52 insertions(+), 80 deletions(-) create mode 100644 include/api.h create mode 100644 include/includes.h create mode 100644 include/net.h diff --git a/include/api.h b/include/api.h new file mode 100644 index 0000000..6bc95de --- /dev/null +++ b/include/api.h @@ -0,0 +1,10 @@ +#ifndef INCLUDE_API_H_ +#define INCLUDE_API_H_ +#include +#include +#include +#include +#include +#include +#include +#endif \ No newline at end of file diff --git a/include/includes.h b/include/includes.h new file mode 100644 index 0000000..fb60bf7 --- /dev/null +++ b/include/includes.h @@ -0,0 +1,9 @@ +#ifndef INCLUDE_INCLUDES_H_ +#define INCLUDE_INCLUDES_H_ +#include +#include +#include +#include +#include +#include +#endif \ No newline at end of file diff --git a/include/net.h b/include/net.h new file mode 100644 index 0000000..c989eb3 --- /dev/null +++ b/include/net.h @@ -0,0 +1,5 @@ +#ifndef INCLUDE_NET_H_ +#define INCLUDE_NET_H_ +#include +#include +#endif \ No newline at end of file diff --git a/libs/api/Author.hpp b/libs/api/Author.hpp index 2967859..cc6ab41 100644 --- a/libs/api/Author.hpp +++ b/libs/api/Author.hpp @@ -1,12 +1,8 @@ #ifndef API_AUTHOR_HPP_ #define API_AUTHOR_HPP_ -#include -#include -#include -#include -using std::string; -using std::cout; -using std::endl; +#include +#include +using std::string, std::cout, std::endl, nlohmann::json; class Author { private: json data; diff --git a/libs/api/Bot.hpp b/libs/api/Bot.hpp index f5c737c..dbac131 100644 --- a/libs/api/Bot.hpp +++ b/libs/api/Bot.hpp @@ -1,12 +1,7 @@ #ifndef API_BOT_HPP_ #define API_BOT_HPP_ -#include -#include -#include -#include -using std::string; -using std::cout; -using std::endl; +#include +using std::string, std::cout, std::endl, nlohmann::json; template class Bot { private: diff --git a/libs/api/Channel.hpp b/libs/api/Channel.hpp index 2400e97..343ca55 100644 --- a/libs/api/Channel.hpp +++ b/libs/api/Channel.hpp @@ -1,14 +1,8 @@ #ifndef API_CHANNEL_HPP_ #define API_CHANNEL_HPP_ -#include -#include -#include -#include -#include -#include -using std::string; -using std::cout; -using std::endl; +#include +#include +using std::string, std::cout, std::endl, nlohmann::json; class Channel { private: json data; diff --git a/libs/api/Embed.hpp b/libs/api/Embed.hpp index fdc3107..9f3efd8 100644 --- a/libs/api/Embed.hpp +++ b/libs/api/Embed.hpp @@ -1,11 +1,7 @@ #ifndef API_EMBED_HPP_ #define API_EMBED_HPP_ -#include -#include -#include -using std::string; -using std::cout; -using std::endl; +#include +using std::string, std::cout, std::endl, nlohmann::json; class EmbedBuilder { private: json embed = { diff --git a/libs/api/Guild.hpp b/libs/api/Guild.hpp index b8590e7..510cd7f 100644 --- a/libs/api/Guild.hpp +++ b/libs/api/Guild.hpp @@ -1,12 +1,8 @@ #ifndef API_GUILD_HPP_ #define API_GUILD_HPP_ -#include -#include -#include -using std::string; -using std::cout; -using std::endl; -using json = nlohmann::json; +#include +//#include +using std::string, std::cout, std::endl, nlohmann::json; class Guild { private: json data; diff --git a/libs/api/Message.hpp b/libs/api/Message.hpp index b7e0b18..08b3701 100644 --- a/libs/api/Message.hpp +++ b/libs/api/Message.hpp @@ -1,12 +1,8 @@ #ifndef API_MESSAGE_HPP_ #define API_MESSAGE_HPP_ -#include -#include -#include -#include -using std::string; -using std::cout; -using std::endl; +#include +#include +using std::string, std::cout, std::endl, nlohmann::json; class Message { private: json data; diff --git a/libs/api/User.hpp b/libs/api/User.hpp index c6e26b4..fa18587 100644 --- a/libs/api/User.hpp +++ b/libs/api/User.hpp @@ -1,14 +1,9 @@ #ifndef API_USER_HPP_ #define API_USER_HPP_ -#include -#include -#include -#include -#include +#include +#include #include -using std::string; -using std::cout; -using std::endl; +using std::string, std::cout, std::endl, nlohmann::json; class User { private: json data; diff --git a/libs/gateway/Websocket.hpp b/libs/gateway/Websocket.hpp index adfe9b2..371815a 100644 --- a/libs/gateway/Websocket.hpp +++ b/libs/gateway/Websocket.hpp @@ -1,15 +1,11 @@ #ifndef GATEWAY_WEBSOCKET_HPP_ #define GATEWAY_WEBSOCKET_HPP_ -#include +#include #include -#include #include -#include #include #include -using json = nlohmann::json; -using std::cout; -using std::endl; +using std::string, std::cout, std::endl, nlohmann::json; using namespace std::chrono; using namespace std::chrono_literals; class WebSocket { diff --git a/libs/tls/Network.hpp b/libs/tls/Network.hpp index f321732..eb5f782 100644 --- a/libs/tls/Network.hpp +++ b/libs/tls/Network.hpp @@ -2,15 +2,12 @@ #define TLS_NETWORK_HPP_ #include #include -#include -#include +#include #include #include #include #include -using std::cout; -using std::cerr; -using std::endl; +using std::string, std::cout, std::endl, nlohmann::json; class NetworkManager { private: WebSocket& web; @@ -121,7 +118,7 @@ public: #endif request += data; if (SSL_write(ssl.get(), request.c_str(), request.length()) <= 0) { - std::cerr << "Failed to send request" << std::endl; + Logs::create(ERROR, NETWORK, "Failed to send request"); handleSSLInitErrors(); } Logs::create(INFO, NETWORK, "Request " + method + " " + path); diff --git a/libs/utils/logs.hpp b/libs/utils/logs.hpp index fd71638..979abf5 100644 --- a/libs/utils/logs.hpp +++ b/libs/utils/logs.hpp @@ -5,8 +5,7 @@ #include #include #include -using std::setfill; -using std::setw; +using std::setfill, std::setw; enum level { INFO, WARNING, ERROR }; enum type { WEBSOCKET, NETWORK }; class Logs { diff --git a/libs/utils/types.hpp b/libs/utils/types.hpp index 22c6480..594a4eb 100644 --- a/libs/utils/types.hpp +++ b/libs/utils/types.hpp @@ -6,8 +6,4 @@ #define g(x, y) (std::get(y)) #define ALL_INTENTS 131071 #define RELEASE -#include -#include -#include -using json = nlohmann::json; #endif \ No newline at end of file diff --git a/sources/main.cpp b/sources/main.cpp index a1ee76b..6ea4ce1 100644 --- a/sources/main.cpp +++ b/sources/main.cpp @@ -1,21 +1,13 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include int main(int argc, char* argv[]) { if (argc != 3) return -1; WebSocket* bot = &WebSocket::getInstance(argv[2], 131071); bot->on(GatewayEvents::MESSAGE_CREATE, [](const Bot& msg) { if (!g(2, msg.net)->isBot()) { g(0, msg.net)->send("939957962972229634", j("content", g(2, msg.net)->content())); - //cout << g(1, msg.net)->extract({ "content" }).get() << endl; } }); bot->start(); return 0; -} \ No newline at end of file +} \ No newline at end of file