Compare commits

...

8 commits

Author SHA1 Message Date
James Upjohn 2552d7f5b7
Merge 2f631356b2 into 85d34c8ff0 2024-10-18 21:44:23 +02:00
pajlada 85d34c8ff0
test: use httpbox fork release (#5655) 2024-10-18 19:23:13 +00:00
James Upjohn 2f631356b2
chore: reformat all changed files to please the clang-tidy gods 2024-10-16 14:02:44 +13:00
James Upjohn f22f323bc0
doc: add changelog entry 2024-10-16 13:45:36 +13:00
James Upjohn 8ff61c4860
ref: use username colour from IRC tag instead of cache 2024-10-16 13:43:14 +13:00
James Upjohn fc12a3c630
ref: extract identical message builder emplacement logic to lambda 2024-10-16 13:26:23 +13:00
James Upjohn 8bfcd99be9
feat: pass off raid message to raid-specific message builder 2024-10-16 13:26:23 +13:00
James Upjohn 2cc492a26f
feat: create message builder for raid messages 2024-10-16 13:26:23 +13:00
7 changed files with 94 additions and 25 deletions

View file

@ -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
@ -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
@ -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: |

View file

@ -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)
@ -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 `
@ -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

View file

@ -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)

View file

@ -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,

View file

@ -53,6 +53,8 @@ namespace linkparser {
struct SystemMessageTag {
};
struct RaidEntryMessageTag {
};
struct TimeoutMessageTag {
};
struct LiveUpdatesUpdateEmoteMessageTag {
@ -67,6 +69,7 @@ struct ImageUploaderResultTag {
};
const SystemMessageTag systemMessage{};
const RaidEntryMessageTag raidEntryMessage{};
const TimeoutMessageTag timeoutMessage{};
const LiveUpdatesUpdateEmoteMessageTag liveUpdatesUpdateEmoteMessage{};
const LiveUpdatesRemoveEmoteMessageTag liveUpdatesRemoveEmoteMessage{};
@ -109,6 +112,9 @@ public:
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());

View file

@ -512,6 +512,18 @@ std::vector<MessagePtr> parseUserNoticeMessage(Channel *channel,
}
}
auto buildAndEmplaceMessage = [&builtMessages,
mirrored](MessageBuilder &builder) {
builder->flags.set(MessageFlag::Subscription);
if (mirrored)
{
builder->flags.set(MessageFlag::SharedMessage);
}
auto newMessage = builder.release();
builtMessages.emplace_back(newMessage);
};
auto it = tags.find("system-msg");
if (it != tags.end())
@ -531,6 +543,29 @@ std::vector<MessagePtr> parseUserNoticeMessage(Channel *channel,
{
messageText = "Announcement";
}
else if (msgType == "raid")
{
auto loginTag = tags.find("login");
auto displayNameTag = tags.find("msg-param-displayName");
if (loginTag != tags.end() && displayNameTag != tags.end())
{
auto login = loginTag.value().toString();
MessageColor color = MessageColor::System;
if (auto colorTag = tags.find("color"); colorTag != tags.end())
{
// Blindly trust that it's a valid hex code
color = MessageColor(QColor{colorTag.value().toString()});
}
auto displayName = displayNameTag.value().toString();
auto b = MessageBuilder(
raidEntryMessage, parseTagString(messageText), login,
displayName, color, calculateMessageTime(message).time());
buildAndEmplaceMessage(b);
return builtMessages;
}
}
else if (msgType == "subgift")
{
if (auto monthsIt = tags.find("msg-param-gift-months");
@ -600,14 +635,7 @@ 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);
buildAndEmplaceMessage(b);
}
return builtMessages;

View file

@ -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`