Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/submodules/lib/expected-lite-88…
Browse files Browse the repository at this point in the history
…ee08e
  • Loading branch information
pajlada authored Oct 19, 2024
2 parents 4deaf49 + fb787b5 commit 9fe7872
Show file tree
Hide file tree
Showing 94 changed files with 3,532 additions and 32 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/test-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:

env:
TWITCH_PUBSUB_SERVER_TAG: v1.0.7
HTTPBOX_TAG: v0.2.1
QT_QPA_PLATFORM: minimal
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
Expand Down Expand Up @@ -58,6 +59,13 @@ jobs:
run: |
brew install boost openssl rapidjson p7zip create-dmg cmake
- name: Install httpbox
run: |
curl -L -o httpbox.tar.xz "/~https://github.com/Chatterino/httpbox/releases/download/${{ env.HTTPBOX_TAG }}/httpbox-x86_64-apple-darwin.tar.xz"
tar -xJf httpbox.tar.xz
mv ./httpbox-x86_64-apple-darwin/httpbox /usr/local/bin
working-directory: /tmp

- name: Build
run: |
mkdir build-test
Expand All @@ -83,10 +91,6 @@ jobs:
curl -L -o server.key "/~https://github.com/Chatterino/twitch-pubsub-server-test/raw/${{ env.TWITCH_PUBSUB_SERVER_TAG }}/cmd/server/server.key"
cd ..
- name: Cargo Install httpbox
run: |
cargo install --git /~https://github.com/kevinastone/httpbox --rev 89b971f
- name: Test
timeout-minutes: 30
run: |
Expand Down
14 changes: 9 additions & 5 deletions .github/workflows/test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:

