Skip to content

Commit

Permalink
Merge branch 'master' into chatterino7
Browse files Browse the repository at this point in the history
Now we're on commit d6b5921; Changes from upstream we pulled:

- Major: Added username autocompletion popup menu when typing usernames with an @ prefix. (Chatterino#1979, Chatterino#2866)
- Minor: The /live split now shows channels going offline. (Chatterino#2880)
- Minor: Now shows deletions of messages like timeouts (Chatterino#1155, Chatterino#2841, Chatterino#2867, Chatterino#2874)
- Bugfix: Moderation buttons now show the correct time unit when using units other than seconds. (Chatterino#1719, Chatterino#2864)
- Bugfix: Fixed bit and new subscriber emotes not (re)loading in some rare cases. (Chatterino#2856, Chatterino#2857)
  • Loading branch information
zneix committed Jun 19, 2021
2 parents 68659eb + d6b5921 commit 6568208
Show file tree
Hide file tree
Showing 25 changed files with 493 additions and 209 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/build.yml
Expand Up @@ -81,7 +81,7 @@ jobs:
- name: Enable Developer Command Prompt
if: startsWith(matrix.os, 'windows')
uses: ilammy/msvc-dev-cmd@v1.8.1
uses: ilammy/msvc-dev-cmd@v1.9.0

- name: Build (Windows)
if: startsWith(matrix.os, 'windows') && matrix.build-system == 'qmake'
Expand Down Expand Up @@ -113,7 +113,7 @@ jobs:
- name: Upload artifact (Windows)
if: startsWith(matrix.os, 'windows')
uses: actions/upload-artifact@v2.2.3
uses: actions/upload-artifact@v2.2.4
with:
name: chatterino-windows-x86-64-${{ matrix.qt-version }}-${{ matrix.build-system }}.zip
path: build/chatterino-windows-x86-64.zip
Expand Down Expand Up @@ -170,7 +170,7 @@ jobs:

- name: Upload artifact (Ubuntu)
if: startsWith(matrix.os, 'ubuntu')
uses: actions/upload-artifact@v2.2.3
uses: actions/upload-artifact@v2.2.4
with:
name: Chatterino-x86_64-${{ matrix.qt-version }}-${{ matrix.build-system }}.AppImage
path: build/Chatterino-x86_64.AppImage
Expand Down Expand Up @@ -215,7 +215,7 @@ jobs:

- name: Upload artifact (MacOS)
if: startsWith(matrix.os, 'macos')
uses: actions/upload-artifact@v2.2.3
uses: actions/upload-artifact@v2.2.4
with:
name: chatterino-osx-${{ matrix.qt-version }}-${{ matrix.build-system }}.dmg
path: build/chatterino-osx.dmg
Expand All @@ -239,32 +239,32 @@ jobs:
Nightly Build
prerelease: true

- uses: actions/download-artifact@v2.0.9
- uses: actions/download-artifact@v2.0.10
with:
name: chatterino-windows-x86-64-5.15.2-qmake.zip
path: windows/

- uses: actions/download-artifact@v2.0.9
- uses: actions/download-artifact@v2.0.10
with:
name: chatterino-windows-x86-64-5.15.2-cmake.zip
path: windows-cmake/

- uses: actions/download-artifact@v2.0.9
- uses: actions/download-artifact@v2.0.10
with:
name: Chatterino-x86_64-5.15.2-qmake.AppImage
path: linux/

- uses: actions/download-artifact@v2.0.9
- uses: actions/download-artifact@v2.0.10
with:
name: Chatterino-x86_64-5.15.2-cmake.AppImage
path: linux-cmake/

- uses: actions/download-artifact@v2.0.9
- uses: actions/download-artifact@v2.0.10
with:
name: chatterino-osx-5.15.2-qmake.dmg
path: macos/

- uses: actions/download-artifact@v2.0.9
- uses: actions/download-artifact@v2.0.10
with:
name: chatterino-osx-5.15.2-cmake.dmg
path: macos-cmake/
Expand Down
7 changes: 5 additions & 2 deletions CHANGELOG.md
Expand Up @@ -2,7 +2,9 @@

## Unversioned

- Major: Added username autocompletion popup menu when typing usernames with an @ prefix. (#1979, #2866)
- Major: Added ability to toggle visibility of Channel Tabs - This can be done by right-clicking the tab area or pressing the keyboard shortcut (default: Ctrl+U). (#2600)
- Minor: The /live split now shows channels going offline. (#2880)
- Minor: Restore automod functionality for moderators (#2817, #2887)
- Minor: Add setting for username style (#2889, #2891)
- Minor: Searching for users in the viewer list now searches anywhere in the user's name. (#2861)
Expand All @@ -12,13 +14,14 @@
- Minor: Limit the number of recent chatters to improve memory usage and reduce freezes. (#2796, #2814)
- Minor: Added `/popout` command. Usage: `/popout [channel]`. It opens browser chat for the provided channel. Can also be used without arguments to open current channels browser chat. (#2556, #2812)
- Minor: Improved matching of game names when using `/setgame` command (#2636)
- Minor: Now shows deletions of messages like timeouts (#1155, #2841)
- Minor: Now shows deletions of messages like timeouts (#1155, #2841, #2867, #2874)
- Minor: Added a link to accounts page in settings to "You need to be logged in to send messages" message. (#2862)
- Minor: Switch to Twitch v2 emote API for animated emote support. (#2863)
- Bugfix: Moderation buttons now show the correct time unit when using units other than seconds. (#1719, #2864)
- Bugfix: Fixed FFZ emote links for global emotes (#2807, #2808)
- Bugfix: Fixed pasting text with URLs included (#1688, #2855)
- Bugfix: Fix reconnecting when IRC write connection is lost (#1831, #2356, #2850)
- Bugfix: Fixed bit emotes not loading in some rare cases. (#2856)
- Bugfix: Fixed bit and new subscriber emotes not (re)loading in some rare cases. (#2856, #2857)

## 2.3.2

Expand Down
8 changes: 4 additions & 4 deletions chatterino.pro
Expand Up @@ -320,8 +320,8 @@ SOURCES += \
src/widgets/settingspages/NotificationPage.cpp \
src/widgets/settingspages/SettingsPage.cpp \
src/widgets/splits/ClosedSplits.cpp \
src/widgets/splits/EmoteInputItem.cpp \
src/widgets/splits/EmoteInputPopup.cpp \
src/widgets/splits/InputCompletionItem.cpp \
src/widgets/splits/InputCompletionPopup.cpp \
src/widgets/splits/Split.cpp \
src/widgets/splits/SplitContainer.cpp \
src/widgets/splits/SplitHeader.cpp \
Expand Down Expand Up @@ -583,8 +583,8 @@ HEADERS += \
src/widgets/settingspages/NotificationPage.hpp \
src/widgets/settingspages/SettingsPage.hpp \
src/widgets/splits/ClosedSplits.hpp \
src/widgets/splits/EmoteInputItem.hpp \
src/widgets/splits/EmoteInputPopup.hpp \
src/widgets/splits/InputCompletionItem.hpp \
src/widgets/splits/InputCompletionPopup.hpp \
src/widgets/splits/Split.hpp \
src/widgets/splits/SplitContainer.hpp \
src/widgets/splits/SplitHeader.hpp \
Expand Down
41 changes: 41 additions & 0 deletions src/Application.cpp
Expand Up @@ -19,6 +19,7 @@
#include "providers/seventv/SeventvEmotes.hpp"
#include "providers/twitch/PubsubClient.hpp"
#include "providers/twitch/TwitchIrcServer.hpp"
#include "providers/twitch/TwitchMessageBuilder.hpp"
#include "singletons/Emotes.hpp"
#include "singletons/Fonts.hpp"
#include "singletons/Logging.hpp"
Expand Down Expand Up @@ -288,6 +289,46 @@ void Application::initPubsub()
chan->addOrReplaceTimeout(msg);
});
});
this->twitch.pubsub->signals_.moderation.messageDeleted.connect(
[&](const auto &action) {
auto chan =
this->twitch.server->getChannelOrEmptyByID(action.roomID);

if (chan->isEmpty())
{
return;
}

MessageBuilder msg;
TwitchMessageBuilder::deletionMessage(action, &msg);
msg->flags.set(MessageFlag::PubSub);

postToThread([chan, msg = msg.release()] {
auto replaced = false;
LimitedQueueSnapshot<MessagePtr> snapshot =
chan->getMessageSnapshot();
int snapshotLength = snapshot.size();

// without parens it doesn't build on windows
int end = (std::max)(0, snapshotLength - 200);

for (int i = snapshotLength - 1; i >= end; --i)
{
auto &s = snapshot[i];
if (!s->flags.has(MessageFlag::PubSub) &&
s->timeoutUser == msg->timeoutUser)
{
chan->replaceMessage(s, msg);
replaced = true;
break;
}
}
if (!replaced)
{
chan->addMessage(msg);
}
});
});

this->twitch.pubsub->signals_.moderation.userUnbanned.connect(
[&](const auto &action) {
Expand Down
8 changes: 4 additions & 4 deletions src/CMakeLists.txt
Expand Up @@ -440,10 +440,10 @@ set(SOURCE_FILES

widgets/splits/ClosedSplits.cpp
widgets/splits/ClosedSplits.hpp
widgets/splits/EmoteInputItem.cpp
widgets/splits/EmoteInputItem.hpp
widgets/splits/EmoteInputPopup.cpp
widgets/splits/EmoteInputPopup.hpp
widgets/splits/InputCompletionItem.cpp
widgets/splits/InputCompletionItem.hpp
widgets/splits/InputCompletionPopup.cpp
widgets/splits/InputCompletionPopup.hpp
widgets/splits/Split.cpp
widgets/splits/Split.hpp
widgets/splits/SplitContainer.cpp
Expand Down
44 changes: 36 additions & 8 deletions src/controllers/moderationactions/ModerationAction.cpp
Expand Up @@ -29,7 +29,7 @@ ModerationAction::ModerationAction(const QString &action)
: action_(action)
{
static QRegularExpression replaceRegex("[!/.]");
static QRegularExpression timeoutRegex("^[./]timeout.* (\\d+)");
static QRegularExpression timeoutRegex("^[./]timeout.* (\\d+)([mhdw]?)");

auto timeoutMatch = timeoutRegex.match(action);

Expand All @@ -39,28 +39,56 @@ ModerationAction::ModerationAction(const QString &action)
// QString line1;
// QString line2;

constexpr int minute = 60;
constexpr int hour = 60 * minute;
constexpr int day = 24 * hour;
constexpr int week = 7 * day;

int amount = timeoutMatch.captured(1).toInt();
QString unit = timeoutMatch.captured(2);

if (unit == "m")
{
amount *= minute;
}
else if (unit == "h")
{
amount *= hour;
}
else if (unit == "d")
{
amount *= day;
}
else if (unit == "w")
{
amount *= week;
}

if (amount < 60)
if (amount < minute)
{
this->line1_ = QString::number(amount);
this->line2_ = "s";
}
else if (amount < 60 * 60)
else if (amount < hour)
{
this->line1_ = QString::number(amount / 60);
this->line1_ = QString::number(amount / minute);
this->line2_ = "m";
}
else if (amount < 60 * 60 * 24)
else if (amount < day)
{
this->line1_ = QString::number(amount / 60 / 60);
this->line1_ = QString::number(amount / hour);
this->line2_ = "h";
}
else
else if (amount < week)
{
this->line1_ = QString::number(amount / 60 / 60 / 24);
this->line1_ = QString::number(amount / day);
this->line2_ = "d";
}
else
{
this->line1_ = QString::number(amount / week);
this->line2_ = "w";
}

// line1 = this->line1_;
// line2 = this->line2_;
Expand Down
17 changes: 11 additions & 6 deletions src/providers/twitch/IrcMessageHandler.cpp
Expand Up @@ -494,15 +494,24 @@ void IrcMessageHandler::handleClearMessageMessage(Communi::IrcMessage *message)

void IrcMessageHandler::handleUserStateMessage(Communi::IrcMessage *message)
{
auto app = getApp();
auto currentUser = getApp()->accounts->twitch.getCurrent();

// set received emote-sets, used in TwitchAccount::loadUserstateEmotes
bool emoteSetsChanged = currentUser->setUserstateEmoteSets(
message->tag("emote-sets").toString().split(","));

if (emoteSetsChanged)
{
currentUser->loadUserstateEmotes();
}

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

auto c = app->twitch.server->getChannelOrEmpty(channelName);
auto c = getApp()->twitch.server->getChannelOrEmpty(channelName);
if (c->isEmpty())
{
return;
Expand All @@ -529,10 +538,6 @@ void IrcMessageHandler::handleUserStateMessage(Communi::IrcMessage *message)
tc->setMod(_mod == "1");
}
}

// handle emotes
app->accounts->twitch.getCurrent()->loadUserstateEmotes(
message->tag("emote-sets").toString().split(","));
}

void IrcMessageHandler::handleWhisperMessage(Communi::IrcMessage *message)
Expand Down
9 changes: 9 additions & 0 deletions src/providers/twitch/PubsubActions.hpp
Expand Up @@ -75,6 +75,15 @@ struct BanAction : PubSubAction {
}
};

struct DeleteAction : PubSubAction {
using PubSubAction::PubSubAction;

ActionUser target;

QString messageId;
QString messageText;
};

struct UnbanAction : PubSubAction {
using PubSubAction::PubSubAction;

Expand Down
40 changes: 40 additions & 0 deletions src/providers/twitch/PubsubClient.cpp
Expand Up @@ -428,6 +428,46 @@ PubSub::PubSub()
}
};

this->moderationActionHandlers["delete"] = [this](const auto &data,
const auto &roomID) {
DeleteAction action(data, roomID);

getCreatedByUser(data, action.source);
getTargetUser(data, action.target);

try
{
const auto &args = getArgs(data);

if (args.Size() < 3)
{
return;
}

if (!rj::getSafe(args[0], action.target.name))
{
return;
}

if (!rj::getSafe(args[1], action.messageText))
{
return;
}

if (!rj::getSafe(args[2], action.messageId))
{
return;
}

this->signals_.moderation.messageDeleted.invoke(action);
}
catch (const std::runtime_error &ex)
{
qCDebug(chatterinoPubsub)
<< "Error parsing moderation action:" << ex.what();
}
};

this->moderationActionHandlers["ban"] = [this](const auto &data,
const auto &roomID) {
BanAction action(data, roomID);
Expand Down
1 change: 1 addition & 0 deletions src/providers/twitch/PubsubClient.hpp
Expand Up @@ -124,6 +124,7 @@ class PubSub
struct {
struct {
Signal<ClearChatAction> chatCleared;
Signal<DeleteAction> messageDeleted;
Signal<ModeChangedAction> modeChanged;
Signal<ModerationStateAction> moderationStateChanged;

Expand Down

0 comments on commit 6568208

Please sign in to comment.