Skip to content

feat: adapt to v1 #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 41 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
c1a70ba
feat: deprecate features no longer available in Top.gg API v0
null8626 Feb 17, 2025
f8019c9
doc: remove usize
null8626 Feb 18, 2025
dbc6d08
feat: add bot_query
null8626 Feb 18, 2025
a80b1f9
fix: woops
null8626 Feb 18, 2025
f507356
feat: add v0
null8626 Feb 19, 2025
c171af5
fix: TOPGG_EXPORT this
null8626 Feb 19, 2025
28b8311
doc: add documentation for autoposter_source
null8626 Feb 19, 2025
56a82b6
meta: bump version and copyright year
null8626 Feb 19, 2025
6773892
doc: documentation tweaks
null8626 Feb 19, 2025
71eeca7
feat: add implementation for co_finish
null8626 Feb 19, 2025
f89509b
feat: add tests
null8626 Feb 20, 2025
a351b54
fix: also include topgg.lib
null8626 Feb 20, 2025
2400a80
feat: almost everything works
null8626 Feb 24, 2025
e8daa6d
feat: remove github workflows
null8626 Feb 24, 2025
4ee2596
style: add space
null8626 Feb 24, 2025
fa13422
style: use braces
null8626 Feb 24, 2025
5f03e57
fix: adapt more stuff for v0
null8626 Feb 25, 2025
e97194e
feat: add topgg_id and id
null8626 Feb 25, 2025
612358a
doc: simplify documentation
null8626 Feb 25, 2025
8c7d1d1
feat: bot_query is now reusable
null8626 Feb 26, 2025
2a1844e
fix: fix segmentation fault risk here
null8626 Feb 26, 2025
1adb4ac
fix: remove double encoding here
null8626 Feb 26, 2025
4342ee0
fix: fix get_bots
null8626 Feb 26, 2025
8978ec7
Merge branch 'v0' of https://github.com/null8626/cpp-sdk into v0
null8626 Feb 26, 2025
15634e6
feat: add review_score and review_count
null8626 Feb 26, 2025
0a56eee
refactor: change __TOPGG_TESTING__ usage
null8626 Feb 27, 2025
55b716b
feat: add test_autoposter and autoposter callbacks
null8626 Feb 27, 2025
a748cc9
feat: add page to get_voters
null8626 Mar 4, 2025
e0158dd
doc: reword documentation
null8626 Mar 4, 2025
f21e804
doc: fix not_found description
null8626 Mar 6, 2025
88e5a09
chore: update date
null8626 Mar 6, 2025
ece1fd2
refactor: remove the need to destruct API token
null8626 Mar 7, 2025
b548a3f
feat: remove url and bannerUrl
null8626 May 5, 2025
3d87f13
fix: GET /bots/votes not working
null8626 May 23, 2025
c94d19c
doc: update error message
null8626 May 23, 2025
fc297c8
feat: fully adapt to v0
null8626 Jun 16, 2025
fdd65df
meta: update dates
null8626 Jun 16, 2025
4d336a6
feat: widgets
null8626 Jun 17, 2025
d777380
feat: add small widgets
null8626 Jun 18, 2025
49f0961
doc: documentation overhaul
null8626 Jun 20, 2025
eeadf16
feat: add webhooks
null8626 Jul 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ README.md eol=lf
CMakeLists.txt eol=lf
docs/Doxyfile eol=lf
docs/*.png binary
docs/*.css eol=lf linguist-vendored=true
docs/*.html eol=lf linguist-vendored=true
**/*.cmake eol=lf
**/*.cpp eol=lf
Expand Down
21 changes: 18 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
**/*.deb
**/*.rpm
**/*.exe
**/*.obj
*.cmake
.idea

cmake-build-debug/
CMakePresets.json

.vscode/
include/dpp/
build/
deps/
docs/html/
include/cpp-httplib/
include/drogon/
include/nlohmann/
**/build/
**/*.dll
**/*.lib
docs/html/

cpp-httplib/
json/

conan_toolchain.cmake
*conan*.bat
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "docs/doxygen-awesome-css"]
path = docs/doxygen-awesome-css
url = https://github.com/jothepro/doxygen-awesome-css.git
[submodule "deps/drogon"]
path = deps/drogon
url = https://github.com/drogonframework/drogon.git
106 changes: 94 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,30 +1,45 @@
cmake_minimum_required(VERSION 3.8.2)
cmake_minimum_required(VERSION 3.15)

project(
topgg
LANGUAGES CXX
HOMEPAGE_URL "https://docs.top.gg/docs"
DESCRIPTION "The official C++ wrapper for the Top.gg API."
DESCRIPTION "A simple API wrapper for Top.gg written in C++."
)

set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type")
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type")

option(BUILD_SHARED_LIBS "Build shared libraries" ON)
option(ENABLE_CORO "Support for C++20 coroutines" OFF)
option(ENABLE_API "Build primary API support" ON)
option(ENABLE_CPP_HTTPLIB_WEBHOOKS "Build support for webhooks via cpp-httplib" OFF)
option(ENABLE_DROGON_WEBHOOKS "Build support for webhooks via drogon" OFF)
option(ENABLE_CORO "Add support for C++20 coroutines" OFF)
option(TESTING "Enable this only if you are testing the library" OFF)