env:
TWITCH_PUBSUB_SERVER_TAG: v1.0.7
HTTPBOX_TAG: v0.2.1
QT_QPA_PLATFORM: minimal
# Last known good conan version
# 2.0.3 has a bug on Windows (conan-io/conan#13606)
Expand Down Expand Up @@ -111,6 +112,13 @@ jobs:
mkdir -Force build-test/bin
cp "$((ls $Env:VCToolsRedistDir/onecore/x64 -Filter '*.CRT')[0].FullName)/*" build-test/bin
- name: Install httpbox
run: |
mkdir httpbox
Invoke-WebRequest -Uri "/~https://github.com/Chatterino/httpbox/releases/download/${{ env.HTTPBOX_TAG }}/httpbox-x86_64-pc-windows-msvc.zip" -outfile "httpbox.zip"
Expand-Archive httpbox.zip -DestinationPath httpbox
rm httpbox.zip
- name: Build
run: |
cmake `
Expand Down Expand Up @@ -139,14 +147,10 @@ jobs:
Invoke-WebRequest -Uri "/~https://github.com/Chatterino/twitch-pubsub-server-test/raw/${{ env.TWITCH_PUBSUB_SERVER_TAG }}/cmd/server/server.key" -outfile "server.key"
cd ..
- name: Cargo Install httpbox
run: |
cargo install --git /~https://github.com/kevinastone/httpbox --rev 89b971f
- name: Test
timeout-minutes: 30
run: |
httpbox --port 9051 &
..\httpbox\httpbox.exe --port 9051 &
cd ..\pubsub-server-test
.\server.exe 127.0.0.1:9050 &
cd ..\build-test
Expand Down
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- Major: Add option to show pronouns in user card. (#5442, #5583)
- Major: Release plugins alpha. (#5288)
- Major: Improve high-DPI support on Windows. (#4868, #5391)
- Major: Added transparent overlay window (default keybind: <kbd>CTRL</kbd> + <kbd>ALT</kbd> + <kbd>N</kbd>). (#4746, #5643)
- Major: Added transparent overlay window (default keybind: <kbd>CTRL</kbd> + <kbd>ALT</kbd> + <kbd>N</kbd>). (#4746, #5643, #5659)
- Minor: Removed the Ctrl+Shift+L hotkey for toggling the "live only" tab visibility state. (#5530)
- Minor: Add support for Shared Chat messages. Shared chat messages can be filtered with the `flags.shared` filter variable, or with search using `is:shared`. Some messages like subscriptions are filtered on purpose to avoid confusion for the broadcaster. If you have both channels participating in Shared Chat open, only one of the message triggering your highlight will trigger. (#5606, #5625)
- Minor: Moved tab visibility control to a submenu, without any toggle actions. (#5530)
Expand Down Expand Up @@ -36,6 +36,7 @@
- Minor: Added `--login <username>` CLI argument to specify which account to start logged in as. (#5626)
- Minor: Indicate when subscriptions and resubscriptions are for multiple months. (#5642)
- Minor: Proxy URL information is now included in the `/debug-env` command. (#5648)
- Minor: Make raid entry message usernames clickable. (#5651)
- Bugfix: Fixed tab move animation occasionally failing to start after closing a tab. (#5426, #5612)
- Bugfix: If a network request errors with 200 OK, Qt's error code is now reported instead of the HTTP status. (#5378)
- Bugfix: Fixed restricted users usernames not being clickable. (#5405)
Expand Down Expand Up @@ -103,7 +104,7 @@
- Dev: Added more tests for input completion. (#5604)
- Dev: Refactored legacy Unicode zero-width-joiner replacement. (#5594)
- Dev: The JSON output when copying a message (<kbd>SHIFT</kbd> + right-click) is now more extensive. (#5600)
- Dev: Added more tests for message building. (#5598)
- Dev: Added more tests for message building. (#5598, #5654, #5656)
- Dev: Twitch messages are now sent using Twitch's Helix API instead of IRC by default. (#5607)
- Dev: `GIFTimer` is no longer initialized in tests. (#5608)
- Dev: Emojis now use flags instead of a set of strings for capabilities. (#5616)
Expand Down
29 changes: 29 additions & 0 deletions src/messages/MessageBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,35 @@ MessageBuilder::MessageBuilder(SystemMessageTag, const QString &text,
this->message().searchText = text;
}

MessageBuilder::MessageBuilder(RaidEntryMessageTag, const QString &text,
const QString &loginName,
const QString &displayName,
const MessageColor &userColor, const QTime &time)
: MessageBuilder()
{
this->emplace<TimestampElement>(time);

const QStringList textFragments =
text.split(QRegularExpression("\\s"), Qt::SkipEmptyParts);
for (const auto &word : textFragments)
{
if (word == displayName)
{
this->emplace<MentionElement>(displayName, loginName,
MessageColor::System, userColor);
continue;
}

this->emplace<TextElement>(word, MessageElementFlag::Text,
MessageColor::System);
}

this->message().flags.set(MessageFlag::System);
this->message().flags.set(MessageFlag::DoNotTriggerNotification);
this->message().messageText = text;
this->message().searchText = text;
}

MessageBuilder::MessageBuilder(TimeoutMessageTag, const QString &timeoutUser,
const QString &sourceUser,
const QString &systemMessageText, int times,
Expand Down
6 changes: 6 additions & 0 deletions src/messages/MessageBuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ namespace linkparser {

struct SystemMessageTag {
};
struct RaidEntryMessageTag {
};
struct TimeoutMessageTag {
};
struct LiveUpdatesUpdateEmoteMessageTag {
Expand All @@ -67,6 +69,7 @@ struct ImageUploaderResultTag {
};

const SystemMessageTag systemMessage{};
const RaidEntryMessageTag raidEntryMessage{};
const TimeoutMessageTag timeoutMessage{};
const LiveUpdatesUpdateEmoteMessageTag liveUpdatesUpdateEmoteMessage{};
const LiveUpdatesRemoveEmoteMessageTag liveUpdatesRemoveEmoteMessage{};
Expand Down Expand Up @@ -109,6 +112,9 @@ class MessageBuilder

MessageBuilder(SystemMessageTag, const QString &text,
const QTime &time = QTime::currentTime());
MessageBuilder(RaidEntryMessageTag, const QString &text,
const QString &loginName, const QString &displayName,
const MessageColor &userColor, const QTime &time);
MessageBuilder(TimeoutMessageTag, const QString &timeoutUser,
const QString &sourceUser, const QString &systemMessageText,
int times, const QTime &time = QTime::currentTime());
Expand Down
78 changes: 77 additions & 1 deletion src/providers/twitch/IrcMessageHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,35 @@ std::vector<MessagePtr> parseUserNoticeMessage(Channel *channel,
{
messageText = "Announcement";
}
else if (msgType == "raid")
{
auto login = tags.value("login").toString();
auto displayName = tags.value("msg-param-displayName").toString();

if (!login.isEmpty() && !displayName.isEmpty())
{
MessageColor color = MessageColor::System;
if (auto colorTag = tags.value("color").value<QColor>();
colorTag.isValid())
{
color = MessageColor(colorTag);
}

auto b = MessageBuilder(
raidEntryMessage, parseTagString(messageText), login,
displayName, color, calculateMessageTime(message).time());

b->flags.set(MessageFlag::Subscription);
if (mirrored)
{
b->flags.set(MessageFlag::SharedMessage);
}

auto newMessage = b.release();
builtMessages.emplace_back(newMessage);
return builtMessages;
}
}
else if (msgType == "subgift")
{
if (auto monthsIt = tags.find("msg-param-gift-months");
Expand Down Expand Up @@ -600,12 +629,12 @@ std::vector<MessagePtr> parseUserNoticeMessage(Channel *channel,

auto b = MessageBuilder(systemMessage, parseTagString(messageText),
calculateMessageTime(message).time());

b->flags.set(MessageFlag::Subscription);
if (mirrored)
{
b->flags.set(MessageFlag::SharedMessage);
}

auto newMessage = b.release();
builtMessages.emplace_back(newMessage);
}
Expand Down Expand Up @@ -1085,6 +1114,53 @@ void IrcMessageHandler::handleUserNoticeMessage(Communi::IrcMessage *message,
{
messageText = "Announcement";
}
else if (msgType == "raid")
{
auto login = tags.value("login").toString();
auto displayName = tags.value("msg-param-displayName").toString();

if (!login.isEmpty() && !displayName.isEmpty())
{
MessageColor color = MessageColor::System;
if (auto colorTag = tags.value("color").value<QColor>();
colorTag.isValid())
{
color = MessageColor(colorTag);
}

auto b = MessageBuilder(
raidEntryMessage, parseTagString(messageText), login,
displayName, color, calculateMessageTime(message).time());

b->flags.set(MessageFlag::Subscription);
if (mirrored)
{
b->flags.set(MessageFlag::SharedMessage);
}
auto newMessage = b.release();

QString channelName;

if (message->parameters().size() < 1)
{
return;
}

if (!trimChannelName(message->parameter(0), channelName))
{
return;
}

auto chan = twitchServer.getChannelOrEmpty(channelName);

if (!chan->isEmpty())
{
chan->addMessage(newMessage, MessageContext::Original);
}

return;
}
}
else if (msgType == "subgift")
{
if (auto monthsIt = tags.find("msg-param-gift-months");
Expand Down
4 changes: 2 additions & 2 deletions src/providers/twitch/TwitchChannel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <optional>
#include <unordered_map>

class TestMessageBuilderP;
class TestIrcMessageHandlerP;

namespace chatterino {

Expand Down Expand Up @@ -464,7 +464,7 @@ class TwitchChannel final : public Channel, public ChannelChatters
friend class MessageBuilder;
friend class IrcMessageHandler;
friend class Commands_E2E_Test;
friend class ::TestMessageBuilderP;
friend class ::TestIrcMessageHandlerP;
};

} // namespace chatterino
1 change: 1 addition & 0 deletions src/singletons/helper/GifTimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ void GIFTimer::initialize()

QObject::connect(&this->timer, &QTimer::timeout, [this] {
if (getSettings()->animationsWhenFocused &&
this->openOverlayWindows_ == 0 &&
QApplication::activeWindow() == nullptr)
{
return;
Expand Down
12 changes: 12 additions & 0 deletions src/singletons/helper/GifTimer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,21 @@ class GIFTimer
return this->position_;
}

void registerOpenOverlayWindow()
{
this->openOverlayWindows_++;
}

void unregisterOpenOverlayWindow()
{
assert(this->openOverlayWindows_ >= 1);
this->openOverlayWindows_--;
}

private:
QTimer timer;
long unsigned position_{};
size_t openOverlayWindows_ = 0;
};

} // namespace chatterino
3 changes: 3 additions & 0 deletions src/widgets/OverlayWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "common/FlagsEnum.hpp"
#include "common/Literals.hpp"
#include "controllers/hotkeys/HotkeyController.hpp"
#include "singletons/Emotes.hpp"
#include "singletons/Settings.hpp"
#include "singletons/WindowManager.hpp"
#include "widgets/BaseWidget.hpp"
Expand Down Expand Up @@ -166,13 +167,15 @@ OverlayWindow::OverlayWindow(IndirectChannel channel,

this->addShortcuts();
this->triggerFirstActivation();
getApp()->getEmotes()->getGIFTimer().registerOpenOverlayWindow();
}

OverlayWindow::~OverlayWindow()
{
#ifdef Q_OS_WIN
::DestroyCursor(this->sizeAllCursor_);
#endif
getApp()->getEmotes()->getGIFTimer().unregisterOpenOverlayWindow();
}

void OverlayWindow::applyTheme()
Expand Down
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ set(test_SOURCES
${CMAKE_CURRENT_LIST_DIR}/src/UtilTwitch.cpp
${CMAKE_CURRENT_LIST_DIR}/src/IrcHelpers.cpp
${CMAKE_CURRENT_LIST_DIR}/src/TwitchPubSubClient.cpp
${CMAKE_CURRENT_LIST_DIR}/src/MessageBuilder.cpp
${CMAKE_CURRENT_LIST_DIR}/src/IrcMessageHandler.cpp
${CMAKE_CURRENT_LIST_DIR}/src/HighlightController.cpp
${CMAKE_CURRENT_LIST_DIR}/src/FormatTime.cpp
${CMAKE_CURRENT_LIST_DIR}/src/LimitedQueue.cpp
Expand Down
13 changes: 5 additions & 8 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
To run all tests you will need to run the `kennethreitz/httpbin` and `ghcr.io/chatterino/twitch-pubsub-server-test:latest` docker images.
# Pre-requisites to running tests

For example:
- Download & run [httpbox](/~https://github.com/Chatterino/httpbox/releases/latest)
`httpbox --port 9051`

```bash
docker run --network=host --detach ghcr.io/chatterino/twitch-pubsub-server-test:latest
docker run -p 9051:80 --detach kennethreitz/httpbin
```

If you're unable to use docker, you can use [httpbox](/~https://github.com/kevinastone/httpbox) (`httpbox --port 9051`) and [Chatterino/twitch-pubsub-server-test](/~https://github.com/Chatterino/twitch-pubsub-server-test/releases/latest) manually.
- Download & run [twitch-pubsub-server-test](/~https://github.com/Chatterino/twitch-pubsub-server-test/releases/latest)
`twitch-pubsub-server-test`
Loading

0 comments on commit 9fe7872

Please sign in to comment.