Skip to content

Commit

Permalink
Merge pull request #25 from brainboxdotcc/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Commandserver authored Sep 11, 2022
2 parents 8ab21be + d7f9268 commit 43a8637
Show file tree
Hide file tree
Showing 39 changed files with 715 additions and 428 deletions.
47 changes: 25 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,30 +60,15 @@ jobs:
TEST_USER_ID: ${{secrets.TEST_USER_ID}}
TEST_EVENT_ID: ${{secrets.TEST_EVENT_ID}}

- name: Package distributable
run: cd build && cpack --verbose

- name: Upload Binary (DEB)
uses: actions/upload-artifact@v2
with:
name: "libdpp - Debian Package ${{matrix.cfg.arch}}"
path: '${{github.workspace}}/build/*.deb'

- name: Upload Binary (RPM)
uses: actions/upload-artifact@v2
with:
name: "libdpp - RPM Package ${{matrix.cfg.arch}}"
path: '${{github.workspace}}/build/*.rpm'

linux-no-unit-tests:
name: Linux ${{matrix.cfg.arch}} (${{matrix.cfg.cpp-version}})
runs-on: ${{matrix.cfg.os}}
strategy:
fail-fast: false # Don't fail everything if one fails. We want to test each OS/Compiler individually
matrix:
cfg:
- { arch: 'amd64', os: ubuntu-latest, cpp-version: g++-11 }
- { arch: 'amd64', os: ubuntu-latest, cpp-version: g++-10 }
- { arch: 'amd64', os: ubuntu-22.04, cpp-version: g++-11 }
- { arch: 'amd64', os: ubuntu-22.04, cpp-version: g++-10 }
- { arch: 'amd64', os: ubuntu-20.04, cpp-version: g++-9 }

steps:
Expand All @@ -101,6 +86,24 @@ jobs:
- name: Build Project
run: cd build && ninja

- name: Package distributable
if: ${{ matrix.cfg.cpp-version == 'g++-10' }}
run: cd build && cpack --verbose

- name: Upload Binary (DEB)
if: ${{ matrix.cfg.cpp-version == 'g++-10' }}
uses: actions/upload-artifact@v2
with:
name: "libdpp - Debian Package ${{matrix.cfg.arch}}"
path: '${{github.workspace}}/build/*.deb'

- name: Upload Binary (RPM)
if: ${{ matrix.cfg.cpp-version == 'g++-10' }}
uses: actions/upload-artifact@v2
with:
name: "libdpp - RPM Package ${{matrix.cfg.arch}}"
path: '${{github.workspace}}/build/*.rpm'

macos:
name: macOS x64
runs-on: macos-latest
Expand Down Expand Up @@ -186,13 +189,13 @@ jobs:
fail-fast: false
matrix:
cfg:
- {name: "ARM64", cmake-options: -DCMAKE_TOOLCHAIN_FILE=cmake/ARM64ToolChain.cmake}
- {name: "ARMv7 HF", cmake-options: -DCMAKE_TOOLCHAIN_FILE=cmake/ARMv7ToolChain.cmake}
- {name: "Linux x86", cmake-options: -DCMAKE_TOOLCHAIN_FILE=cmake/LINUXx86ToolChain.cmake}
- {name: "ARMv6", cmake-options: -DCMAKE_TOOLCHAIN_FILE=cmake/ARMv6ToolChain.cmake}
- {name: "ARM64", os: ubuntu-20.04, cmake-options: -DCMAKE_TOOLCHAIN_FILE=cmake/ARM64ToolChain.cmake}
- {name: "ARMv7 HF", os: ubuntu-20.04, cmake-options: -DCMAKE_TOOLCHAIN_FILE=cmake/ARMv7ToolChain.cmake}
- {name: "Linux x86", os: ubuntu-22.04, cmake-options: -DCMAKE_TOOLCHAIN_FILE=cmake/LINUXx86ToolChain.cmake}
- {name: "ARMv6", os: ubuntu-20.04, cmake-options: -DCMAKE_TOOLCHAIN_FILE=cmake/ARMv6ToolChain.cmake}