if(ENABLE_API)
file(GLOB TOPGG_SOURCE_FILES src/*.cpp)
endif()

if(ENABLE_CPP_HTTPLIB_WEBHOOKS)
set(TOPGG_SOURCE_FILES ${TOPGG_SOURCE_FILES} src/webhooks/cpp-httplib.cpp src/webhooks/models.cpp)
elseif(ENABLE_DROGON_WEBHOOKS)
set(TOPGG_SOURCE_FILES ${TOPGG_SOURCE_FILES} src/webhooks/drogon.cpp src/webhooks/models.cpp)
endif()

if(BUILD_SHARED_LIBS)
add_library(topgg SHARED ${TOPGG_SOURCE_FILES})

if(WIN32)
target_sources(topgg PRIVATE ${CMAKE_SOURCE_DIR}/topgg.rc)
target_sources(topgg PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/topgg.rc)
endif()
else()
add_library(topgg STATIC ${TOPGG_SOURCE_FILES})
endif()

if(WIN32)
target_compile_definitions(topgg PRIVATE $<$<BOOL:${BUILD_SHARED_LIBS}>:__TOPGG_BUILDING_DLL__:DPP_STATIC TOPGG_STATIC>)
target_compile_definitions(topgg PRIVATE $<IF:$<BOOL:${BUILD_SHARED_LIBS}>,__TOPGG_BUILDING_DLL__,DPP_STATIC TOPGG_STATIC>)
endif()

if(ENABLE_CORO)
Expand All @@ -34,26 +49,93 @@ else()
set(TOPGG_CXX_STANDARD 17)
endif()

if(TESTING)
target_compile_definitions(topgg PRIVATE __TOPGG_TESTING__)
endif()

set_target_properties(topgg PROPERTIES
OUTPUT_NAME topgg
CXX_STANDARD ${TOPGG_CXX_STANDARD}
CXX_STANDARD_REQUIRED ON
)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
if(ENABLE_API)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

find_package(DPP REQUIRED)
endif()

if(ENABLE_CPP_HTTPLIB_WEBHOOKS)
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/include/cpp-httplib/cpp-httplib.h")
execute_process(COMMAND git clone https://github.com/yhirose/cpp-httplib.git --depth 1 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/include/cpp-httplib")
file(MAKE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/cpp-httplib")
endif()
file(RENAME "${CMAKE_CURRENT_SOURCE_DIR}/cpp-httplib/httplib.h" "${CMAKE_CURRENT_SOURCE_DIR}/include/cpp-httplib/httplib.h")
file(REMOVE_RECURSE "${CMAKE_CURRENT_SOURCE_DIR}/cpp-httplib")
endif()

if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/include/nlohmann/json.hpp")
execute_process(COMMAND git clone https://github.com/nlohmann/json.git --depth 1 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/include/nlohmann")
file(MAKE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/nlohmann")
endif()
file(RENAME "${CMAKE_CURRENT_SOURCE_DIR}/json/single_include/nlohmann/json.hpp" "${CMAKE_CURRENT_SOURCE_DIR}/include/nlohmann/json.hpp")
file(REMOVE_RECURSE "${CMAKE_CURRENT_SOURCE_DIR}/json")
endif()
endif()

if(ENABLE_DROGON_WEBHOOKS)
if(WIN32)
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/conan_toolchain.cmake")

include(${CMAKE_CURRENT_SOURCE_DIR}/conan_toolchain.cmake)
endif()

set(DROGON_LIBRARY drogon)

set(
TRANTOR_INCLUDE_DIR
"${CMAKE_CURRENT_SOURCE_DIR}/deps/drogon/trantor"
"${CMAKE_BINARY_DIR}/deps/drogon/trantor/exports"
)

set(
DROGON_INCLUDE_DIR
"${CMAKE_CURRENT_SOURCE_DIR}/deps/drogon/lib/inc"
"${CMAKE_CURRENT_SOURCE_DIR}/deps/drogon/orm_lib/inc"
"${CMAKE_CURRENT_SOURCE_DIR}/deps/drogon/nosql_lib/redis/inc"
"${CMAKE_BINARY_DIR}/deps/drogon/exports"
)

set(BUILD_CTL OFF)
set(BUILD_EXAMPLES OFF)
set(BUILD_BROTLI OFF)
set(BUILD_YAML_CONFIG OFF)
set(USE_SUBMODULE ON)

add_subdirectory(deps/drogon)

target_compile_definitions(topgg PUBLIC __TOPGG_DROGON_WEBHOOKS__)

if(WIN32)
target_compile_definitions(topgg PUBLIC _CRT_SECURE_NO_WARNINGS)
cmake_policy(SET CMP0091 NEW)
endif()
endif()

if(MSVC)
target_compile_options(topgg PUBLIC $<$<CONFIG:Debug>:/diagnostics:caret /MTd> $<$<CONFIG:Release>:/MT /O2 /Oi /Oy /Gy>)
target_compile_options(topgg PUBLIC /nologo $<$<CONFIG:Debug>:/diagnostics:caret /MDd /DDEBUG /D_DEBUG> $<$<CONFIG:Release>:/MD /O2 /Oi /Oy /Gy /DNDEBUG>)
else()
target_compile_options(topgg PUBLIC $<$<CONFIG:Release>:-O3> -Wall -Wextra -Wpedantic -Wformat=2 -Wnull-dereference -Wuninitialized -Wdeprecated)
endif()

target_include_directories(topgg PUBLIC
${CMAKE_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/include
${DPP_INCLUDE_DIR}
${JSONCPP_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIR}
${TRANTOR_INCLUDE_DIR}
${DROGON_INCLUDE_DIR}
)

target_link_libraries(topgg ${DPP_LIBRARIES})
target_link_libraries(topgg PUBLIC ${DPP_LIBRARIES} ${JSONCPP_LIBRARIES} ${DROGON_LIBRARY})
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 Top.gg & null8626
Copyright (c) 2024-2025 Top.gg & null8626

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading