From 091301e15d2aa86b5218c1917e351026aaf1d544 Mon Sep 17 00:00:00 2001 From: pajlada Date: Sat, 27 Jan 2024 00:05:18 +0100 Subject: [PATCH] Chatterinoify the repo (#32) --- .github/workflows/build.yml | 6 +- CMakeLists.txt | 12 +-- Makefile | 4 +- README.md | 14 ++++ ast/generate-and-replace-dir.py | 2 +- example/CMakeLists.txt | 30 ++++--- example/main.cpp | 4 +- .../chrono.hpp | 2 +- .../{eventsub => twitch-eventsub-ws}/date.h | 0 .../errors.hpp | 0 .../helpers.hpp | 0 .../listener.hpp | 16 ++-- .../messages/metadata.hpp | 2 +- .../payloads/channel-ban-v1.hpp | 2 +- .../payloads/channel-chat-message-v1.hpp | 2 +- .../payloads/channel-chat-notification-v1.hpp | 2 +- .../payloads/channel-update-v1.hpp | 2 +- .../payloads/session-welcome.hpp | 2 +- .../payloads/stream-offline-v1.hpp | 2 +- .../payloads/stream-online-v1.hpp | 2 +- .../payloads/subscription.hpp | 2 +- .../session.hpp | 0 src/CMakeLists.txt | 3 +- src/chrono.cpp | 2 +- src/messages/metadata.cpp | 4 +- src/payloads/channel-ban-v1.cpp | 6 +- src/payloads/channel-chat-message-v1.cpp | 78 ++++++++++++++++++- src/payloads/channel-chat-notification-v1.cpp | 4 +- src/payloads/channel-update-v1.cpp | 4 +- src/payloads/new-payload.sh | 10 +-- src/payloads/session-welcome.cpp | 4 +- src/payloads/stream-offline-v1.cpp | 4 +- src/payloads/stream-online-v1.cpp | 4 +- src/payloads/subscription.cpp | 4 +- src/session.cpp | 10 +-- 35 files changed, 168 insertions(+), 77 deletions(-) create mode 100644 README.md rename include/{eventsub => twitch-eventsub-ws}/chrono.hpp (91%) rename include/{eventsub => twitch-eventsub-ws}/date.h (100%) rename include/{eventsub => twitch-eventsub-ws}/errors.hpp (100%) rename include/{eventsub => twitch-eventsub-ws}/helpers.hpp (100%) rename include/{eventsub => twitch-eventsub-ws}/listener.hpp (72%) rename include/{eventsub => twitch-eventsub-ws}/messages/metadata.hpp (96%) rename include/{eventsub => twitch-eventsub-ws}/payloads/channel-ban-v1.hpp (98%) rename include/{eventsub => twitch-eventsub-ws}/payloads/channel-chat-message-v1.hpp (98%) rename include/{eventsub => twitch-eventsub-ws}/payloads/channel-chat-notification-v1.hpp (99%) rename include/{eventsub => twitch-eventsub-ws}/payloads/channel-update-v1.hpp (95%) rename include/{eventsub => twitch-eventsub-ws}/payloads/session-welcome.hpp (94%) rename include/{eventsub => twitch-eventsub-ws}/payloads/stream-offline-v1.hpp (94%) rename include/{eventsub => twitch-eventsub-ws}/payloads/stream-online-v1.hpp (95%) rename include/{eventsub => twitch-eventsub-ws}/payloads/subscription.hpp (96%) rename include/{eventsub => twitch-eventsub-ws}/session.hpp (100%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3c14857..13d6987 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -81,7 +81,7 @@ jobs: -DCMAKE_BUILD_TYPE=RelWithDebInfo ` -DCMAKE_TOOLCHAIN_FILE="conan_toolchain.cmake" ` -DEVENTSUB_BUILD_EXAMPLE=On ` - .. + ../example set cl=/MP nmake /S /NOLOGO @@ -128,7 +128,7 @@ jobs: CXXFLAGS=-fno-sized-deallocation cmake \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DEVENTSUB_BUILD_EXAMPLE=On \ - .. + ../example make -j"$(nproc)" shell: bash env: @@ -154,6 +154,6 @@ jobs: -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 \ -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl \ -DEVENTSUB_BUILD_EXAMPLE=On \ - .. + ../example make -j"$(sysctl -n hw.logicalcpu)" shell: bash diff --git a/CMakeLists.txt b/CMakeLists.txt index 96693b8..5f8e9fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,13 +3,13 @@ cmake_policy(SET CMP0087 NEW) # evaluates generator expressions in `install(CODE cmake_policy(SET CMP0091 NEW) # select MSVC runtime library through `CMAKE_MSVC_RUNTIME_LIBRARY` include(FeatureSummary) -option(EVENTSUB_BUILD_EXAMPLE "Build example application" OFF) +set(TWITCH_EVENTSUB_WS_LIBRARY_TYPE "OBJECT" CACHE STRING "What type of library to build this as (defaults to OBJECT)") list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" ) -project(eventsub VERSION 0.1.0) +project(twitch-eventsub-ws VERSION 0.1.0) # Find boost on the system find_package(Boost REQUIRED OPTIONAL_COMPONENTS json) @@ -17,17 +17,9 @@ find_package(Boost REQUIRED OPTIONAL_COMPONENTS json) # Find OpenSSL on the system find_package(OpenSSL REQUIRED) -find_package(Threads REQUIRED) - -find_library(LIBRT rt) - set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) add_subdirectory(src) -if (EVENTSUB_BUILD_EXAMPLE) - add_subdirectory(example) -endif () - feature_summary(WHAT ALL) diff --git a/Makefile b/Makefile index 878d129..f4d0270 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ update-deserializations: update-payloads update-messages update-payloads: - @./ast/venv/bin/python3 ./ast/generate-and-replace-dir.py ./include/eventsub/payloads + @./ast/venv/bin/python3 ./ast/generate-and-replace-dir.py ./include/twitch-eventsub-ws/payloads update-messages: - @./ast/venv/bin/python3 ./ast/generate-and-replace-dir.py ./include/eventsub/messages + @./ast/venv/bin/python3 ./ast/generate-and-replace-dir.py ./include/twitch-eventsub-ws/messages diff --git a/README.md b/README.md new file mode 100644 index 0000000..b77b498 --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +# twitch-eventsub-ws + +This library implements some of [Twitch's EventSub](https://dev.twitch.tv/docs/eventsub/) topics for use in [Chatterino 2](https://github.com/Chatterino/chatterino2) + +Topic generation is done in the `ast` directory + +The example can be built like this: + +```sh +mkdir build +cd build +cmake ../example +cmake --build . +``` diff --git a/ast/generate-and-replace-dir.py b/ast/generate-and-replace-dir.py index 0d40d31..7aee69d 100755 --- a/ast/generate-and-replace-dir.py +++ b/ast/generate-and-replace-dir.py @@ -32,7 +32,7 @@ def main(): header_path = path.path source_path = re.sub(r"\.hpp$", ".cpp", header_path) - source_path = re.sub(r"include[/\\]eventsub[/\\]", "src/", source_path) + source_path = re.sub(r"include[/\\]twitch-eventsub-ws[/\\]", "src/", source_path) if not os.path.isfile(source_path): log.warning(f"Header file {header_path} did not have a matching source file at {source_path}") diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index d8eeec4..496c322 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -1,12 +1,24 @@ -set(EXECUTABLE_PROJECT "${PROJECT_NAME}-example") +cmake_minimum_required(VERSION 3.15) +cmake_policy(SET CMP0087 NEW) # evaluates generator expressions in `install(CODE/SCRIPT)` +cmake_policy(SET CMP0091 NEW) # select MSVC runtime library through `CMAKE_MSVC_RUNTIME_LIBRARY` -add_executable(${EXECUTABLE_PROJECT} main.cpp) +project(twitch-eventsub-ws-example VERSION 0.1.0) -target_link_libraries(${EXECUTABLE_PROJECT} +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +add_executable(${PROJECT_NAME} main.cpp) + +add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/.." twitch-eventsub-ws) + +find_library(LIBRT rt) +find_package(Threads REQUIRED) + +target_link_libraries(${PROJECT_NAME} PUBLIC Threads::Threads - ${PROJECT_NAME} + twitch-eventsub-ws ) # Set the output of TARGET to be @@ -25,19 +37,17 @@ function(set_target_directory_hierarchy TARGET) ) endfunction() -set_target_directory_hierarchy(${EXECUTABLE_PROJECT}) - -target_include_directories(${EXECUTABLE_PROJECT} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +set_target_directory_hierarchy(${PROJECT_NAME}) # See https://github.com/boostorg/beast/issues/2661 -target_compile_definitions(${EXECUTABLE_PROJECT} PRIVATE BOOST_ASIO_DISABLE_CONCEPTS) +target_compile_definitions(${PROJECT_NAME} PRIVATE BOOST_ASIO_DISABLE_CONCEPTS) if (MSVC) - target_compile_options(${EXECUTABLE_PROJECT} PUBLIC /EHsc /bigobj) + target_compile_options(${PROJECT_NAME} PUBLIC /EHsc /bigobj) endif () if (LIBRT) - target_link_libraries(${EXECUTABLE_PROJECT} + target_link_libraries(${PROJECT_NAME} PUBLIC ${LIBRT} ) diff --git a/example/main.cpp b/example/main.cpp index 0a5ec47..8f1373e 100644 --- a/example/main.cpp +++ b/example/main.cpp @@ -1,5 +1,5 @@ -#include "eventsub/listener.hpp" -#include "eventsub/session.hpp" +#include "twitch-eventsub-ws/listener.hpp" +#include "twitch-eventsub-ws/session.hpp" #include #include diff --git a/include/eventsub/chrono.hpp b/include/twitch-eventsub-ws/chrono.hpp similarity index 91% rename from include/eventsub/chrono.hpp rename to include/twitch-eventsub-ws/chrono.hpp index ccb7580..588d432 100644 --- a/include/eventsub/chrono.hpp +++ b/include/twitch-eventsub-ws/chrono.hpp @@ -1,6 +1,6 @@ #pragma once -#include "eventsub/date.h" +#include "twitch-eventsub-ws/date.h" #include diff --git a/include/eventsub/date.h b/include/twitch-eventsub-ws/date.h similarity index 100% rename from include/eventsub/date.h rename to include/twitch-eventsub-ws/date.h diff --git a/include/eventsub/errors.hpp b/include/twitch-eventsub-ws/errors.hpp similarity index 100% rename from include/eventsub/errors.hpp rename to include/twitch-eventsub-ws/errors.hpp diff --git a/include/eventsub/helpers.hpp b/include/twitch-eventsub-ws/helpers.hpp similarity index 100% rename from include/eventsub/helpers.hpp rename to include/twitch-eventsub-ws/helpers.hpp diff --git a/include/eventsub/listener.hpp b/include/twitch-eventsub-ws/listener.hpp similarity index 72% rename from include/eventsub/listener.hpp rename to include/twitch-eventsub-ws/listener.hpp index 9876146..3c1b84e 100644 --- a/include/eventsub/listener.hpp +++ b/include/twitch-eventsub-ws/listener.hpp @@ -1,13 +1,13 @@ #pragma once -#include "eventsub/messages/metadata.hpp" -#include "eventsub/payloads/channel-ban-v1.hpp" -#include "eventsub/payloads/channel-chat-message-v1.hpp" -#include "eventsub/payloads/channel-chat-notification-v1.hpp" -#include "eventsub/payloads/channel-update-v1.hpp" -#include "eventsub/payloads/session-welcome.hpp" -#include "eventsub/payloads/stream-offline-v1.hpp" -#include "eventsub/payloads/stream-online-v1.hpp" +#include "twitch-eventsub-ws/messages/metadata.hpp" +#include "twitch-eventsub-ws/payloads/channel-ban-v1.hpp" +#include "twitch-eventsub-ws/payloads/channel-chat-message-v1.hpp" +#include "twitch-eventsub-ws/payloads/channel-chat-notification-v1.hpp" +#include "twitch-eventsub-ws/payloads/channel-update-v1.hpp" +#include "twitch-eventsub-ws/payloads/session-welcome.hpp" +#include "twitch-eventsub-ws/payloads/stream-offline-v1.hpp" +#include "twitch-eventsub-ws/payloads/stream-online-v1.hpp" namespace eventsub { diff --git a/include/eventsub/messages/metadata.hpp b/include/twitch-eventsub-ws/messages/metadata.hpp similarity index 96% rename from include/eventsub/messages/metadata.hpp rename to include/twitch-eventsub-ws/messages/metadata.hpp index 4939693..fa66257 100644 --- a/include/eventsub/messages/metadata.hpp +++ b/include/twitch-eventsub-ws/messages/metadata.hpp @@ -1,6 +1,6 @@ #pragma once -#include "eventsub/errors.hpp" +#include "twitch-eventsub-ws/errors.hpp" #include diff --git a/include/eventsub/payloads/channel-ban-v1.hpp b/include/twitch-eventsub-ws/payloads/channel-ban-v1.hpp similarity index 98% rename from include/eventsub/payloads/channel-ban-v1.hpp rename to include/twitch-eventsub-ws/payloads/channel-ban-v1.hpp index 410e2ee..0451486 100644 --- a/include/eventsub/payloads/channel-ban-v1.hpp +++ b/include/twitch-eventsub-ws/payloads/channel-ban-v1.hpp @@ -1,6 +1,6 @@ #pragma once -#include "eventsub/payloads/subscription.hpp" +#include "twitch-eventsub-ws/payloads/subscription.hpp" #include diff --git a/include/eventsub/payloads/channel-chat-message-v1.hpp b/include/twitch-eventsub-ws/payloads/channel-chat-message-v1.hpp similarity index 98% rename from include/eventsub/payloads/channel-chat-message-v1.hpp rename to include/twitch-eventsub-ws/payloads/channel-chat-message-v1.hpp index b1b509b..c9c26c5 100644 --- a/include/eventsub/payloads/channel-chat-message-v1.hpp +++ b/include/twitch-eventsub-ws/payloads/channel-chat-message-v1.hpp @@ -1,6 +1,6 @@ #pragma once -#include "eventsub/payloads/subscription.hpp" +#include "twitch-eventsub-ws/payloads/subscription.hpp" #include diff --git a/include/eventsub/payloads/channel-chat-notification-v1.hpp b/include/twitch-eventsub-ws/payloads/channel-chat-notification-v1.hpp similarity index 99% rename from include/eventsub/payloads/channel-chat-notification-v1.hpp rename to include/twitch-eventsub-ws/payloads/channel-chat-notification-v1.hpp index 799383a..4d78988 100644 --- a/include/eventsub/payloads/channel-chat-notification-v1.hpp +++ b/include/twitch-eventsub-ws/payloads/channel-chat-notification-v1.hpp @@ -1,6 +1,6 @@ #pragma once -#include "eventsub/payloads/subscription.hpp" +#include "twitch-eventsub-ws/payloads/subscription.hpp" #include diff --git a/include/eventsub/payloads/channel-update-v1.hpp b/include/twitch-eventsub-ws/payloads/channel-update-v1.hpp similarity index 95% rename from include/eventsub/payloads/channel-update-v1.hpp rename to include/twitch-eventsub-ws/payloads/channel-update-v1.hpp index 442a161..7ab0fef 100644 --- a/include/eventsub/payloads/channel-update-v1.hpp +++ b/include/twitch-eventsub-ws/payloads/channel-update-v1.hpp @@ -1,6 +1,6 @@ #pragma once -#include "eventsub/payloads/subscription.hpp" +#include "twitch-eventsub-ws/payloads/subscription.hpp" #include diff --git a/include/eventsub/payloads/session-welcome.hpp b/include/twitch-eventsub-ws/payloads/session-welcome.hpp similarity index 94% rename from include/eventsub/payloads/session-welcome.hpp rename to include/twitch-eventsub-ws/payloads/session-welcome.hpp index 92b2633..356c195 100644 --- a/include/eventsub/payloads/session-welcome.hpp +++ b/include/twitch-eventsub-ws/payloads/session-welcome.hpp @@ -1,6 +1,6 @@ #pragma once -#include "eventsub/errors.hpp" +#include "twitch-eventsub-ws/errors.hpp" #include diff --git a/include/eventsub/payloads/stream-offline-v1.hpp b/include/twitch-eventsub-ws/payloads/stream-offline-v1.hpp similarity index 94% rename from include/eventsub/payloads/stream-offline-v1.hpp rename to include/twitch-eventsub-ws/payloads/stream-offline-v1.hpp index c51dbf4..0c1f3de 100644 --- a/include/eventsub/payloads/stream-offline-v1.hpp +++ b/include/twitch-eventsub-ws/payloads/stream-offline-v1.hpp @@ -1,6 +1,6 @@ #pragma once -#include "eventsub/payloads/subscription.hpp" +#include "twitch-eventsub-ws/payloads/subscription.hpp" #include diff --git a/include/eventsub/payloads/stream-online-v1.hpp b/include/twitch-eventsub-ws/payloads/stream-online-v1.hpp similarity index 95% rename from include/eventsub/payloads/stream-online-v1.hpp rename to include/twitch-eventsub-ws/payloads/stream-online-v1.hpp index ef41bb5..f775f34 100644 --- a/include/eventsub/payloads/stream-online-v1.hpp +++ b/include/twitch-eventsub-ws/payloads/stream-online-v1.hpp @@ -1,6 +1,6 @@ #pragma once -#include "eventsub/payloads/subscription.hpp" +#include "twitch-eventsub-ws/payloads/subscription.hpp" #include diff --git a/include/eventsub/payloads/subscription.hpp b/include/twitch-eventsub-ws/payloads/subscription.hpp similarity index 96% rename from include/eventsub/payloads/subscription.hpp rename to include/twitch-eventsub-ws/payloads/subscription.hpp index b02590d..26b9aff 100644 --- a/include/eventsub/payloads/subscription.hpp +++ b/include/twitch-eventsub-ws/payloads/subscription.hpp @@ -1,6 +1,6 @@ #pragma once -#include "eventsub/payloads/subscription.hpp" +#include "twitch-eventsub-ws/payloads/subscription.hpp" #include diff --git a/include/eventsub/session.hpp b/include/twitch-eventsub-ws/session.hpp similarity index 100% rename from include/eventsub/session.hpp rename to include/twitch-eventsub-ws/session.hpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8170b8d..152cd4a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -18,7 +18,8 @@ set(SOURCE_FILES messages/metadata.cpp ) -add_library(${PROJECT_NAME} OBJECT ${SOURCE_FILES}) +message(STATUS "Building ${PROJECT_NAME} as a '${TWITCH_EVENTSUB_WS_LIBRARY_TYPE}' library") +add_library(${PROJECT_NAME} ${TWITCH_EVENTSUB_WS_LIBRARY_TYPE} ${SOURCE_FILES}) # Generate source groups for use in IDEs # source_group(TREE ${CMAKE_SOURCE_DIR} FILES ${SOURCE_FILES}) diff --git a/src/chrono.cpp b/src/chrono.cpp index 6a35f7a..901bc00 100644 --- a/src/chrono.cpp +++ b/src/chrono.cpp @@ -1,4 +1,4 @@ -#include "eventsub/chrono.hpp" +#include "twitch-eventsub-ws/chrono.hpp" namespace eventsub { diff --git a/src/messages/metadata.cpp b/src/messages/metadata.cpp index 9938c7a..3dd7b6a 100644 --- a/src/messages/metadata.cpp +++ b/src/messages/metadata.cpp @@ -1,6 +1,6 @@ -#include "eventsub/messages/metadata.hpp" +#include "twitch-eventsub-ws/messages/metadata.hpp" -#include "eventsub/errors.hpp" +#include "twitch-eventsub-ws/errors.hpp" #include diff --git a/src/payloads/channel-ban-v1.cpp b/src/payloads/channel-ban-v1.cpp index acbda0d..bb40f3b 100644 --- a/src/payloads/channel-ban-v1.cpp +++ b/src/payloads/channel-ban-v1.cpp @@ -1,7 +1,7 @@ -#include "eventsub/payloads/channel-ban-v1.hpp" +#include "twitch-eventsub-ws/payloads/channel-ban-v1.hpp" -#include "eventsub/chrono.hpp" -#include "eventsub/errors.hpp" +#include "twitch-eventsub-ws/chrono.hpp" +#include "twitch-eventsub-ws/errors.hpp" #include diff --git a/src/payloads/channel-chat-message-v1.cpp b/src/payloads/channel-chat-message-v1.cpp index 35e0ab0..991b015 100644 --- a/src/payloads/channel-chat-message-v1.cpp +++ b/src/payloads/channel-chat-message-v1.cpp @@ -1,6 +1,6 @@ -#include "eventsub/payloads/channel-chat-message-v1.hpp" +#include "twitch-eventsub-ws/payloads/channel-chat-message-v1.hpp" -#include "eventsub/errors.hpp" +#include "twitch-eventsub-ws/errors.hpp" #include @@ -25,7 +25,9 @@ boost::json::result_for::type tag_invoke( "Missing required key set_id"}; return boost::system::error_code{129, error_missing_field_setID}; } + const auto setID = boost::json::try_value_to(*jvsetID); + if (setID.has_error()) { return setID.error(); @@ -38,7 +40,9 @@ boost::json::result_for::type tag_invoke( "Missing required key id"}; return boost::system::error_code{129, error_missing_field_id}; } + const auto id = boost::json::try_value_to(*jvid); + if (id.has_error()) { return id.error(); @@ -51,7 +55,9 @@ boost::json::result_for::type tag_invoke( "Missing required key info"}; return boost::system::error_code{129, error_missing_field_info}; } + const auto info = boost::json::try_value_to(*jvinfo); + if (info.has_error()) { return info.error(); @@ -82,7 +88,9 @@ boost::json::result_for::type tag_invoke( "Missing required key prefix"}; return boost::system::error_code{129, error_missing_field_prefix}; } + const auto prefix = boost::json::try_value_to(*jvprefix); + if (prefix.has_error()) { return prefix.error(); @@ -95,7 +103,9 @@ boost::json::result_for::type tag_invoke( "Missing required key bits"}; return boost::system::error_code{129, error_missing_field_bits}; } + const auto bits = boost::json::try_value_to(*jvbits); + if (bits.has_error()) { return bits.error(); @@ -108,7 +118,9 @@ boost::json::result_for::type tag_invoke( "Missing required key tier"}; return boost::system::error_code{129, error_missing_field_tier}; } + const auto tier = boost::json::try_value_to(*jvtier); + if (tier.has_error()) { return tier.error(); @@ -139,7 +151,9 @@ boost::json::result_for::type tag_invoke( "Missing required key id"}; return boost::system::error_code{129, error_missing_field_id}; } + const auto id = boost::json::try_value_to(*jvid); + if (id.has_error()) { return id.error(); @@ -152,8 +166,10 @@ boost::json::result_for::type tag_invoke( error_missing_field_emoteSetID{"Missing required key emote_set_id"}; return boost::system::error_code{129, error_missing_field_emoteSetID}; } + const auto emoteSetID = boost::json::try_value_to(*jvemoteSetID); + if (emoteSetID.has_error()) { return emoteSetID.error(); @@ -166,7 +182,9 @@ boost::json::result_for::type tag_invoke( error_missing_field_ownerID{"Missing required key owner_id"}; return boost::system::error_code{129, error_missing_field_ownerID}; } + const auto ownerID = boost::json::try_value_to(*jvownerID); + if (ownerID.has_error()) { return ownerID.error(); @@ -212,7 +230,9 @@ boost::json::result_for::type tag_invoke( "Missing required key user_id"}; return boost::system::error_code{129, error_missing_field_userID}; } + const auto userID = boost::json::try_value_to(*jvuserID); + if (userID.has_error()) { return userID.error(); @@ -225,7 +245,9 @@ boost::json::result_for::type tag_invoke( error_missing_field_userName{"Missing required key user_name"}; return boost::system::error_code{129, error_missing_field_userName}; } + const auto userName = boost::json::try_value_to(*jvuserName); + if (userName.has_error()) { return userName.error(); @@ -238,7 +260,9 @@ boost::json::result_for::type tag_invoke( error_missing_field_userLogin{"Missing required key user_login"}; return boost::system::error_code{129, error_missing_field_userLogin}; } + const auto userLogin = boost::json::try_value_to(*jvuserLogin); + if (userLogin.has_error()) { return userLogin.error(); @@ -270,7 +294,9 @@ boost::json::result_for::type tag_invoke( "Missing required key type"}; return boost::system::error_code{129, error_missing_field_type}; } + const auto type = boost::json::try_value_to(*jvtype); + if (type.has_error()) { return type.error(); @@ -283,7 +309,9 @@ boost::json::result_for::type tag_invoke( "Missing required key text"}; return boost::system::error_code{129, error_missing_field_text}; } + const auto text = boost::json::try_value_to(*jvtext); + if (text.has_error()) { return text.error(); @@ -362,7 +390,9 @@ boost::json::result_for::type tag_invoke( "Missing required key text"}; return boost::system::error_code{129, error_missing_field_text}; } + const auto text = boost::json::try_value_to(*jvtext); + if (text.has_error()) { return text.error(); @@ -407,7 +437,9 @@ boost::json::result_for::type tag_invoke( "Missing required key bits"}; return boost::system::error_code{129, error_missing_field_bits}; } + const auto bits = boost::json::try_value_to(*jvbits); + if (bits.has_error()) { return bits.error(); @@ -438,8 +470,10 @@ boost::json::result_for::type tag_invoke( return boost::system::error_code{129, error_missing_field_parentMessageID}; } + const auto parentMessageID = boost::json::try_value_to(*jvparentMessageID); + if (parentMessageID.has_error()) { return parentMessageID.error(); @@ -453,8 +487,10 @@ boost::json::result_for::type tag_invoke( "Missing required key parent_user_id"}; return boost::system::error_code{129, error_missing_field_parentUserID}; } + const auto parentUserID = boost::json::try_value_to(*jvparentUserID); + if (parentUserID.has_error()) { return parentUserID.error(); @@ -469,8 +505,10 @@ boost::json::result_for::type tag_invoke( return boost::system::error_code{129, error_missing_field_parentUserLogin}; } + const auto parentUserLogin = boost::json::try_value_to(*jvparentUserLogin); + if (parentUserLogin.has_error()) { return parentUserLogin.error(); @@ -485,8 +523,10 @@ boost::json::result_for::type tag_invoke( return boost::system::error_code{129, error_missing_field_parentUserName}; } + const auto parentUserName = boost::json::try_value_to(*jvparentUserName); + if (parentUserName.has_error()) { return parentUserName.error(); @@ -501,8 +541,10 @@ boost::json::result_for::type tag_invoke( return boost::system::error_code{129, error_missing_field_parentMessageBody}; } + const auto parentMessageBody = boost::json::try_value_to(*jvparentMessageBody); + if (parentMessageBody.has_error()) { return parentMessageBody.error(); @@ -517,8 +559,10 @@ boost::json::result_for::type tag_invoke( return boost::system::error_code{129, error_missing_field_threadMessageID}; } + const auto threadMessageID = boost::json::try_value_to(*jvthreadMessageID); + if (threadMessageID.has_error()) { return threadMessageID.error(); @@ -532,8 +576,10 @@ boost::json::result_for::type tag_invoke( "Missing required key thread_user_id"}; return boost::system::error_code{129, error_missing_field_threadUserID}; } + const auto threadUserID = boost::json::try_value_to(*jvthreadUserID); + if (threadUserID.has_error()) { return threadUserID.error(); @@ -548,8 +594,10 @@ boost::json::result_for::type tag_invoke( return boost::system::error_code{129, error_missing_field_threadUserLogin}; } + const auto threadUserLogin = boost::json::try_value_to(*jvthreadUserLogin); + if (threadUserLogin.has_error()) { return threadUserLogin.error(); @@ -564,8 +612,10 @@ boost::json::result_for::type tag_invoke( return boost::system::error_code{129, error_missing_field_threadUserName}; } + const auto threadUserName = boost::json::try_value_to(*jvthreadUserName); + if (threadUserName.has_error()) { return threadUserName.error(); @@ -604,8 +654,10 @@ boost::json::result_for::type tag_invoke( return boost::system::error_code{129, error_missing_field_broadcasterUserID}; } + const auto broadcasterUserID = boost::json::try_value_to(*jvbroadcasterUserID); + if (broadcasterUserID.has_error()) { return broadcasterUserID.error(); @@ -621,8 +673,10 @@ boost::json::result_for::type tag_invoke( return boost::system::error_code{ 129, error_missing_field_broadcasterUserLogin}; } + const auto broadcasterUserLogin = boost::json::try_value_to(*jvbroadcasterUserLogin); + if (broadcasterUserLogin.has_error()) { return broadcasterUserLogin.error(); @@ -638,8 +692,10 @@ boost::json::result_for::type tag_invoke( return boost::system::error_code{ 129, error_missing_field_broadcasterUserName}; } + const auto broadcasterUserName = boost::json::try_value_to(*jvbroadcasterUserName); + if (broadcasterUserName.has_error()) { return broadcasterUserName.error(); @@ -654,8 +710,10 @@ boost::json::result_for::type tag_invoke( return boost::system::error_code{129, error_missing_field_chatterUserID}; } + const auto chatterUserID = boost::json::try_value_to(*jvchatterUserID); + if (chatterUserID.has_error()) { return chatterUserID.error(); @@ -670,8 +728,10 @@ boost::json::result_for::type tag_invoke( return boost::system::error_code{129, error_missing_field_chatterUserLogin}; } + const auto chatterUserLogin = boost::json::try_value_to(*jvchatterUserLogin); + if (chatterUserLogin.has_error()) { return chatterUserLogin.error(); @@ -686,8 +746,10 @@ boost::json::result_for::type tag_invoke( return boost::system::error_code{129, error_missing_field_chatterUserName}; } + const auto chatterUserName = boost::json::try_value_to(*jvchatterUserName); + if (chatterUserName.has_error()) { return chatterUserName.error(); @@ -700,7 +762,9 @@ boost::json::result_for::type tag_invoke( "Missing required key color"}; return boost::system::error_code{129, error_missing_field_color}; } + const auto color = boost::json::try_value_to(*jvcolor); + if (color.has_error()) { return color.error(); @@ -728,7 +792,9 @@ boost::json::result_for::type tag_invoke( error_missing_field_messageID{"Missing required key message_id"}; return boost::system::error_code{129, error_missing_field_messageID}; } + const auto messageID = boost::json::try_value_to(*jvmessageID); + if (messageID.has_error()) { return messageID.error(); @@ -742,8 +808,10 @@ boost::json::result_for::type tag_invoke( "Missing required key message_type"}; return boost::system::error_code{129, error_missing_field_messageType}; } + const auto messageType = boost::json::try_value_to(*jvmessageType); + if (messageType.has_error()) { return messageType.error(); @@ -756,7 +824,9 @@ boost::json::result_for::type tag_invoke( error_missing_field_message{"Missing required key message"}; return boost::system::error_code{129, error_missing_field_message}; } + const auto message = boost::json::try_value_to(*jvmessage); + if (message.has_error()) { return message.error(); @@ -846,8 +916,10 @@ boost::json::result_for::type tag_invoke( "Missing required key subscription"}; return boost::system::error_code{129, error_missing_field_subscription}; } + const auto subscription = boost::json::try_value_to(*jvsubscription); + if (subscription.has_error()) { return subscription.error(); @@ -860,7 +932,9 @@ boost::json::result_for::type tag_invoke( "Missing required key event"}; return boost::system::error_code{129, error_missing_field_event}; } + const auto event = boost::json::try_value_to(*jvevent); + if (event.has_error()) { return event.error(); diff --git a/src/payloads/channel-chat-notification-v1.cpp b/src/payloads/channel-chat-notification-v1.cpp index dc793f2..ab78e18 100644 --- a/src/payloads/channel-chat-notification-v1.cpp +++ b/src/payloads/channel-chat-notification-v1.cpp @@ -1,6 +1,6 @@ -#include "eventsub/payloads/channel-chat-notification-v1.hpp" +#include "twitch-eventsub-ws/payloads/channel-chat-notification-v1.hpp" -#include "eventsub/errors.hpp" +#include "twitch-eventsub-ws/errors.hpp" #include diff --git a/src/payloads/channel-update-v1.cpp b/src/payloads/channel-update-v1.cpp index f7fb8e1..b5c7d02 100644 --- a/src/payloads/channel-update-v1.cpp +++ b/src/payloads/channel-update-v1.cpp @@ -1,6 +1,6 @@ -#include "eventsub/payloads/channel-update-v1.hpp" +#include "twitch-eventsub-ws/payloads/channel-update-v1.hpp" -#include "eventsub/errors.hpp" +#include "twitch-eventsub-ws/errors.hpp" #include diff --git a/src/payloads/new-payload.sh b/src/payloads/new-payload.sh index 066d291..35ff963 100755 --- a/src/payloads/new-payload.sh +++ b/src/payloads/new-payload.sh @@ -31,10 +31,10 @@ header_file_name="${dashed_subscription_name}-${subscription_version}.hpp" source_file_name="${dashed_subscription_name}-${subscription_version}.cpp" # Write the header file -cat > "$SCRIPT_DIR/../../include/eventsub/payloads/$header_file_name" << EOF +cat > "$SCRIPT_DIR/../../include/twitch-eventsub-ws/payloads/$header_file_name" << EOF #pragma once -#include "eventsub/payloads/subscription.hpp" +#include "twitch-eventsub-ws/payloads/subscription.hpp" #include @@ -61,9 +61,9 @@ EOF # Write the source file cat > "$SCRIPT_DIR/$source_file_name" << EOF -#include "eventsub/payloads/$header_file_name" +#include "twitch-eventsub-ws/payloads/$header_file_name" -#include "eventsub/errors.hpp" +#include "twitch-eventsub-ws/errors.hpp" #include @@ -76,6 +76,6 @@ namespace eventsub::payload::$underscored_subscription_name::$subscription_versi EOF echo "Steps that are left for you:" -echo "1. Add a virtual method to the Listener class in include/eventsub/listener.hpp" +echo "1. Add a virtual method to the Listener class in include/twitch-eventsub-ws/listener.hpp" echo "2. Add a handler for this subscription in src/session.cpp's NOTIFICATION_HANDLERS" echo "3. Add payloads/${source_file_name} to src/CMakeLists.txt" diff --git a/src/payloads/session-welcome.cpp b/src/payloads/session-welcome.cpp index 3ae5ef4..025072a 100644 --- a/src/payloads/session-welcome.cpp +++ b/src/payloads/session-welcome.cpp @@ -1,6 +1,6 @@ -#include "eventsub/payloads/session-welcome.hpp" +#include "twitch-eventsub-ws/payloads/session-welcome.hpp" -#include "eventsub/errors.hpp" +#include "twitch-eventsub-ws/errors.hpp" #include diff --git a/src/payloads/stream-offline-v1.cpp b/src/payloads/stream-offline-v1.cpp index 58d4931..8cb9fa0 100644 --- a/src/payloads/stream-offline-v1.cpp +++ b/src/payloads/stream-offline-v1.cpp @@ -1,6 +1,6 @@ -#include "eventsub/payloads/stream-offline-v1.hpp" +#include "twitch-eventsub-ws/payloads/stream-offline-v1.hpp" -#include "eventsub/errors.hpp" +#include "twitch-eventsub-ws/errors.hpp" #include diff --git a/src/payloads/stream-online-v1.cpp b/src/payloads/stream-online-v1.cpp index 4211d3f..35798da 100644 --- a/src/payloads/stream-online-v1.cpp +++ b/src/payloads/stream-online-v1.cpp @@ -1,6 +1,6 @@ -#include "eventsub/payloads/stream-online-v1.hpp" +#include "twitch-eventsub-ws/payloads/stream-online-v1.hpp" -#include "eventsub/errors.hpp" +#include "twitch-eventsub-ws/errors.hpp" #include diff --git a/src/payloads/subscription.cpp b/src/payloads/subscription.cpp index 29f85e5..6192eb5 100644 --- a/src/payloads/subscription.cpp +++ b/src/payloads/subscription.cpp @@ -1,6 +1,6 @@ -#include "eventsub/payloads/subscription.hpp" +#include "twitch-eventsub-ws/payloads/subscription.hpp" -#include "eventsub/errors.hpp" +#include "twitch-eventsub-ws/errors.hpp" #include diff --git a/src/session.cpp b/src/session.cpp index d1176f9..3736347 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -1,9 +1,9 @@ -#include "eventsub/session.hpp" +#include "twitch-eventsub-ws/session.hpp" -#include "eventsub/listener.hpp" -#include "eventsub/messages/metadata.hpp" -#include "eventsub/payloads/channel-ban-v1.hpp" -#include "eventsub/payloads/session-welcome.hpp" +#include "twitch-eventsub-ws/listener.hpp" +#include "twitch-eventsub-ws/messages/metadata.hpp" +#include "twitch-eventsub-ws/payloads/channel-ban-v1.hpp" +#include "twitch-eventsub-ws/payloads/session-welcome.hpp" #include #include