name: ${{matrix.cfg.name}}
runs-on: ubuntu-20.04
runs-on: ${{matrix.cfg.os}}
steps:
- name: Checkout D++
uses: actions/checkout@v2
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ core
compile_commands.json
tags
.cache
src/dpp/dpp.rc
/main
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
"codecvt": "cpp",
"future": "cpp",
"cerrno": "cpp",
"compare": "cpp"
"compare": "cpp",
"coroutine": "cpp",
"numbers": "cpp",
"semaphore": "cpp",
"stop_token": "cpp"
}
}
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ else()
message("-- INFO: Using VCPKG if detected")
endif()

if (WIN32 AND NOT MINGW AND BUILD_SHARED_LIBS)
message("-- INFO: Configuring .rc resource script")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/dpp/dpp.rc.in" "${CMAKE_CURRENT_SOURCE_DIR}/src/dpp/dpp.rc" NEWLINE_STYLE WIN32)
endif()

if (NOT DPP_NO_VCPKG AND EXISTS "${_VCPKG_ROOT_DIR}")
set(PROJECT_NAME "dpp")
project(
Expand Down
3 changes: 2 additions & 1 deletion buildtools/changelog.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
foreach ($changelog as $change) {

// Wrap anything that looks like a symbol name in backticks
$change = preg_replace('/([\w_\/]+\.\w+|\S+\(\)|\w+::\w+|dpp::\w+|utility::\w+|(\w+_\w+)+)/', '`$1`', $change);
$change = preg_replace('/([a-zA-Z][\w_\/\-]+\.\w+|\S+\(\)|\w+::\w+|dpp::\w+|utility::\w+|(\w+_\w+)+)/', '`$1`', $change);
$change = preg_replace("/vs(\d+)/", "Visual Studio $1", $change);
$change = preg_replace("/\bfaq\b/", "FAQ", $change);
$change = preg_replace("/\bdiscord\b/", "Discord", $change);
Expand All @@ -73,6 +73,7 @@
$change = preg_replace("/\sarm(\d+)\s/i", ' ARM$1 ', $change);
$change = preg_replace("/\b(was|is|wo)nt\b/i", '$1n\'t', $change);
$change = preg_replace("/\bfreebsd\b/", 'FreeBSD', $change);
$change = preg_replace("/``/", "`", $change);

// Match keywords against categories
$matched = false;
Expand Down
3 changes: 2 additions & 1 deletion buildtools/classes/Generator/CoroGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public function getCommentArray(): array
*/
public function saveHeader(string $content): void
{
$content .= "auto inline co_request(const std::string &url, http_method method, const std::string &postdata = \"\", const std::string &mimetype = \"text/plain\", const std::multimap<std::string, std::string> &headers = {}) {\n\treturn dpp::awaitable(this, [&] (auto cc) { this->request(url, method, cc, mimetype, headers); }); \n}\n\n";
file_put_contents('include/dpp/cluster_coro_calls.h', $content);
}

Expand All @@ -127,4 +128,4 @@ public function saveCpp(string $cppcontent): void
/* No cpp file to save, code is all inline */
}

}
}
4 changes: 2 additions & 2 deletions cmake/ARM64ToolChain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ INCLUDE_DIRECTORIES(
/usr/include/aarch64-linux-gnu)

SET(ZLIB_LIBRARY /lib/aarch64-linux-gnu/libz.so.1.2.11)
SET(OPENSSL_CRYPTO_LIBRARY /usr/lib/aarch64-linux-gnu/libcrypto.so.1.1)
SET(OPENSSL_SSL_LIBRARY /usr/lib/aarch64-linux-gnu/libssl.so.1.1)
SET(OPENSSL_CRYPTO_LIBRARY /usr/lib/aarch64-linux-gnu/libcrypto.so)
SET(OPENSSL_SSL_LIBRARY /usr/lib/aarch64-linux-gnu/libssl.so)

SET(CMAKE_PREFIX_PATH ${RASPBERRY_KINETIC_PATH} ${RASPBERRY_ROOT_PATH}/usr)

Expand Down
10 changes: 5 additions & 5 deletions cmake/LINUXx86ToolChain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ SET(CMAKE_SYSTEM_NAME Linux)
# Possibly needed tweak
#SET(CMAKE_SYSTEM_PROCESSOR i386)

SET(CMAKE_C_COMPILER gcc-8)
SET(CMAKE_CXX_COMPILER g++-8)
SET(CMAKE_C_COMPILER gcc-10)
SET(CMAKE_CXX_COMPILER g++-10)

# Below call is necessary to avoid non-RT problem.
SET(CMAKE_LIBRARY_ARCHITECTURE i386-linux-gnu)
Expand All @@ -17,14 +17,14 @@ INCLUDE_DIRECTORIES(
/usr/include/i386-linux-gnu)

SET(ZLIB_LIBRARY /lib/i386-linux-gnu/libz.so.1.2.11)
SET(OPENSSL_CRYPTO_LIBRARY /usr/lib/i386-linux-gnu/libcrypto.so.1.1)
SET(OPENSSL_SSL_LIBRARY /usr/lib/i386-linux-gnu/libssl.so.1.1)
SET(OPENSSL_CRYPTO_LIBRARY /usr/lib/i386-linux-gnu/libcrypto.so)
SET(OPENSSL_SSL_LIBRARY /usr/lib/i386-linux-gnu/libssl.so)

SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32 " CACHE INTERNAL "" FORCE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32 " CACHE INTERNAL "" FORCE)

EXECUTE_PROCESS(COMMAND sudo dpkg --add-architecture i386)
EXECUTE_PROCESS(COMMAND sudo apt update)
EXECUTE_PROCESS(COMMAND sudo apt install -y g++-8 gcc-8-multilib glibc-*:i386 libc6-dev-i386 g++-8-multilib zlib1g-dev:i386 libssl-dev:i386 libopus-dev:i386 libsodium-dev:i386)
EXECUTE_PROCESS(COMMAND sudo apt install -y g++-10 gcc-10-multilib glibc-*:i386 libc6-dev-i386 g++-10-multilib zlib1g-dev:i386 libssl-dev:i386 libopus-dev:i386 libsodium-dev:i386)
EXECUTE_PROCESS(COMMAND sudo mv /usr/lib/i386-linux-gnu/pkgconfig/libsodium.pc /usr/lib/pkgconfig/)

