Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into chatterino7
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerixyz committed Feb 16, 2025
2 parents cd8116f + fbe1448 commit 9f34cad
Show file tree
Hide file tree
Showing 55 changed files with 1,699 additions and 234 deletions.
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ tests/snapshots/**/*.json

# Ignore submodule files
lib/*/
!lib/twitch-eventsub-ws
conan-pkgs/*/
cmake/sanitizers-cmake/
tools/crash-handler
Expand All @@ -30,3 +31,6 @@ vcpkg_installed/

# Compile commands generated by CMake
compile_commands.json

# include files
*.inc
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Minor: Added the ability to filter on messages by the author's user ID (example: `author.user_id == "22484632"`). (#5862)
- Minor: Improved error messaging of the `/clip` command. (#5879)
- Minor: Added Linux support for Live Notifications toasts. (#5881)
- Minor: Messages can now be deleted from the context menu in a channel. (#5956)
- Bugfix: Fixed a potential way to escape the Lua Plugin sandbox. (#5846)
- Bugfix: Fixed a crash relating to Lua HTTP. (#5800)
- Bugfix: Fixed a crash that could occur on Linux and macOS when clicking "Install" from the update prompt. (#5818)
Expand All @@ -24,8 +25,9 @@
- Bugfix: Ensure miniaudio backend exits even if it doesn't exit cleanly. (#5896)
- Bugfix: Fixed search in emote popup not always working correctly. (#5946)
- Bugfix: Fixed channel point redemptions with messages not showing up if PubSub is disconnected. (#5948)
- Bugfix: Fixed the input font not immediately updating when zooming in/out. (#5960)
- Dev: Subscriptions to PubSub channel points redemption topics now use no auth token, making it continue to work during PubSub shutdown. (#5947)
- Dev: Add initial experimental EventSub support. (#5837, #5895, #5897, #5904, #5910, #5903, #5915, #5916, #5930, #5935, #5932, #5943)
- Dev: Add initial experimental EventSub support. (#5837, #5895, #5897, #5904, #5910, #5903, #5915, #5916, #5930, #5935, #5932, #5943, #5952, #5953)
- Dev: Remove unneeded platform specifier for toasts. (#5914)
- Dev: Highlight checks now use non-capturing groups for the boundaries. (#5784)
- Dev: Removed unused PubSub whisper code. (#5898)
Expand All @@ -41,6 +43,7 @@
- Dev: Updated `qtkeychain` to 0.15.0. (#5871)
- Dev: Updated `googletest` to 1.16.0. (#5942)
- Dev: Fixed duplicate CMake configure in clean builds. (#5940)
- Dev: BTTV emotes are now loaded as WEBP. (#5957)

## 2.5.2

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ if (libavif_FOUND AND NOT CHATTERINO_NO_AVIF_PLUGIN)
set(CHATTERINO_WITH_AVIF_PLUGIN ON)
endif()

add_subdirectory(lib/twitch-eventsub-ws EXCLUDE_FROM_ALL)
add_subdirectory(lib/twitch-eventsub-ws)

# Used to provide a date of build in the About page (for nightly builds). Getting the actual time of
# compilation in CMake is a more involved, as documented in https://stackoverflow.com/q/24292898.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
![chatterinoLogo](https://user-images.githubusercontent.com/41973452/272541622-52457e89-5f16-4c83-93e7-91866c25b606.png)
Chatterino7 [![GitHub Actions Build (Windows, Ubuntu, MacOS)](https://github.com/SevenTV/chatterino7/workflows/Build/badge.svg?branch=chatterino7)](https://github.com/SevenTV/chatterino7/actions?query=workflow%3ABuild+branch%3Achatterino7) [![Chocolatey Package](https://img.shields.io/chocolatey/v/chatterino7?include_prereleases)](https://chocolatey.org/packages/chatterino7)
Chatterino7 [![GitHub Actions Build (Windows, Ubuntu, MacOS)](https://github.com/seventv/chatterino7/actions/workflows/build.yml/badge.svg?branch=chatterino7)](https://github.com/SevenTV/chatterino7/actions?query=workflow%3ABuild+branch%3Achatterino7) [![Chocolatey Package](https://img.shields.io/chocolatey/v/chatterino7?include_prereleases)](https://chocolatey.org/packages/chatterino7)
============

Chatterino7 is a fork of Chatterino 2. This fork mainly contains features that aren't accepted into Chatterino 2, most notably 7TV subscriber features.
Expand Down
2 changes: 1 addition & 1 deletion lib/WinToast
9 changes: 9 additions & 0 deletions lib/twitch-eventsub-ws/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,12 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(cmake/GenerateJson.cmake)

add_subdirectory(src)

if(BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()

if(BUILD_BENCHMARKS)
add_subdirectory(benchmarks)
endif()
28 changes: 28 additions & 0 deletions lib/twitch-eventsub-ws/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
project(twitch-eventsub-ws-benchmark)

set(SOURCES
src/main.cpp
resources/bench.qrc

src/parse.cpp
)

add_executable(${PROJECT_NAME} ${SOURCES})
add_sanitizers(${PROJECT_NAME})

target_link_libraries(${PROJECT_NAME} PRIVATE
twitch-eventsub-ws
benchmark::benchmark
Qt${MAJOR_QT_VERSION}::Core # for QFile
)

set_target_properties(${PROJECT_NAME}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
CXX_STANDARD 20
AUTORCC ON
)

if(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /EHsc /bigobj)
endif()
5 changes: 5 additions & 0 deletions lib/twitch-eventsub-ws/benchmarks/resources/bench.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/bench">
<file>messages.ndjson</file>
</qresource>
</RCC>
24 changes: 24 additions & 0 deletions lib/twitch-eventsub-ws/benchmarks/resources/messages.ndjson

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions lib/twitch-eventsub-ws/benchmarks/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include <benchmark/benchmark.h>

BENCHMARK_MAIN();
135 changes: 135 additions & 0 deletions lib/twitch-eventsub-ws/benchmarks/src/parse.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
#include "twitch-eventsub-ws/listener.hpp"
#include "twitch-eventsub-ws/session.hpp"

#include <benchmark/benchmark.h>
#include <boost/beast/core/flat_buffer.hpp>
#include <QFile>

#include <memory>

namespace {

using namespace chatterino::eventsub::lib;

std::vector<boost::beast::flat_buffer> readMessages()
{
QFile file(":/bench/messages.ndjson");
bool ok = file.open(QFile::ReadOnly);
assert(ok);

std::vector<boost::beast::flat_buffer> messages;
while (!file.atEnd())
{
QByteArray line = file.readLine();
if (line.isEmpty())
{
continue;
}

boost::beast::flat_buffer buf;
auto inner = buf.prepare(line.size());
std::memcpy(inner.data(), line.data(), inner.size());
buf.commit(inner.size());

messages.emplace_back(std::move(buf));
}
return messages;
}

class NoopListener : public Listener
{
public:
NoopListener() = default;

// NOLINTBEGIN(cppcoreguidelines-pro-type-const-cast)
void onSessionWelcome(
const messages::Metadata &metadata,
const payload::session_welcome::Payload &payload) override
{
benchmark::DoNotOptimize(&metadata);
benchmark::DoNotOptimize(&payload);
}

void onNotification(const messages::Metadata &metadata,
const boost::json::value &jv) override
{
benchmark::DoNotOptimize(&metadata);
benchmark::DoNotOptimize(&jv);
}

void onChannelBan(const messages::Metadata &metadata,
const payload::channel_ban::v1::Payload &payload) override
{
benchmark::DoNotOptimize(&metadata);
benchmark::DoNotOptimize(&payload);
}

void onStreamOnline(
const messages::Metadata &metadata,
const payload::stream_online::v1::Payload &payload) override
{
benchmark::DoNotOptimize(&metadata);
benchmark::DoNotOptimize(&payload);
}

void onStreamOffline(
const messages::Metadata &metadata,
const payload::stream_offline::v1::Payload &payload) override
{
benchmark::DoNotOptimize(&metadata);
benchmark::DoNotOptimize(&payload);
}

void onChannelChatNotification(
const messages::Metadata &metadata,
const payload::channel_chat_notification::v1::Payload &payload) override
{
benchmark::DoNotOptimize(&metadata);
benchmark::DoNotOptimize(&payload);
}

void onChannelUpdate(
const messages::Metadata &metadata,
const payload::channel_update::v1::Payload &payload) override
{
benchmark::DoNotOptimize(&metadata);
benchmark::DoNotOptimize(&payload);
}

void onChannelChatMessage(
const messages::Metadata &metadata,
const payload::channel_chat_message::v1::Payload &payload) override
{
benchmark::DoNotOptimize(&metadata);
benchmark::DoNotOptimize(&payload);
}

void onChannelModerate(
const messages::Metadata &metadata,
const payload::channel_moderate::v2::Payload &payload) override
{
benchmark::DoNotOptimize(&metadata);
benchmark::DoNotOptimize(&payload);
}
// NOLINTEND(cppcoreguidelines-pro-type-const-cast)
};

void BM_ParseAndHandleMessages(benchmark::State &state)
{
auto messages = readMessages();

std::unique_ptr<Listener> listener = std::make_unique<NoopListener>();

for (auto _ : state)
{
for (const auto &msg : messages)
{
boost::system::error_code ec = handleMessage(listener, msg);
assert(!ec);
}
}
}

} // namespace

BENCHMARK(BM_ParseAndHandleMessages);
35 changes: 18 additions & 17 deletions lib/twitch-eventsub-ws/include/twitch-eventsub-ws/listener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,40 @@ class Listener
virtual ~Listener() = default;

virtual void onSessionWelcome(
messages::Metadata metadata,
payload::session_welcome::Payload payload) = 0;
const messages::Metadata &metadata,
const payload::session_welcome::Payload &payload) = 0;

virtual void onNotification(messages::Metadata metadata,
virtual void onNotification(const messages::Metadata &metadata,
const boost::json::value &jv) = 0;

// Subscription types
virtual void onChannelBan(messages::Metadata metadata,
payload::channel_ban::v1::Payload payload) = 0;
virtual void onChannelBan(
const messages::Metadata &metadata,
const payload::channel_ban::v1::Payload &payload) = 0;

virtual void onStreamOnline(
messages::Metadata metadata,
payload::stream_online::v1::Payload payload) = 0;
const messages::Metadata &metadata,
const payload::stream_online::v1::Payload &payload) = 0;

virtual void onStreamOffline(
messages::Metadata metadata,
payload::stream_offline::v1::Payload payload) = 0;
const messages::Metadata &metadata,
const payload::stream_offline::v1::Payload &payload) = 0;

virtual void onChannelChatNotification(
messages::Metadata metadata,
payload::channel_chat_notification::v1::Payload payload) = 0;
const messages::Metadata &metadata,
const payload::channel_chat_notification::v1::Payload &payload) = 0;

virtual void onChannelUpdate(
messages::Metadata metadata,
payload::channel_update::v1::Payload payload) = 0;
const messages::Metadata &metadata,
const payload::channel_update::v1::Payload &payload) = 0;

virtual void onChannelChatMessage(
messages::Metadata metadata,
payload::channel_chat_message::v1::Payload payload) = 0;
const messages::Metadata &metadata,
const payload::channel_chat_message::v1::Payload &payload) = 0;

virtual void onChannelModerate(
messages::Metadata metadata,
payload::channel_moderate::v2::Payload payload) = 0;
const messages::Metadata &metadata,
const payload::channel_moderate::v2::Payload &payload) = 0;

// Add your new subscription types above this line
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ namespace chatterino::eventsub::lib::messages {
*/

struct Metadata {
const std::string messageID;
const std::string messageType;
std::string messageID;
std::string messageType;
// TODO: should this be chronofied?
const std::string messageTimestamp;
std::string messageTimestamp;

const std::optional<std::string> subscriptionType;
const std::optional<std::string> subscriptionVersion;
std::optional<std::string> subscriptionType;
std::optional<std::string> subscriptionVersion;
};

#include "twitch-eventsub-ws/messages/metadata.inc"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ struct Event {
};

struct Payload {
const subscription::Subscription subscription;
subscription::Subscription subscription;

const Event event;
Event event;
};

#include "twitch-eventsub-ws/payloads/channel-ban-v1.inc"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ struct Event {
};

struct Payload {
const subscription::Subscription subscription;
subscription::Subscription subscription;

const Event event;
Event event;
};

#include "twitch-eventsub-ws/payloads/channel-chat-message-v1.inc"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ struct Resubscription {
int durationMonths;
std::optional<int> streakMonths;
std::string subTier;
bool isPrime;
std::optional<bool> isPrime;
bool isGift;
bool gifterIsAnonymous;
std::optional<bool> gifterIsAnonymous;
std::optional<std::string> gifterUserID;
std::optional<std::string> gifterUserName;
std::optional<std::string> gifterUserLogin;
Expand Down Expand Up @@ -162,9 +162,9 @@ struct Event {
std::string broadcasterUserID;
std::string broadcasterUserLogin;
std::string broadcasterUserName;
std::string chatterUserID;
std::string chatterUserLogin;
std::string chatterUserName;
std::optional<std::string> chatterUserID;
std::optional<std::string> chatterUserLogin;
std::optional<std::string> chatterUserName;
bool chatterIsAnonymous;
std::string color;
std::vector<Badge> badges;
Expand All @@ -190,9 +190,9 @@ struct Event {
};

struct Payload {
const subscription::Subscription subscription;
subscription::Subscription subscription;

const Event event;
Event event;
};

#include "twitch-eventsub-ws/payloads/channel-chat-notification-v1.inc"
Expand Down
Loading

0 comments on commit 9f34cad

Please sign in to comment.