2 changes: 1 addition & 1 deletion include/dpp/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ class DPP_EXPORT channel : public managed, public json_interface<channel> {
* @param flags Flag bitmask to set from dpp::channel_flags
* @return Reference to self, so these method calls may be chained
*/
channel& set_flags(const uint16_t flags);
channel& set_flags(const uint8_t flags);

/**
* @brief Add (bitwise OR) a flag to this channel object
Expand Down
14 changes: 13 additions & 1 deletion include/dpp/cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,11 @@ class DPP_EXPORT cluster {
friend class discord_client;
friend class discord_voice_client;

/**
* @brief default gateway for connecting the websocket.
*/
std::string default_gateway;

/**
* @brief queue system for commands sent to Discord, and any replies
*/
Expand Down Expand Up @@ -402,7 +407,7 @@ class DPP_EXPORT cluster {
* @param request_threads_raw The number of threads to allocate for making HTTP requests to sites outside of Discord. This defaults to 1. You can increase this at runtime via the object returned from get_raw_rest().
* @throw dpp::exception Thrown on windows, if WinSock fails to initialise, or on any other system if a dpp::request_queue fails to construct
*/
cluster(const std::string &token, uint32_t intents = i_default_intents, uint32_t shards = 0, uint32_t cluster_id = 0, uint32_t maxclusters = 1, bool compressed = true, cache_policy_t policy = {cp_aggressive, cp_aggressive, cp_aggressive}, uint32_t request_threads = 12, uint32_t request_threads_raw = 1);
cluster(const std::string& token, uint32_t intents = i_default_intents, uint32_t shards = 0, uint32_t cluster_id = 0, uint32_t maxclusters = 1, bool compressed = true, cache_policy_t policy = { cp_aggressive, cp_aggressive, cp_aggressive }, uint32_t request_threads = 12, uint32_t request_threads_raw = 1);

/**
* @brief dpp::cluster is non-copyable
Expand Down Expand Up @@ -495,6 +500,13 @@ class DPP_EXPORT cluster {
*/
std::string get_audit_reason();

/**
* @brief Sets the address of the default gateway, for connecting the websockets.
*
* @return cluster& Reference to self for chaining.
*/
cluster& set_default_gateway(std::string& default_gateway);

/**
* @brief Log a message to whatever log the user is using.
* The logged message is passed up the chain to the on_log event in user code which can then do whatever
Expand Down
14 changes: 9 additions & 5 deletions include/dpp/cluster_coro_calls.h
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ auto inline co_channel_edit(const class channel &c) {
}

/**
* @brief Follow a news channel
* @brief Follow an announcement (news) channel
* @see dpp::cluster::channel_follow_news
* @see https://discord.com/developers/docs/resources/channel#follow-news-channel
* @param c Channel id to follow
Expand Down Expand Up @@ -742,12 +742,12 @@ auto inline co_guild_auditlog_get(snowflake guild_id, snowflake user_id, uint32_
* @note This method supports audit log reasons set by the cluster::set_audit_reason() method.
* @param guild_id Guild ID to add ban to
* @param user_id User ID to ban
* @param delete_message_days How many days of their user's messages to also delete (0-7). Defaults to 0
* @param delete_message_seconds How many seconds to delete messages for, between 0 and 604800 (7 days). Defaults to 0
* @return confirmation returned object on completion
* \memberof dpp::cluster
*/
auto inline co_guild_ban_add(snowflake guild_id, snowflake user_id, uint32_t delete_message_days) {
return dpp::awaitable(this, [&] (auto cc) { this->guild_ban_add(guild_id, user_id, delete_message_days, cc); });
auto inline co_guild_ban_add(snowflake guild_id, snowflake user_id, uint32_t delete_message_seconds) {
return dpp::awaitable(this, [&] (auto cc) { this->guild_ban_add(guild_id, user_id, delete_message_seconds, cc); });
}

/**
Expand Down Expand Up @@ -1895,7 +1895,7 @@ auto inline co_thread_members_get(snowflake thread_id) {
* @param thread_name Name of the thread
* @param channel_id Channel in which thread to create
* @param auto_archive_duration Duration after which thread auto-archives. Can be set to - 60, 1440 (for boosted guilds can also be: 4320, 10080)
* @param thread_type Type of thread - GUILD_PUBLIC_THREAD, GUILD_NEWS_THREAD, GUILD_PRIVATE_THREAD
* @param thread_type Type of thread - CHANNEL_PUBLIC_THREAD, CHANNEL_ANNOUNCEMENT_THREAD, CHANNEL_PRIVATE_THREAD
* @param invitable whether non-moderators can add other non-moderators to a thread; only available when creating a private thread
* @param rate_limit_per_user amount of seconds a user has to wait before sending another message (0-21600); bots, as well as users with the permission manage_messages, manage_thread, or manage_channel, are unaffected
* @return thread returned object on completion
Expand Down Expand Up @@ -2310,3 +2310,7 @@ auto inline co_get_webhook_with_token(snowflake webhook_id, const std::string &t


/* End of auto-generated definitions */
auto inline co_request(const std::string &url, http_method method, const std::string &postdata = "", const std::string &mimetype = "text/plain", const std::multimap<std::string, std::string> &headers = {}) {
return dpp::awaitable(this, [&] (auto cc) { this->request(url, method, cc, mimetype, headers); });
}

8 changes: 4 additions & 4 deletions include/dpp/cluster_sync_calls.h
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ confirmation channel_edit_positions_sync(const std::vector<channel> &c);
channel channel_edit_sync(const class channel &c);

/**
* @brief Follow a news channel
* @brief Follow an announcement (news) channel
* @see dpp::cluster::channel_follow_news
* @see https://discord.com/developers/docs/resources/channel#follow-news-channel
* @param c Channel id to follow
Expand Down Expand Up @@ -793,14 +793,14 @@ auditlog guild_auditlog_get_sync(snowflake guild_id, snowflake user_id, uint32_t
* @note This method supports audit log reasons set by the cluster::set_audit_reason() method.
* @param guild_id Guild ID to add ban to
* @param user_id User ID to ban
* @param delete_message_days How many days of their user's messages to also delete (0-7). Defaults to 0
* @param delete_message_seconds How many seconds to delete messages for, between 0 and 604800 (7 days). Defaults to 0
* @return confirmation returned object on completion
* \memberof dpp::cluster
* @throw dpp::rest_exception upon failure to execute REST function
* @warning This function is a blocking (synchronous) call and should only be used from within a separate thread.
* Avoid direct use of this function inside an event handler.
*/
confirmation guild_ban_add_sync(snowflake guild_id, snowflake user_id, uint32_t delete_message_days = 0);
confirmation guild_ban_add_sync(snowflake guild_id, snowflake user_id, uint32_t delete_message_seconds = 0);

/**
* @brief Delete guild ban
Expand Down Expand Up @@ -2008,7 +2008,7 @@ thread_member_map thread_members_get_sync(snowflake thread_id);
* @param thread_name Name of the thread
* @param channel_id Channel in which thread to create
* @param auto_archive_duration Duration after which thread auto-archives. Can be set to - 60, 1440 (for boosted guilds can also be: 4320, 10080)
* @param thread_type Type of thread - GUILD_PUBLIC_THREAD, GUILD_NEWS_THREAD, GUILD_PRIVATE_THREAD
* @param thread_type Type of thread - CHANNEL_PUBLIC_THREAD, CHANNEL_ANNOUNCEMENT_THREAD, CHANNEL_PRIVATE_THREAD
* @param invitable whether non-moderators can add other non-moderators to a thread; only available when creating a private thread
* @param rate_limit_per_user amount of seconds a user has to wait before sending another message (0-21600); bots, as well as users with the permission manage_messages, manage_thread, or manage_channel, are unaffected
* @return thread returned object on completion
Expand Down
1 change: 0 additions & 1 deletion include/dpp/discordclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
using json = nlohmann::json;

#define DISCORD_API_VERSION "10"
#define DEFAULT_GATEWAY "gateway.discord.gg"
#define API_PATH "/api/v" DISCORD_API_VERSION
namespace dpp {

Expand Down
1 change: 1 addition & 0 deletions include/dpp/dpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
#include <dpp/once.h>
#include <dpp/sync.h>
#include <dpp/colors.h>
#include <dpp/discordevents.h>

namespace dpp {

Expand Down
7 changes: 7 additions & 0 deletions include/dpp/restresults.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,13 @@ struct DPP_EXPORT confirmation_callback_t {
*/
confirmation_callback_t(cluster* creator);

/**
* @brief Construct a new confirmation callback object
*
* @param _http The HTTP metadata from the REST call
*/
confirmation_callback_t(const http_request_completion_t& _http);

/**
* @brief Construct a new confirmation callback object
*
Expand Down
2 changes: 1 addition & 1 deletion include/dpp/snowflake.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace dpp {
* @see https://github.com/twitter-archive/snowflake/tree/b3f6a3c6ca8e1b6847baa6ff42bf72201e2c2231
*/
class DPP_EXPORT snowflake final {
friend class std::hash<dpp::snowflake>;
friend struct std::hash<dpp::snowflake>;
protected:
/**
* @brief The snowflake value
Expand Down
6 changes: 3 additions & 3 deletions include/dpp/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
#pragma once

#if !defined(DPP_VERSION_LONG)
#define DPP_VERSION_LONG 0x00100017
#define DPP_VERSION_SHORT 100017
#define DPP_VERSION_TEXT "D++ 10.0.17 (15-Aug-2022)"
#define DPP_VERSION_LONG 0x00100019
#define DPP_VERSION_SHORT 100019
#define DPP_VERSION_TEXT "D++ 10.0.19 (10-Sep-2022)"

#define DPP_VERSION_MAJOR ((DPP_VERSION_LONG & 0x00ff0000) >> 16)
#define DPP_VERSION_MINOR ((DPP_VERSION_LONG & 0x0000ff00) >> 8)
Expand Down
2 changes: 1 addition & 1 deletion library-vcpkg/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
file(GLOB THE_SOURCES "${CMAKE_SOURCE_DIR}/src/dpp/events/*.cpp" "${CMAKE_SOURCE_DIR}/src/dpp/cluster/*.cpp" "${CMAKE_SOURCE_DIR}/src/dpp/*.cpp" "${CMAKE_SOURCE_DIR}/src/*.cpp")
file(GLOB THE_SOURCES "${CMAKE_SOURCE_DIR}/src/dpp/events/*.cpp" "${CMAKE_SOURCE_DIR}/src/dpp/cluster/*.cpp" "${CMAKE_SOURCE_DIR}/src/dpp/*.cpp" "${CMAKE_SOURCE_DIR}/src/dpp/*.rc")

set(LIB_NAME "${PROJECT_NAME}")

Expand Down
Loading

0 comments on commit 43a8637

Please sign in to comment.