mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Compare commits
No commits in common. "35823a5bd9cb4e22c1e18cfb3390e0c5327c90c5" and "738cddeb6bab25df7c1b441aeead8a760d319880" have entirely different histories.
35823a5bd9
...
738cddeb6b
74 changed files with 1096 additions and 1811 deletions
4
.github/workflows/clang-tidy.yml
vendored
4
.github/workflows/clang-tidy.yml
vendored
|
@ -41,7 +41,7 @@ jobs:
|
|||
|
||||
- name: clang-tidy review
|
||||
timeout-minutes: 20
|
||||
uses: ZedThree/clang-tidy-review@v0.20.0
|
||||
uses: ZedThree/clang-tidy-review@v0.19.0
|
||||
with:
|
||||
build_dir: build-clang-tidy
|
||||
config_file: ".clang-tidy"
|
||||
|
@ -63,4 +63,4 @@ jobs:
|
|||
libxkbcommon-x11-0, libxcb-xkb-dev, libxcb-cursor0
|
||||
|
||||
- name: clang-tidy-review upload
|
||||
uses: ZedThree/clang-tidy-review/upload@v0.20.0
|
||||
uses: ZedThree/clang-tidy-review/upload@v0.19.0
|
||||
|
|
2
.github/workflows/post-clang-tidy-review.yml
vendored
2
.github/workflows/post-clang-tidy-review.yml
vendored
|
@ -14,7 +14,7 @@ jobs:
|
|||
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
||||
|
||||
steps:
|
||||
- uses: ZedThree/clang-tidy-review/post@v0.20.0
|
||||
- uses: ZedThree/clang-tidy-review/post@v0.19.0
|
||||
with:
|
||||
lgtm_comment_body: ""
|
||||
num_comments_as_exitcode: false
|
||||
|
|
1
.gitmodules
vendored
1
.gitmodules
vendored
|
@ -38,7 +38,6 @@
|
|||
[submodule "lib/lua/src"]
|
||||
path = lib/lua/src
|
||||
url = https://github.com/lua/lua
|
||||
branch = v5.4
|
||||
[submodule "tools/crash-handler"]
|
||||
path = tools/crash-handler
|
||||
url = https://github.com/Chatterino/crash-handler
|
||||
|
|
16
CHANGELOG.md
16
CHANGELOG.md
|
@ -34,14 +34,9 @@
|
|||
- Minor: Moderators can now see which mods start and cancel raids. (#5563)
|
||||
- Minor: The emote popup now reloads when Twitch emotes are reloaded. (#5580)
|
||||
- Minor: Added `--login <username>` CLI argument to specify which account to start logged in as. (#5626)
|
||||
- Minor: When blocking a channel, Chatterino will now warn you about that action. (#5615)
|
||||
- Minor: Indicate when subscriptions and resubscriptions are for multiple months. (#5642)
|
||||
- Minor: Added a setting to control whether or not to show "Blocked Term" automod messages. (#5690)
|
||||
- Minor: Proxy URL information is now included in the `/debug-env` command. (#5648)
|
||||
- Minor: Make raid entry message usernames clickable. (#5651)
|
||||
- Minor: Tabs unhighlight when their content is read in other tabs. (#5649)
|
||||
- Minor: Made usernames in bits and sub messages clickable. (#5686)
|
||||
- Minor: Mentions of FrankerFaceZ and BetterTTV in settings are standardized as such. (#5698)
|
||||
- Minor: Added support for the "Device code grant flow" for authentication. (#5680)
|
||||
- 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)
|
||||
|
@ -60,7 +55,6 @@
|
|||
- Bugfix: Fixed event emotes not showing up in autocomplete and popups. (#5239, #5580, #5582, #5632)
|
||||
- Bugfix: Fixed tab visibility being controllable in the emote popup. (#5530)
|
||||
- Bugfix: Fixed account switch not being saved if no other settings were changed. (#5558)
|
||||
- Bugfix: Fixed a crash that could occur when handling the quick switcher popup really quickly. (#5687)
|
||||
- Bugfix: Fixed 7TV badges being inadvertently animated. (#5674)
|
||||
- Bugfix: Fixed some tooltips not being readable. (#5578)
|
||||
- Bugfix: Fixed log files being locked longer than needed. (#5592)
|
||||
|
@ -70,8 +64,6 @@
|
|||
- Bugfix: Fixed double-click selection not working when clicking outside a message. (#5617)
|
||||
- Bugfix: Fixed emotes starting with ":" not tab-completing. (#5603)
|
||||
- Bugfix: Fixed 7TV emotes messing with Qt's HTML. (#5677)
|
||||
- Bugfix: Fixed incorrect messages getting replaced visually. (#5683)
|
||||
- Bugfix: Fixed rendering of multi-line selection that starts at a trailing space. (#5691)
|
||||
- Dev: Update Windows build from Qt 6.5.0 to Qt 6.7.1. (#5420)
|
||||
- Dev: Update vcpkg build Qt from 6.5.0 to 6.7.0, boost from 1.83.0 to 1.85.0, openssl from 3.1.3 to 3.3.0. (#5422)
|
||||
- Dev: Unsingletonize `ISoundController`. (#5462)
|
||||
|
@ -84,7 +76,7 @@
|
|||
- Dev: Removed unused timegate settings. (#5361)
|
||||
- Dev: Add `Channel::addSystemMessage` helper function, allowing us to avoid the common `channel->addMessage(makeSystemMessage(...));` pattern. (#5500)
|
||||
- Dev: Unsingletonize `Resources2`. (#5460)
|
||||
- Dev: All Lua globals now show in the `c2` global in the LuaLS metadata. (#5385, #5682)
|
||||
- Dev: All Lua globals now show in the `c2` global in the LuaLS metadata. (#5385)
|
||||
- Dev: Images are now loaded in worker threads. (#5431)
|
||||
- Dev: Fixed broken `SignalVector::operator[]` implementation. (#5556)
|
||||
- Dev: Qt Creator now auto-configures Conan when loading the project and skips vcpkg. (#5305)
|
||||
|
@ -119,15 +111,11 @@
|
|||
- 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)
|
||||
- Dev: Move plugins to Sol2. (#5622, #5682)
|
||||
- Dev: Clarified our Lua dependency's version. (#5693)
|
||||
- Dev: Specified qtkeychain dependency version. (#5695, #5697)
|
||||
- Dev: Move plugins to Sol2. (#5622)
|
||||
- Dev: Refactored static `MessageBuilder` helpers to standalone functions. (#5652)
|
||||
- Dev: Decoupled reply parsing from `MessageBuilder`. (#5660, #5668)
|
||||
- Dev: Refactored IRC message building. (#5663)
|
||||
- Dev: Fixed some compiler warnings. (#5672)
|
||||
- Dev: Unified parsing of historic and live IRC messages. (#5678)
|
||||
- Dev: 7TV's `entitlement.reset` is now explicitly ignored. (#5685)
|
||||
|
||||
## 2.5.1
|
||||
|
||||
|
|
|
@ -160,19 +160,10 @@ if (BUILD_WITH_QTKEYCHAIN)
|
|||
message(FATAL_ERROR "Submodules probably not loaded, unable to find lib/qtkeychain/CMakeLists.txt")
|
||||
endif()
|
||||
|
||||
set(_prev_testing ${BUILD_TESTING})
|
||||
set(BUILD_TESTING Off)
|
||||
add_subdirectory("${QTKEYCHAIN_ROOT_LIB_FOLDER}" EXCLUDE_FROM_ALL)
|
||||
set(BUILD_TESTING ${_prev_testing})
|
||||
|
||||
if (NOT TARGET qt${MAJOR_QT_VERSION}keychain)
|
||||
message(FATAL_ERROR "qt${MAJOR_QT_VERSION}keychain target was not created :@")
|
||||
endif()
|
||||
if (MSVC AND "${MAJOR_QT_VERSION}" STREQUAL "5")
|
||||
target_compile_definitions(qt5keychain PRIVATE UNICODE)
|
||||
target_compile_options(qt5keychain PRIVATE /utf-8)
|
||||
set_target_properties(qt5keychain PROPERTIES CXX_STANDARD 17)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
|
@ -5,20 +5,20 @@
|
|||
-- Add the folder this file is in to "Lua.workspace.library".
|
||||
|
||||
c2 = {}
|
||||
---@enum c2.LogLevel
|
||||
c2.LogLevel = {
|
||||
Debug = {}, ---@type c2.LogLevel.Debug
|
||||
Info = {}, ---@type c2.LogLevel.Info
|
||||
Warning = {}, ---@type c2.LogLevel.Warning
|
||||
Critical = {}, ---@type c2.LogLevel.Critical
|
||||
}
|
||||
---@alias c2.LogLevel.Debug "c2.LogLevel.Debug"
|
||||
---@alias c2.LogLevel.Info "c2.LogLevel.Info"
|
||||
---@alias c2.LogLevel.Warning "c2.LogLevel.Warning"
|
||||
---@alias c2.LogLevel.Critical "c2.LogLevel.Critical"
|
||||
---@alias c2.LogLevel c2.LogLevel.Debug|c2.LogLevel.Info|c2.LogLevel.Warning|c2.LogLevel.Critical
|
||||
---@type { Debug: c2.LogLevel.Debug, Info: c2.LogLevel.Info, Warning: c2.LogLevel.Warning, Critical: c2.LogLevel.Critical }
|
||||
c2.LogLevel = {}
|
||||
|
||||
-- Begin src/controllers/plugins/api/EventType.hpp
|
||||
|
||||
---@enum c2.EventType
|
||||
c2.EventType = {
|
||||
CompletionRequested = {}, ---@type c2.EventType.CompletionRequested
|
||||
}
|
||||
---@alias c2.EventType.CompletionRequested "c2.EventType.CompletionRequested"
|
||||
---@alias c2.EventType c2.EventType.CompletionRequested
|
||||
---@type { CompletionRequested: c2.EventType.CompletionRequested }
|
||||
c2.EventType = {}
|
||||
|
||||
-- End src/controllers/plugins/api/EventType.hpp
|
||||
|
||||
|
@ -38,19 +38,19 @@ c2.EventType = {
|
|||
|
||||
-- Begin src/common/Channel.hpp
|
||||
|
||||
---@enum c2.ChannelType
|
||||
c2.ChannelType = {
|
||||
None = {}, ---@type c2.ChannelType.None
|
||||
Direct = {}, ---@type c2.ChannelType.Direct
|
||||
Twitch = {}, ---@type c2.ChannelType.Twitch
|
||||
TwitchWhispers = {}, ---@type c2.ChannelType.TwitchWhispers
|
||||
TwitchWatching = {}, ---@type c2.ChannelType.TwitchWatching
|
||||
TwitchMentions = {}, ---@type c2.ChannelType.TwitchMentions
|
||||
TwitchLive = {}, ---@type c2.ChannelType.TwitchLive
|
||||
TwitchAutomod = {}, ---@type c2.ChannelType.TwitchAutomod
|
||||
TwitchEnd = {}, ---@type c2.ChannelType.TwitchEnd
|
||||
Misc = {}, ---@type c2.ChannelType.Misc
|
||||
}
|
||||
---@alias c2.ChannelType.None "c2.ChannelType.None"
|
||||
---@alias c2.ChannelType.Direct "c2.ChannelType.Direct"
|
||||
---@alias c2.ChannelType.Twitch "c2.ChannelType.Twitch"
|
||||
---@alias c2.ChannelType.TwitchWhispers "c2.ChannelType.TwitchWhispers"
|
||||
---@alias c2.ChannelType.TwitchWatching "c2.ChannelType.TwitchWatching"
|
||||
---@alias c2.ChannelType.TwitchMentions "c2.ChannelType.TwitchMentions"
|
||||
---@alias c2.ChannelType.TwitchLive "c2.ChannelType.TwitchLive"
|
||||
---@alias c2.ChannelType.TwitchAutomod "c2.ChannelType.TwitchAutomod"
|
||||
---@alias c2.ChannelType.TwitchEnd "c2.ChannelType.TwitchEnd"
|
||||
---@alias c2.ChannelType.Misc "c2.ChannelType.Misc"
|
||||
---@alias c2.ChannelType c2.ChannelType.None|c2.ChannelType.Direct|c2.ChannelType.Twitch|c2.ChannelType.TwitchWhispers|c2.ChannelType.TwitchWatching|c2.ChannelType.TwitchMentions|c2.ChannelType.TwitchLive|c2.ChannelType.TwitchAutomod|c2.ChannelType.TwitchEnd|c2.ChannelType.Misc
|
||||
---@type { None: c2.ChannelType.None, Direct: c2.ChannelType.Direct, Twitch: c2.ChannelType.Twitch, TwitchWhispers: c2.ChannelType.TwitchWhispers, TwitchWatching: c2.ChannelType.TwitchWatching, TwitchMentions: c2.ChannelType.TwitchMentions, TwitchLive: c2.ChannelType.TwitchLive, TwitchAutomod: c2.ChannelType.TwitchAutomod, TwitchEnd: c2.ChannelType.TwitchEnd, Misc: c2.ChannelType.Misc }
|
||||
c2.ChannelType = {}
|
||||
|
||||
-- End src/common/Channel.hpp
|
||||
|
||||
|
@ -174,97 +174,90 @@ function c2.Channel.by_twitch_id(id) end
|
|||
|
||||
-- Begin src/controllers/plugins/api/HTTPResponse.hpp
|
||||
|
||||
---@class c2.HTTPResponse
|
||||
c2.HTTPResponse = {}
|
||||
---@class HTTPResponse
|
||||
HTTPResponse = {}
|
||||
|
||||
--- Returns the data. This is not guaranteed to be encoded using any
|
||||
--- particular encoding scheme. It's just the bytes the server returned.
|
||||
---
|
||||
---@return string
|
||||
---@nodiscard
|
||||
function c2.HTTPResponse:data() end
|
||||
function HTTPResponse:data() end
|
||||
|
||||
--- Returns the status code.
|
||||
---
|
||||
---@return number|nil
|
||||
---@nodiscard
|
||||
function c2.HTTPResponse:status() end
|
||||
function HTTPResponse:status() end
|
||||
|
||||
--- A somewhat human readable description of an error if such happened
|
||||
---
|
||||
---@return string
|
||||
---@nodiscard
|
||||
function c2.HTTPResponse:error() end
|
||||
function HTTPResponse:error() end
|
||||
|
||||
---@return string
|
||||
---@nodiscard
|
||||
function c2.HTTPResponse:__tostring() end
|
||||
function HTTPResponse:__tostring() end
|
||||
|
||||
-- End src/controllers/plugins/api/HTTPResponse.hpp
|
||||
|
||||
-- Begin src/controllers/plugins/api/HTTPRequest.hpp
|
||||
|
||||
---@alias c2.HTTPCallback fun(result: c2.HTTPResponse): nil
|
||||
---@class c2.HTTPRequest
|
||||
c2.HTTPRequest = {}
|
||||
---@alias HTTPCallback fun(result: HTTPResponse): nil
|
||||
---@class HTTPRequest
|
||||
HTTPRequest = {}
|
||||
|
||||
--- Sets the success callback
|
||||
---
|
||||
---@param callback c2.HTTPCallback Function to call when the HTTP request succeeds
|
||||
function c2.HTTPRequest:on_success(callback) end
|
||||
---@param callback HTTPCallback Function to call when the HTTP request succeeds
|
||||
function HTTPRequest:on_success(callback) end
|
||||
|
||||
--- Sets the failure callback
|
||||
---
|
||||
---@param callback c2.HTTPCallback Function to call when the HTTP request fails or returns a non-ok status
|
||||
function c2.HTTPRequest:on_error(callback) end
|
||||
---@param callback HTTPCallback Function to call when the HTTP request fails or returns a non-ok status
|
||||
function HTTPRequest:on_error(callback) end
|
||||
|
||||
--- Sets the finally callback
|
||||
---
|
||||
---@param callback fun(): nil Function to call when the HTTP request finishes
|
||||
function c2.HTTPRequest:finally(callback) end
|
||||
function HTTPRequest:finally(callback) end
|
||||
|
||||
--- Sets the timeout
|
||||
---
|
||||
---@param timeout integer How long in milliseconds until the times out
|
||||
function c2.HTTPRequest:set_timeout(timeout) end
|
||||
function HTTPRequest:set_timeout(timeout) end
|
||||
|
||||
--- Sets the request payload
|
||||
---
|
||||
---@param data string
|
||||
function c2.HTTPRequest:set_payload(data) end
|
||||
function HTTPRequest:set_payload(data) end
|
||||
|
||||
--- Sets a header in the request
|
||||
---
|
||||
---@param name string
|
||||
---@param value string
|
||||
function c2.HTTPRequest:set_header(name, value) end
|
||||
function HTTPRequest:set_header(name, value) end
|
||||
|
||||
--- Executes the HTTP request
|
||||
---
|
||||
function c2.HTTPRequest:execute() end
|
||||
function HTTPRequest:execute() end
|
||||
|
||||
---@return string
|
||||
function c2.HTTPRequest:__tostring() end
|
||||
function HTTPRequest:__tostring() end
|
||||
|
||||
--- Creates a new HTTPRequest
|
||||
---
|
||||
---@param method c2.HTTPMethod Method to use
|
||||
---@param method HTTPMethod Method to use
|
||||
---@param url string Where to send the request to
|
||||
---@return c2.HTTPRequest
|
||||
function c2.HTTPRequest.create(method, url) end
|
||||
---@return HTTPRequest
|
||||
function HTTPRequest.create(method, url) end
|
||||
|
||||
-- End src/controllers/plugins/api/HTTPRequest.hpp
|
||||
|
||||
-- Begin src/common/network/NetworkCommon.hpp
|
||||
|
||||
---@enum c2.HTTPMethod
|
||||
c2.HTTPMethod = {
|
||||
Get = {}, ---@type c2.HTTPMethod.Get
|
||||
Post = {}, ---@type c2.HTTPMethod.Post
|
||||
Put = {}, ---@type c2.HTTPMethod.Put
|
||||
Delete = {}, ---@type c2.HTTPMethod.Delete
|
||||
Patch = {}, ---@type c2.HTTPMethod.Patch
|
||||
}
|
||||
---@alias HTTPMethod.Get "HTTPMethod.Get"
|
||||
---@alias HTTPMethod.Post "HTTPMethod.Post"
|
||||
---@alias HTTPMethod.Put "HTTPMethod.Put"
|
||||
---@alias HTTPMethod.Delete "HTTPMethod.Delete"
|
||||
---@alias HTTPMethod.Patch "HTTPMethod.Patch"
|
||||
---@alias HTTPMethod HTTPMethod.Get|HTTPMethod.Post|HTTPMethod.Put|HTTPMethod.Delete|HTTPMethod.Patch
|
||||
---@type { Get: HTTPMethod.Get, Post: HTTPMethod.Post, Put: HTTPMethod.Put, Delete: HTTPMethod.Delete, Patch: HTTPMethod.Patch }
|
||||
HTTPMethod = {}
|
||||
|
||||
-- End src/common/network/NetworkCommon.hpp
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 73c3772d6432280df83e1ab3299c2a8f1e4ea47f
|
||||
Subproject commit e5b070831cf1ea3cb98c95f97fcb7439f8d79bd6
|
|
@ -422,7 +422,7 @@ public:
|
|||
// get followed channel
|
||||
MOCK_METHOD(
|
||||
void, getFollowedChannel,
|
||||
(QString userID, QString broadcasterID, const QObject *caller,
|
||||
(QString userID, QString broadcasterID,
|
||||
ResultCallback<std::optional<HelixFollowedChannel>> successCallback,
|
||||
FailureCallback<QString> failureCallback),
|
||||
(override));
|
||||
|
|
23
scripts/make_luals_meta.py
Executable file → Normal file
23
scripts/make_luals_meta.py
Executable file → Normal file
|
@ -1,4 +1,3 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
This script generates docs/plugin-meta.lua. It accepts no arguments
|
||||
|
||||
|
@ -243,19 +242,25 @@ def read_file(path: Path, out: TextIOWrapper):
|
|||
)
|
||||
name = header[0].split(" ", 1)[1]
|
||||
printmsg(path, reader.line_no(), f"enum {name}")
|
||||
variants = reader.read_enum_variants()
|
||||
|
||||
vtypes = []
|
||||
for variant in variants:
|
||||
vtype = f'{name}.{variant}'
|
||||
vtypes.append(vtype)
|
||||
out.write(f'---@alias {vtype} "{vtype}"\n')
|
||||
|
||||
out.write(f"---@alias {name} {'|'.join(vtypes)}\n")
|
||||
if header_comment:
|
||||
out.write(f"--- {header_comment}\n")
|
||||
out.write(f"---@enum {name}\n")
|
||||
out.write(f"{name} = {{\n")
|
||||
out.write("---@type { ")
|
||||
out.write(
|
||||
"\n".join(
|
||||
[
|
||||
f" {variant} = {{}}, ---@type {name}.{variant}"
|
||||
for variant in reader.read_enum_variants()
|
||||
]
|
||||
", ".join(
|
||||
[f"{variant}: {typ}" for variant, typ in zip(variants,vtypes)]
|
||||
)
|
||||
)
|
||||
out.write("\n}\n\n")
|
||||
out.write(" }\n")
|
||||
out.write(f"{name} = {{}}\n\n")
|
||||
continue
|
||||
|
||||
# class
|
||||
|
|
|
@ -40,7 +40,6 @@ set(SOURCE_FILES
|
|||
common/WindowDescriptors.cpp
|
||||
common/WindowDescriptors.hpp
|
||||
|
||||
common/enums/MessageContext.hpp
|
||||
common/enums/MessageOverflow.hpp
|
||||
|
||||
common/network/NetworkCommon.cpp
|
||||
|
@ -283,9 +282,6 @@ set(SOURCE_FILES
|
|||
messages/MessageElement.cpp
|
||||
messages/MessageElement.hpp
|
||||
messages/MessageFlag.hpp
|
||||
messages/MessageSimilarity.cpp
|
||||
messages/MessageSimilarity.hpp
|
||||
messages/MessageSink.hpp
|
||||
messages/MessageThread.cpp
|
||||
messages/MessageThread.hpp
|
||||
|
||||
|
@ -531,8 +527,6 @@ set(SOURCE_FILES
|
|||
util/Twitch.hpp
|
||||
util/TypeName.hpp
|
||||
util/Variant.hpp
|
||||
util/VectorMessageSink.cpp
|
||||
util/VectorMessageSink.hpp
|
||||
util/WidgetHelpers.cpp
|
||||
util/WidgetHelpers.hpp
|
||||
util/WindowsHelper.cpp
|
||||
|
|
|
@ -3,9 +3,7 @@
|
|||
#include "Application.hpp"
|
||||
#include "messages/Message.hpp"
|
||||
#include "messages/MessageBuilder.hpp"
|
||||
#include "messages/MessageSimilarity.hpp"
|
||||
#include "providers/twitch/IrcMessageHandler.hpp"
|
||||
#include "providers/twitch/TwitchIrcServer.hpp"
|
||||
#include "singletons/Emotes.hpp"
|
||||
#include "singletons/Logging.hpp"
|
||||
#include "singletons/Settings.hpp"
|
||||
|
@ -123,10 +121,10 @@ void Channel::addSystemMessage(const QString &contents)
|
|||
this->addMessage(msg, MessageContext::Original);
|
||||
}
|
||||
|
||||
void Channel::addOrReplaceTimeout(MessagePtr message, QTime now)
|
||||
void Channel::addOrReplaceTimeout(MessagePtr message)
|
||||
{
|
||||
addOrReplaceChannelTimeout(
|
||||
this->getMessageSnapshot(), std::move(message), now,
|
||||
this->getMessageSnapshot(), std::move(message), QTime::currentTime(),
|
||||
[this](auto /*idx*/, auto msg, auto replacement) {
|
||||
this->replaceMessage(msg, replacement);
|
||||
},
|
||||
|
@ -255,33 +253,21 @@ void Channel::fillInMissingMessages(const std::vector<MessagePtr> &messages)
|
|||
}
|
||||
}
|
||||
|
||||
void Channel::replaceMessage(const MessagePtr &message,
|
||||
const MessagePtr &replacement)
|
||||
void Channel::replaceMessage(MessagePtr message, MessagePtr replacement)
|
||||
{
|
||||
int index = this->messages_.replaceItem(message, replacement);
|
||||
|
||||
if (index >= 0)
|
||||
{
|
||||
this->messageReplaced.invoke((size_t)index, message, replacement);
|
||||
this->messageReplaced.invoke((size_t)index, replacement);
|
||||
}
|
||||
}
|
||||
|
||||
void Channel::replaceMessage(size_t index, const MessagePtr &replacement)
|
||||
void Channel::replaceMessage(size_t index, MessagePtr replacement)
|
||||
{
|
||||
MessagePtr prev;
|
||||
if (this->messages_.replaceItem(index, replacement, &prev))
|
||||
if (this->messages_.replaceItem(index, replacement))
|
||||
{
|
||||
this->messageReplaced.invoke(index, prev, replacement);
|
||||
}
|
||||
}
|
||||
|
||||
void Channel::replaceMessage(size_t hint, const MessagePtr &message,
|
||||
const MessagePtr &replacement)
|
||||
{
|
||||
auto index = this->messages_.replaceItem(hint, message, replacement);
|
||||
if (index >= 0)
|
||||
{
|
||||
this->messageReplaced.invoke(hint, message, replacement);
|
||||
this->messageReplaced.invoke(index, replacement);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -301,15 +287,10 @@ void Channel::clearMessages()
|
|||
}
|
||||
|
||||
MessagePtr Channel::findMessage(QString messageID)
|
||||
{
|
||||
return this->findMessageByID(messageID);
|
||||
}
|
||||
|
||||
MessagePtr Channel::findMessageByID(QStringView messageID)
|
||||
{
|
||||
MessagePtr res;
|
||||
|
||||
if (auto msg = this->messages_.rfind([messageID](const MessagePtr &msg) {
|
||||
if (auto msg = this->messages_.rfind([&messageID](const MessagePtr &msg) {
|
||||
return msg->id == messageID;
|
||||
});
|
||||
msg)
|
||||
|
@ -320,19 +301,6 @@ MessagePtr Channel::findMessageByID(QStringView messageID)
|
|||
return res;
|
||||
}
|
||||
|
||||
void Channel::applySimilarityFilters(const MessagePtr &message) const
|
||||
{
|
||||
setSimilarityFlags(message, this->messages_.getSnapshot());
|
||||
}
|
||||
|
||||
MessageSinkTraits Channel::sinkTraits() const
|
||||
{
|
||||
return {
|
||||
MessageSinkTrait::AddMentionsToGlobalChannel,
|
||||
MessageSinkTrait::RequiresKnownChannelPointReward,
|
||||
};
|
||||
}
|
||||
|
||||
bool Channel::canSendMessage() const
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include "common/enums/MessageContext.hpp"
|
||||
#include "controllers/completion/TabCompletionModel.hpp"
|
||||
#include "messages/LimitedQueue.hpp"
|
||||
#include "messages/MessageFlag.hpp"
|
||||
#include "messages/MessageSink.hpp"
|
||||
|
||||
#include <magic_enum/magic_enum.hpp>
|
||||
#include <pajlada/signals/signal.hpp>
|
||||
|
@ -28,7 +26,15 @@ enum class TimeoutStackStyle : int {
|
|||
Default = DontStackBeyondUserMessage,
|
||||
};
|
||||
|
||||
class Channel : public std::enable_shared_from_this<Channel>, public MessageSink
|
||||
/// Context of the message being added to a channel
|
||||
enum class MessageContext {
|
||||
/// This message is the original
|
||||
Original,
|
||||
/// This message is a repost of a message that has already been added in a channel
|
||||
Repost,
|
||||
};
|
||||
|
||||
class Channel : public std::enable_shared_from_this<Channel>
|
||||
{
|
||||
public:
|
||||
// This is for Lua. See scripts/make_luals_meta.py
|
||||
|
@ -49,7 +55,7 @@ public:
|
|||
};
|
||||
|
||||
explicit Channel(const QString &name, Type type);
|
||||
~Channel() override;
|
||||
virtual ~Channel();
|
||||
|
||||
// SIGNALS
|
||||
pajlada::Signals::Signal<const QString &, const QString &, bool &>
|
||||
|
@ -60,9 +66,7 @@ public:
|
|||
pajlada::Signals::Signal<MessagePtr &, std::optional<MessageFlags>>
|
||||
messageAppended;
|
||||
pajlada::Signals::Signal<std::vector<MessagePtr> &> messagesAddedAtStart;
|
||||
/// (index, prev-message, replacement)
|
||||
pajlada::Signals::Signal<size_t, const MessagePtr &, const MessagePtr &>
|
||||
messageReplaced;
|
||||
pajlada::Signals::Signal<size_t, MessagePtr &> messageReplaced;
|
||||
/// Invoked when some number of messages were filled in using time received
|
||||
pajlada::Signals::Signal<const std::vector<MessagePtr> &> filledInMessages;
|
||||
pajlada::Signals::NoArgSignal destroyed;
|
||||
|
@ -81,9 +85,8 @@ public:
|
|||
// overridingFlags can be filled in with flags that should be used instead
|
||||
// of the message's flags. This is useful in case a flag is specific to a
|
||||
// type of split
|
||||
void addMessage(
|
||||
MessagePtr message, MessageContext context,
|
||||
std::optional<MessageFlags> overridingFlags = std::nullopt) final;
|
||||
void addMessage(MessagePtr message, MessageContext context,
|
||||
std::optional<MessageFlags> overridingFlags = std::nullopt);
|
||||
void addMessagesAtStart(const std::vector<MessagePtr> &messages_);
|
||||
|
||||
void addSystemMessage(const QString &contents);
|
||||
|
@ -91,28 +94,19 @@ public:
|
|||
/// Inserts the given messages in order by Message::serverReceivedTime.
|
||||
void fillInMissingMessages(const std::vector<MessagePtr> &messages);
|
||||
|
||||
void addOrReplaceTimeout(MessagePtr message, QTime now) final;
|
||||
void disableAllMessages() final;
|
||||
void replaceMessage(const MessagePtr &message,
|
||||
const MessagePtr &replacement);
|
||||
void replaceMessage(size_t index, const MessagePtr &replacement);
|
||||
void replaceMessage(size_t hint, const MessagePtr &message,
|
||||
const MessagePtr &replacement);
|
||||
void addOrReplaceTimeout(MessagePtr message);
|
||||
void disableAllMessages();
|
||||
void replaceMessage(MessagePtr message, MessagePtr replacement);
|
||||
void replaceMessage(size_t index, MessagePtr replacement);
|
||||
void deleteMessage(QString messageID);
|
||||
|
||||
/// Removes all messages from this channel and invokes #messagesCleared
|
||||
void clearMessages();
|
||||
|
||||
[[deprecated("Use findMessageByID instead")]] MessagePtr findMessage(
|
||||
QString messageID);
|
||||
MessagePtr findMessageByID(QStringView messageID) final;
|
||||
MessagePtr findMessage(QString messageID);
|
||||
|
||||
bool hasMessages() const;
|
||||
|
||||
void applySimilarityFilters(const MessagePtr &message) const final;
|
||||
|
||||
MessageSinkTraits sinkTraits() const final;
|
||||
|
||||
// CHANNEL INFO
|
||||
virtual bool canSendMessage() const;
|
||||
virtual bool isWritable() const; // whether split input will be usable
|
||||
|
|
|
@ -6,10 +6,6 @@
|
|||
#include <QSize>
|
||||
#include <QString>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
void _registerSetting(std::weak_ptr<pajlada::Settings::SettingData> setting);
|
||||
|
@ -166,9 +162,6 @@ struct IsChatterinoSettingT : std::false_type {
|
|||
template <typename T>
|
||||
struct IsChatterinoSettingT<ChatterinoSetting<T>> : std::true_type {
|
||||
};
|
||||
template <typename T>
|
||||
struct IsChatterinoSettingT<EnumStringSetting<T>> : std::true_type {
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
concept IsChatterinoSetting = IsChatterinoSettingT<T>::value;
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
# include "qt5keychain/keychain.h"
|
||||
# endif
|
||||
# else
|
||||
# include <qtkeychain/keychain.h>
|
||||
# include "keychain.h"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
/// Context of the message being added to a channel
|
||||
enum class MessageContext {
|
||||
/// This message is the original
|
||||
Original,
|
||||
/// This message is a repost of a message that has already been added in a channel
|
||||
Repost,
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
|
@ -16,7 +16,7 @@ using NetworkErrorCallback = std::function<void(NetworkResult)>;
|
|||
using NetworkFinallyCallback = std::function<void()>;
|
||||
|
||||
/**
|
||||
* @exposeenum c2.HTTPMethod
|
||||
* @exposeenum HTTPMethod
|
||||
*/
|
||||
enum class NetworkRequestType {
|
||||
Get,
|
||||
|
|
|
@ -16,11 +16,11 @@ namespace chatterino::lua::api {
|
|||
// NOLINTBEGIN(readability-identifier-naming)
|
||||
|
||||
/**
|
||||
* @lua@alias c2.HTTPCallback fun(result: c2.HTTPResponse): nil
|
||||
* @lua@alias HTTPCallback fun(result: HTTPResponse): nil
|
||||
*/
|
||||
|
||||
/**
|
||||
* @lua@class c2.HTTPRequest
|
||||
* @lua@class HTTPRequest
|
||||
*/
|
||||
class HTTPRequest : public std::enable_shared_from_this<HTTPRequest>
|
||||
{
|
||||
|
@ -61,16 +61,16 @@ public:
|
|||
/**
|
||||
* Sets the success callback
|
||||
*
|
||||
* @lua@param callback c2.HTTPCallback Function to call when the HTTP request succeeds
|
||||
* @exposed c2.HTTPRequest:on_success
|
||||
* @lua@param callback HTTPCallback Function to call when the HTTP request succeeds
|
||||
* @exposed HTTPRequest:on_success
|
||||
*/
|
||||
void on_success(sol::protected_function func);
|
||||
|
||||
/**
|
||||
* Sets the failure callback
|
||||
*
|
||||
* @lua@param callback c2.HTTPCallback Function to call when the HTTP request fails or returns a non-ok status
|
||||
* @exposed c2.HTTPRequest:on_error
|
||||
* @lua@param callback HTTPCallback Function to call when the HTTP request fails or returns a non-ok status
|
||||
* @exposed HTTPRequest:on_error
|
||||
*/
|
||||
void on_error(sol::protected_function func);
|
||||
|
||||
|
@ -78,7 +78,7 @@ public:
|
|||
* Sets the finally callback
|
||||
*
|
||||
* @lua@param callback fun(): nil Function to call when the HTTP request finishes
|
||||
* @exposed c2.HTTPRequest:finally
|
||||
* @exposed HTTPRequest:finally
|
||||
*/
|
||||
void finally(sol::protected_function func);
|
||||
|
||||
|
@ -86,7 +86,7 @@ public:
|
|||
* Sets the timeout
|
||||
*
|
||||
* @lua@param timeout integer How long in milliseconds until the times out
|
||||
* @exposed c2.HTTPRequest:set_timeout
|
||||
* @exposed HTTPRequest:set_timeout
|
||||
*/
|
||||
void set_timeout(int timeout);
|
||||
|
||||
|
@ -94,7 +94,7 @@ public:
|
|||
* Sets the request payload
|
||||
*
|
||||
* @lua@param data string
|
||||
* @exposed c2.HTTPRequest:set_payload
|
||||
* @exposed HTTPRequest:set_payload
|
||||
*/
|
||||
void set_payload(QByteArray payload);
|
||||
|
||||
|
@ -103,19 +103,19 @@ public:
|
|||
*
|
||||
* @lua@param name string
|
||||
* @lua@param value string
|
||||
* @exposed c2.HTTPRequest:set_header
|
||||
* @exposed HTTPRequest:set_header
|
||||
*/
|
||||
void set_header(QByteArray name, QByteArray value);
|
||||
|
||||
/**
|
||||
* Executes the HTTP request
|
||||
*
|
||||
* @exposed c2.HTTPRequest:execute
|
||||
* @exposed HTTPRequest:execute
|
||||
*/
|
||||
void execute(sol::this_state L);
|
||||
/**
|
||||
* @lua@return string
|
||||
* @exposed c2.HTTPRequest:__tostring
|
||||
* @exposed HTTPRequest:__tostring
|
||||
*/
|
||||
QString to_string();
|
||||
|
||||
|
@ -126,11 +126,11 @@ public:
|
|||
/**
|
||||
* Creates a new HTTPRequest
|
||||
*
|
||||
* @lua@param method c2.HTTPMethod Method to use
|
||||
* @lua@param method HTTPMethod Method to use
|
||||
* @lua@param url string Where to send the request to
|
||||
*
|
||||
* @lua@return c2.HTTPRequest
|
||||
* @exposed c2.HTTPRequest.create
|
||||
* @lua@return HTTPRequest
|
||||
* @exposed HTTPRequest.create
|
||||
*/
|
||||
static std::shared_ptr<HTTPRequest> create(sol::this_state L,
|
||||
NetworkRequestType method,
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace chatterino::lua::api {
|
|||
// NOLINTBEGIN(readability-identifier-naming)
|
||||
|
||||
/**
|
||||
* @lua@class c2.HTTPResponse
|
||||
* @lua@class HTTPResponse
|
||||
*/
|
||||
class HTTPResponse
|
||||
{
|
||||
|
@ -38,34 +38,26 @@ public:
|
|||
* Returns the data. This is not guaranteed to be encoded using any
|
||||
* particular encoding scheme. It's just the bytes the server returned.
|
||||
*
|
||||
* @lua@return string
|
||||
* @lua@nodiscard
|
||||
* @exposed c2.HTTPResponse:data
|
||||
* @exposed HTTPResponse:data
|
||||
*/
|
||||
QByteArray data();
|
||||
|
||||
/**
|
||||
* Returns the status code.
|
||||
*
|
||||
* @lua@return number|nil
|
||||
* @lua@nodiscard
|
||||
* @exposed c2.HTTPResponse:status
|
||||
* @exposed HTTPResponse:status
|
||||
*/
|
||||
std::optional<int> status();
|
||||
|
||||
/**
|
||||
* A somewhat human readable description of an error if such happened
|
||||
*
|
||||
* @lua@return string
|
||||
* @lua@nodiscard
|
||||
* @exposed c2.HTTPResponse:error
|
||||
* @exposed HTTPResponse:error
|
||||
*/
|
||||
QString error();
|
||||
|
||||
/**
|
||||
* @lua@return string
|
||||
* @lua@nodiscard
|
||||
* @exposed c2.HTTPResponse:__tostring
|
||||
* @exposed HTTPResponse:__tostring
|
||||
*/
|
||||
QString to_string();
|
||||
};
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <shared_mutex>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace chatterino {
|
||||
|
@ -213,10 +212,9 @@ public:
|
|||
*
|
||||
* @param[in] index the index of the item to replace
|
||||
* @param[in] replacement the item to put in place of the item at index
|
||||
* @param[out] prev (optional) the item located at @a index before replacing
|
||||
* @return true if a replacement took place
|
||||
*/
|
||||
bool replaceItem(size_t index, const T &replacement, T *prev = nullptr)
|
||||
bool replaceItem(size_t index, const T &replacement)
|
||||
{
|
||||
std::unique_lock lock(this->mutex_);
|
||||
|
||||
|
@ -225,46 +223,10 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
if (prev)
|
||||
{
|
||||
*prev = std::exchange(this->buffer_[index], replacement);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->buffer_[index] = replacement;
|
||||
}
|
||||
this->buffer_[index] = replacement;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Replace the needle with the given item
|
||||
*
|
||||
* @param hint A hint on where the needle _might_ be
|
||||
* @param[in] needle the item to search for
|
||||
* @param[in] replacement the item to replace needle with
|
||||
* @return the index of the replaced item, or -1 if no replacement took place
|
||||
*/
|
||||
int replaceItem(size_t hint, const T &needle, const T &replacement)
|
||||
{
|
||||
std::unique_lock lock(this->mutex_);
|
||||
|
||||
if (hint < this->buffer_.size() && this->buffer_[hint] == needle)
|
||||
{
|
||||
this->buffer_[hint] = replacement;
|
||||
return static_cast<int>(hint);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < this->buffer_.size(); ++i)
|
||||
{
|
||||
if (this->buffer_[i] == needle)
|
||||
{
|
||||
this->buffer_[i] = replacement;
|
||||
return static_cast<int>(i);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Inserts the given item before another item
|
||||
*
|
||||
|
@ -353,32 +315,6 @@ public:
|
|||
return std::nullopt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Find an item with a hint
|
||||
*
|
||||
* @param hint A hint on where the needle _might_ be
|
||||
* @param predicate that will used to find the item
|
||||
* @return the item and its index or none if it's not found
|
||||
*/
|
||||
std::optional<std::pair<size_t, T>> find(size_t hint, auto &&predicate)
|
||||
{
|
||||
std::unique_lock lock(this->mutex_);
|
||||
|
||||
if (hint < this->buffer_.size() && predicate(this->buffer_[hint]))
|
||||
{
|
||||
return std::pair{hint, this->buffer_[hint]};
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < this->buffer_.size(); i++)
|
||||
{
|
||||
if (predicate(this->buffer_[i]))
|
||||
{
|
||||
return std::pair{i, this->buffer_[i]};
|
||||
}
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the first item matching a predicate, checking in reverse
|
||||
*
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include "providers/twitch/api/Helix.hpp"
|
||||
#include "providers/twitch/ChannelPointReward.hpp"
|
||||
#include "providers/twitch/PubSubActions.hpp"
|
||||
#include "providers/twitch/pubsubmessages/AutoMod.hpp"
|
||||
#include "providers/twitch/TwitchAccount.hpp"
|
||||
#include "providers/twitch/TwitchBadge.hpp"
|
||||
#include "providers/twitch/TwitchBadges.hpp"
|
||||
|
@ -53,7 +52,6 @@
|
|||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
#include <QFileInfo>
|
||||
#include <QStringBuilder>
|
||||
#include <QTimeZone>
|
||||
|
||||
#include <algorithm>
|
||||
|
@ -77,8 +75,6 @@ const QRegularExpression mentionRegex("^@" + regexHelpString);
|
|||
// if findAllUsernames setting is enabled, matches strings like in the examples above, but without @ symbol at the beginning
|
||||
const QRegularExpression allUsernamesMentionRegex("^" + regexHelpString);
|
||||
|
||||
const QRegularExpression SPACE_REGEX("\\s");
|
||||
|
||||
const QSet<QString> zeroWidthEmotes{
|
||||
"SoSnowy", "IceCold", "SantaHat", "TopHat",
|
||||
"ReinDeer", "CandyCane", "cvMask", "cvHazmat",
|
||||
|
@ -516,7 +512,7 @@ MessageBuilder::MessageBuilder(SystemMessageTag, const QString &text,
|
|||
// check system message for links
|
||||
// (e.g. needed for sub ticket message in sub only mode)
|
||||
const QStringList textFragments =
|
||||
text.split(SPACE_REGEX, Qt::SkipEmptyParts);
|
||||
text.split(QRegularExpression("\\s"), Qt::SkipEmptyParts);
|
||||
for (const auto &word : textFragments)
|
||||
{
|
||||
auto link = linkparser::parse(word);
|
||||
|
@ -535,100 +531,33 @@ MessageBuilder::MessageBuilder(SystemMessageTag, const QString &text,
|
|||
this->message().searchText = text;
|
||||
}
|
||||
|
||||
MessagePtrMut MessageBuilder::makeSystemMessageWithUser(
|
||||
const QString &text, const QString &loginName, const QString &displayName,
|
||||
const MessageColor &userColor, const QTime &time)
|
||||
MessageBuilder::MessageBuilder(RaidEntryMessageTag, const QString &text,
|
||||
const QString &loginName,
|
||||
const QString &displayName,
|
||||
const MessageColor &userColor, const QTime &time)
|
||||
: MessageBuilder()
|
||||
{
|
||||
MessageBuilder builder;
|
||||
builder.emplace<TimestampElement>(time);
|
||||
this->emplace<TimestampElement>(time);
|
||||
|
||||
const auto textFragments = text.split(SPACE_REGEX, Qt::SkipEmptyParts);
|
||||
const QStringList textFragments =
|
||||
text.split(QRegularExpression("\\s"), Qt::SkipEmptyParts);
|
||||
for (const auto &word : textFragments)
|
||||
{
|
||||
if (word == displayName)
|
||||
{
|
||||
builder.emplace<MentionElement>(displayName, loginName,
|
||||
MessageColor::System, userColor);
|
||||
this->emplace<MentionElement>(displayName, loginName,
|
||||
MessageColor::System, userColor);
|
||||
continue;
|
||||
}
|
||||
|
||||
builder.emplace<TextElement>(word, MessageElementFlag::Text,
|
||||
MessageColor::System);
|
||||
this->emplace<TextElement>(word, MessageElementFlag::Text,
|
||||
MessageColor::System);
|
||||
}
|
||||
|
||||
builder->flags.set(MessageFlag::System);
|
||||
builder->flags.set(MessageFlag::DoNotTriggerNotification);
|
||||
builder->messageText = text;
|
||||
builder->searchText = text;
|
||||
|
||||
return builder.release();
|
||||
}
|
||||
|
||||
MessagePtrMut MessageBuilder::makeSubgiftMessage(const QString &text,
|
||||
const QVariantMap &tags,
|
||||
const QTime &time)
|
||||
{
|
||||
MessageBuilder builder;
|
||||
builder.emplace<TimestampElement>(time);
|
||||
|
||||
auto gifterLogin = tags.value("login").toString();
|
||||
auto gifterDisplayName = tags.value("display-name").toString();
|
||||
if (gifterDisplayName.isEmpty())
|
||||
{
|
||||
gifterDisplayName = gifterLogin;
|
||||
}
|
||||
MessageColor gifterColor = MessageColor::System;
|
||||
if (auto colorTag = tags.value("color").value<QColor>(); colorTag.isValid())
|
||||
{
|
||||
gifterColor = MessageColor(colorTag);
|
||||
}
|
||||
|
||||
auto recipientLogin =
|
||||
tags.value("msg-param-recipient-user-name").toString();
|
||||
if (recipientLogin.isEmpty())
|
||||
{
|
||||
recipientLogin = tags.value("msg-param-recipient-name").toString();
|
||||
}
|
||||
auto recipientDisplayName =
|
||||
tags.value("msg-param-recipient-display-name").toString();
|
||||
if (recipientDisplayName.isEmpty())
|
||||
{
|
||||
recipientDisplayName = recipientLogin;
|
||||
}
|
||||
|
||||
const auto textFragments = text.split(SPACE_REGEX, Qt::SkipEmptyParts);
|
||||
for (const auto &word : textFragments)
|
||||
{
|
||||
if (word == gifterDisplayName)
|
||||
{
|
||||
builder.emplace<MentionElement>(gifterDisplayName, gifterLogin,
|
||||
MessageColor::System, gifterColor);
|
||||
continue;
|
||||
}
|
||||
if (word.endsWith('!') &&
|
||||
word.size() == recipientDisplayName.size() + 1 &&
|
||||
word.startsWith(recipientDisplayName))
|
||||
{
|
||||
builder
|
||||
.emplace<MentionElement>(recipientDisplayName, recipientLogin,
|
||||
MessageColor::System,
|
||||
MessageColor::System)
|
||||
->setTrailingSpace(false);
|
||||
builder.emplace<TextElement>(u"!"_s, MessageElementFlag::Text,
|
||||
MessageColor::System);
|
||||
continue;
|
||||
}
|
||||
|
||||
builder.emplace<TextElement>(word, MessageElementFlag::Text,
|
||||
MessageColor::System);
|
||||
}
|
||||
|
||||
builder->flags.set(MessageFlag::System);
|
||||
builder->flags.set(MessageFlag::DoNotTriggerNotification);
|
||||
builder->messageText = text;
|
||||
builder->searchText = text;
|
||||
|
||||
return builder.release();
|
||||
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,
|
||||
|
@ -1639,12 +1568,6 @@ std::pair<MessagePtr, MessagePtr> MessageBuilder::makeAutomodMessage(
|
|||
{
|
||||
MessageBuilder builder, builder2;
|
||||
|
||||
if (action.reasonCode == PubSubAutoModQueueMessage::Reason::BlockedTerm)
|
||||
{
|
||||
builder.message().flags.set(MessageFlag::AutoModBlockedTerm);
|
||||
builder2.message().flags.set(MessageFlag::AutoModBlockedTerm);
|
||||
}
|
||||
|
||||
//
|
||||
// Builder for AutoMod message with explanation
|
||||
builder.message().id = "automod_" + action.msgID;
|
||||
|
@ -1988,29 +1911,6 @@ MessagePtr MessageBuilder::makeLowTrustUpdateMessage(
|
|||
return builder.release();
|
||||
}
|
||||
|
||||
MessagePtrMut MessageBuilder::makeAccountExpiredMessage(
|
||||
const QString &expirationText)
|
||||
{
|
||||
auto loginPromptText = u"Try adding your account again."_s;
|
||||
|
||||
MessageBuilder builder;
|
||||
auto text = expirationText % ' ' % loginPromptText;
|
||||
builder->messageText = text;
|
||||
builder->searchText = text;
|
||||
builder->flags.set(MessageFlag::System,
|
||||
MessageFlag::DoNotTriggerNotification);
|
||||
|
||||
builder.emplace<TimestampElement>();
|
||||
builder.emplace<TextElement>(expirationText, MessageElementFlag::Text,
|
||||
MessageColor::System);
|
||||
builder
|
||||
.emplace<TextElement>(loginPromptText, MessageElementFlag::Text,
|
||||
MessageColor::Link)
|
||||
->setLink({Link::OpenAccountsPage, {}});
|
||||
|
||||
return builder.release();
|
||||
}
|
||||
|
||||
std::pair<MessagePtrMut, HighlightAlert> MessageBuilder::makeIrcMessage(
|
||||
/* mutable */ Channel *channel, const Communi::IrcMessage *ircMessage,
|
||||
const MessageParseArgs &args, /* mutable */ QString content,
|
||||
|
|
|
@ -52,6 +52,8 @@ namespace linkparser {
|
|||
|
||||
struct SystemMessageTag {
|
||||
};
|
||||
struct RaidEntryMessageTag {
|
||||
};
|
||||
struct TimeoutMessageTag {
|
||||
};
|
||||
struct LiveUpdatesUpdateEmoteMessageTag {
|
||||
|
@ -67,6 +69,7 @@ struct ImageUploaderResultTag {
|
|||
|
||||
// NOLINTBEGIN(readability-identifier-naming)
|
||||
const SystemMessageTag systemMessage{};
|
||||
const RaidEntryMessageTag raidEntryMessage{};
|
||||
const TimeoutMessageTag timeoutMessage{};
|
||||
const LiveUpdatesUpdateEmoteMessageTag liveUpdatesUpdateEmoteMessage{};
|
||||
const LiveUpdatesRemoveEmoteMessageTag liveUpdatesRemoveEmoteMessage{};
|
||||
|
@ -106,6 +109,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());
|
||||
|
@ -249,18 +255,6 @@ public:
|
|||
const std::shared_ptr<MessageThread> &thread = {},
|
||||
const MessagePtr &parent = {});
|
||||
|
||||
static MessagePtrMut makeSystemMessageWithUser(
|
||||
const QString &text, const QString &loginName,
|
||||
const QString &displayName, const MessageColor &userColor,
|
||||
const QTime &time);
|
||||
|
||||
static MessagePtrMut makeSubgiftMessage(const QString &text,
|
||||
const QVariantMap &tags,
|
||||
const QTime &time);
|
||||
|
||||
static MessagePtrMut makeAccountExpiredMessage(
|
||||
const QString &expirationText);
|
||||
|
||||
private:
|
||||
struct TextState {
|
||||
TwitchChannel *twitchChannel = nullptr;
|
||||
|
|
|
@ -52,8 +52,6 @@ enum class MessageFlag : std::int64_t {
|
|||
Action = (1LL << 36),
|
||||
/// The message is sent in a different source channel as part of a Shared Chat session
|
||||
SharedMessage = (1LL << 37),
|
||||
/// AutoMod message that showed up due to containing a blocked term in the channel
|
||||
AutoModBlockedTerm = (1LL << 38),
|
||||
};
|
||||
using MessageFlags = FlagsEnum<MessageFlag>;
|
||||
|
||||
|
|
|
@ -1,121 +0,0 @@
|
|||
#include "messages/MessageSimilarity.hpp"
|
||||
|
||||
#include "Application.hpp"
|
||||
#include "controllers/accounts/AccountController.hpp"
|
||||
#include "messages/LimitedQueueSnapshot.hpp" // IWYU pragma: keep
|
||||
#include "providers/twitch/TwitchAccount.hpp"
|
||||
#include "singletons/Settings.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace chatterino;
|
||||
|
||||
float relativeSimilarity(QStringView str1, QStringView str2)
|
||||
{
|
||||
using SizeType = QStringView::size_type;
|
||||
|
||||
// Longest Common Substring Problem
|
||||
std::vector<std::vector<int>> tree(str1.size(),
|
||||
std::vector<int>(str2.size(), 0));
|
||||
int z = 0;
|
||||
|
||||
for (SizeType i = 0; i < str1.size(); ++i)
|
||||
{
|
||||
for (SizeType j = 0; j < str2.size(); ++j)
|
||||
{
|
||||
if (str1[i] == str2[j])
|
||||
{
|
||||
if (i == 0 || j == 0)
|
||||
{
|
||||
tree[i][j] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
tree[i][j] = tree[i - 1][j - 1] + 1;
|
||||
}
|
||||
z = std::max(tree[i][j], z);
|
||||
}
|
||||
else
|
||||
{
|
||||
tree[i][j] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ensure that no div by 0
|
||||
if (z == 0)
|
||||
{
|
||||
return 0.F;
|
||||
}
|
||||
|
||||
auto div = std::max<>({static_cast<SizeType>(1), str1.size(), str2.size()});
|
||||
|
||||
return float(z) / float(div);
|
||||
}
|
||||
|
||||
template <std::ranges::bidirectional_range T>
|
||||
float inMessages(const MessagePtr &msg, const T &messages)
|
||||
{
|
||||
float similarityPercent = 0.0F;
|
||||
|
||||
for (const auto &prevMsg :
|
||||
messages | std::views::reverse |
|
||||
std::views::take(getSettings()->hideSimilarMaxMessagesToCheck))
|
||||
{
|
||||
if (prevMsg->parseTime.secsTo(QTime::currentTime()) >=
|
||||
getSettings()->hideSimilarMaxDelay)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (getSettings()->hideSimilarBySameUser &&
|
||||
msg->loginName != prevMsg->loginName)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
similarityPercent = std::max(
|
||||
similarityPercent,
|
||||
relativeSimilarity(msg->messageText, prevMsg->messageText));
|
||||
}
|
||||
|
||||
return similarityPercent;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
template <std::ranges::bidirectional_range T>
|
||||
void setSimilarityFlags(const MessagePtr &message, const T &messages)
|
||||
{
|
||||
if (getSettings()->similarityEnabled)
|
||||
{
|
||||
bool isMyself =
|
||||
message->loginName ==
|
||||
getApp()->getAccounts()->twitch.getCurrent()->getUserName();
|
||||
bool hideMyself = getSettings()->hideSimilarMyself;
|
||||
|
||||
if (isMyself && !hideMyself)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (inMessages(message, messages) > getSettings()->similarityPercentage)
|
||||
{
|
||||
message->flags.set(MessageFlag::Similar);
|
||||
if (getSettings()->colorSimilarDisabled)
|
||||
{
|
||||
message->flags.set(MessageFlag::Disabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template void setSimilarityFlags<std::vector<MessagePtr>>(
|
||||
const MessagePtr &msg, const std::vector<MessagePtr> &messages);
|
||||
template void setSimilarityFlags<LimitedQueueSnapshot<MessagePtr>>(
|
||||
const MessagePtr &msg, const LimitedQueueSnapshot<MessagePtr> &messages);
|
||||
|
||||
} // namespace chatterino
|
|
@ -1,11 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "messages/Message.hpp"
|
||||
|
||||
#include <ranges>
|
||||
namespace chatterino {
|
||||
|
||||
template <std::ranges::bidirectional_range T>
|
||||
void setSimilarityFlags(const MessagePtr &message, const T &messages);
|
||||
|
||||
} // namespace chatterino
|
|
@ -1,67 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "common/enums/MessageContext.hpp"
|
||||
#include "common/FlagsEnum.hpp"
|
||||
#include "messages/MessageFlag.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
class QStringView;
|
||||
class QTime;
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
struct Message;
|
||||
using MessagePtr = std::shared_ptr<const Message>;
|
||||
|
||||
enum class MessageSinkTrait : uint8_t {
|
||||
None = 0,
|
||||
|
||||
/// Messages with the `Highlighted` and `ShowInMentions` flags should be
|
||||
/// added to the global mentions channel when encountered.
|
||||
AddMentionsToGlobalChannel = 1 << 0,
|
||||
|
||||
/// A channel-point redemption whose reward is not yet known should not be
|
||||
/// added to this sink, but queued in the corresponding TwitchChannel
|
||||
/// (`addQueuedRedemption`).
|
||||
RequiresKnownChannelPointReward = 1 << 1,
|
||||
};
|
||||
using MessageSinkTraits = FlagsEnum<MessageSinkTrait>;
|
||||
|
||||
/// A generic interface for a managed buffer of `Message`s
|
||||
class MessageSink
|
||||
{
|
||||
public:
|
||||
virtual ~MessageSink() = default;
|
||||
|
||||
/// Add a message to this sink
|
||||
///
|
||||
/// @param message The message to add (non-null)
|
||||
/// @param ctx The context in which this message is being added.
|
||||
/// @param overridingFlags
|
||||
virtual void addMessage(
|
||||
MessagePtr message, MessageContext ctx,
|
||||
std::optional<MessageFlags> overridingFlags = std::nullopt) = 0;
|
||||
|
||||
/// Adds a timeout message or merges it into an existing one
|
||||
virtual void addOrReplaceTimeout(MessagePtr clearchatMessage,
|
||||
QTime now) = 0;
|
||||
|
||||
/// Flags all messages as `Disabled`
|
||||
virtual void disableAllMessages() = 0;
|
||||
|
||||
/// Searches for similar messages and flags this message as similar
|
||||
/// (based on the current settings).
|
||||
virtual void applySimilarityFilters(const MessagePtr &message) const = 0;
|
||||
|
||||
/// @brief Searches for a message by an ID
|
||||
///
|
||||
/// If there is no message found, an empty shared-pointer is returned.
|
||||
virtual MessagePtr findMessageByID(QStringView id) = 0;
|
||||
|
||||
/// Behaviour to be exercised when parsing/building messages for this sink.
|
||||
virtual MessageSinkTraits sinkTraits() const = 0;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
|
@ -141,9 +141,6 @@ void MessageLayout::actuallyLayout(const MessageLayoutContext &ctx)
|
|||
|
||||
bool hideModerated = getSettings()->hideModerated;
|
||||
bool hideModerationActions = getSettings()->hideModerationActions;
|
||||
bool hideBlockedTermAutomodMessages =
|
||||
getSettings()->showBlockedTermAutomodMessages.getEnum() ==
|
||||
ShowModerationState::Never;
|
||||
bool hideSimilar = getSettings()->hideSimilar;
|
||||
bool hideReplies = !ctx.flags.has(MessageElementFlag::RepliedMessage);
|
||||
|
||||
|
@ -157,21 +154,9 @@ void MessageLayout::actuallyLayout(const MessageLayoutContext &ctx)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (hideBlockedTermAutomodMessages &&
|
||||
this->message_->flags.has(MessageFlag::AutoModBlockedTerm))
|
||||
{
|
||||
// NOTE: This hides the message but it will make the message re-appear if moderation message hiding is no longer active, and the layout is re-laid-out.
|
||||
// This is only the case for the moderation messages that don't get filtered during creation.
|
||||
// We should decide which is the correct method & apply that everywhere
|
||||
continue;
|
||||
}
|
||||
|
||||
if (this->message_->flags.has(MessageFlag::Timeout) ||
|
||||
this->message_->flags.has(MessageFlag::Untimeout))
|
||||
{
|
||||
// NOTE: This hides the message but it will make the message re-appear if moderation message hiding is no longer active, and the layout is re-laid-out.
|
||||
// This is only the case for the moderation messages that don't get filtered during creation.
|
||||
// We should decide which is the correct method & apply that everywhere
|
||||
if (hideModerationActions ||
|
||||
(getSettings()->streamerModeHideModActions &&
|
||||
getApp()->getStreamerMode()->isEnabled()))
|
||||
|
|
|
@ -854,18 +854,6 @@ std::optional<size_t> MessageLayoutContainer::paintSelectionStart(
|
|||
{
|
||||
const auto selectionColor = getTheme()->messages.selection;
|
||||
|
||||
auto paintRemainingLines = [&](size_t startIndex) {
|
||||
for (size_t i = startIndex; i < this->lines_.size(); i++)
|
||||
{
|
||||
const auto &line = this->lines_[i];
|
||||
auto left = this->elements_[line.startIndex]->getRect().left();
|
||||
auto right = this->elements_[line.endIndex - 1]->getRect().right();
|
||||
|
||||
this->paintSelectionRect(painter, line, left, right, yOffset,
|
||||
selectionColor);
|
||||
}
|
||||
};
|
||||
|
||||
// The selection starts in this message
|
||||
for (size_t lineIndex = 0; lineIndex < this->lines_.size(); lineIndex++)
|
||||
{
|
||||
|
@ -886,17 +874,7 @@ std::optional<size_t> MessageLayoutContainer::paintSelectionStart(
|
|||
auto right = this->elements_[line.endIndex - 1]->getRect().right();
|
||||
this->paintSelectionRect(painter, line, right, right, yOffset,
|
||||
selectionColor);
|
||||
|
||||
if (selection.selectionMax.messageIndex != messageIndex)
|
||||
{
|
||||
// The selection does not end in this message
|
||||
paintRemainingLines(lineIndex + 1);
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// The selection starts in this line, but ends in some next line or message
|
||||
return {lineIndex + 1};
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
int x = this->elements_[line.startIndex]->getRect().left();
|
||||
|
@ -945,9 +923,21 @@ std::optional<size_t> MessageLayoutContainer::paintSelectionStart(
|
|||
if (selection.selectionMax.messageIndex != messageIndex)
|
||||
{
|
||||
// The selection does not end in this message
|
||||
for (size_t lineIndex2 = lineIndex + 1;
|
||||
lineIndex2 < this->lines_.size(); lineIndex2++)
|
||||
{
|
||||
const auto &line2 = this->lines_[lineIndex2];
|
||||
auto left =
|
||||
this->elements_[line2.startIndex]->getRect().left();
|
||||
auto right =
|
||||
this->elements_[line2.endIndex - 1]->getRect().right();
|
||||
|
||||
this->paintSelectionRect(painter, line2, left, right,
|
||||
yOffset, selectionColor);
|
||||
}
|
||||
|
||||
this->paintSelectionRect(painter, line, x, r, yOffset,
|
||||
selectionColor);
|
||||
paintRemainingLines(lineIndex + 1);
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
|
|
@ -283,12 +283,7 @@ private:
|
|||
/**
|
||||
* Paint the selection start
|
||||
*
|
||||
* @returns A line index if the selection ends within this message but start
|
||||
* and end are on different lines. The returned index is the index
|
||||
* of the first line where the selection starts at the beginning of
|
||||
* the line. This index should be passed to paintSelectionEnd().
|
||||
* If `std::nullopt` is returned, no further call to
|
||||
* paintSelectionEnd() is necessary.
|
||||
* Returns a line index if this message should also paint the selection end
|
||||
*/
|
||||
std::optional<size_t> paintSelectionStart(QPainter &painter,
|
||||
size_t messageIndex,
|
||||
|
|
|
@ -3,9 +3,7 @@
|
|||
#include "common/Env.hpp"
|
||||
#include "messages/MessageBuilder.hpp"
|
||||
#include "providers/twitch/IrcMessageHandler.hpp"
|
||||
#include "providers/twitch/TwitchChannel.hpp"
|
||||
#include "util/Helpers.hpp"
|
||||
#include "util/VectorMessageSink.hpp"
|
||||
|
||||
#include <QJsonArray>
|
||||
#include <QUrlQuery>
|
||||
|
@ -42,13 +40,7 @@ std::vector<Communi::IrcMessage *> parseRecentMessages(
|
|||
std::vector<MessagePtr> buildRecentMessages(
|
||||
std::vector<Communi::IrcMessage *> &messages, Channel *channel)
|
||||
{
|
||||
VectorMessageSink sink({}, MessageFlag::RecentMessage);
|
||||
|
||||
auto *twitchChannel = dynamic_cast<TwitchChannel *>(channel);
|
||||
if (!twitchChannel)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
std::vector<MessagePtr> allBuiltMessages;
|
||||
|
||||
for (auto *message : messages)
|
||||
{
|
||||
|
@ -66,16 +58,24 @@ std::vector<MessagePtr> buildRecentMessages(
|
|||
auto msg = makeSystemMessage(
|
||||
QLocale().toString(msgDate, QLocale::LongFormat),
|
||||
QTime(0, 0));
|
||||
sink.addMessage(msg, MessageContext::Original);
|
||||
msg->flags.set(MessageFlag::RecentMessage);
|
||||
allBuiltMessages.emplace_back(msg);
|
||||
}
|
||||
}
|
||||
|
||||
IrcMessageHandler::parseMessageInto(message, sink, twitchChannel);
|
||||
auto builtMessages = IrcMessageHandler::parseMessageWithReply(
|
||||
channel, message, allBuiltMessages);
|
||||
|
||||
for (const auto &builtMessage : builtMessages)
|
||||
{
|
||||
builtMessage->flags.set(MessageFlag::RecentMessage);
|
||||
allBuiltMessages.emplace_back(builtMessage);
|
||||
}
|
||||
|
||||
message->deleteLater();
|
||||
}
|
||||
|
||||
return std::move(sink).takeMessages();
|
||||
return allBuiltMessages;
|
||||
}
|
||||
|
||||
// Returns the URL to be used for querying the Recent Messages API for the
|
||||
|
|
|
@ -233,14 +233,6 @@ void SeventvEventAPI::handleDispatch(const Dispatch &dispatch)
|
|||
}
|
||||
}
|
||||
break;
|
||||
case SubscriptionType::ResetEntitlement: {
|
||||
// unhandled (not clear what we'd do here yet)
|
||||
}
|
||||
break;
|
||||
case SubscriptionType::CreateEmoteSet: {
|
||||
// unhandled (c2 does not support custom emote sets)
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
qCDebug(chatterinoSeventvEventAPI)
|
||||
<< "Unknown subscription type:"
|
||||
|
|
|
@ -27,7 +27,6 @@ enum class SubscriptionType {
|
|||
CreateEntitlement,
|
||||
UpdateEntitlement,
|
||||
DeleteEntitlement,
|
||||
ResetEntitlement,
|
||||
|
||||
INVALID,
|
||||
};
|
||||
|
@ -120,8 +119,6 @@ constexpr magic_enum::customize::customize_t magic_enum::customize::enum_name<
|
|||
return "entitlement.update";
|
||||
case SubscriptionType::DeleteEntitlement:
|
||||
return "entitlement.delete";
|
||||
case SubscriptionType::ResetEntitlement:
|
||||
return "entitlement.reset";
|
||||
|
||||
default:
|
||||
return default_tag;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -16,7 +16,6 @@ struct Message;
|
|||
using MessagePtr = std::shared_ptr<const Message>;
|
||||
class TwitchChannel;
|
||||
class TwitchMessageBuilder;
|
||||
class MessageSink;
|
||||
|
||||
struct ClearChatMessage {
|
||||
MessagePtr message;
|
||||
|
@ -34,34 +33,30 @@ public:
|
|||
* Parse an IRC message into 0 or more Chatterino messages
|
||||
* Takes previously loaded messages into consideration to add reply contexts
|
||||
**/
|
||||
static void parseMessageInto(Communi::IrcMessage *message,
|
||||
MessageSink &sink, TwitchChannel *channel);
|
||||
static std::vector<MessagePtr> parseMessageWithReply(
|
||||
Channel *channel, Communi::IrcMessage *message,
|
||||
std::vector<MessagePtr> &otherLoaded);
|
||||
|
||||
void handlePrivMessage(Communi::IrcPrivateMessage *message,
|
||||
ITwitchIrcServer &twitchServer);
|
||||
static void parsePrivMessageInto(Communi::IrcPrivateMessage *message,
|
||||
MessageSink &sink, TwitchChannel *channel);
|
||||
|
||||
void handleRoomStateMessage(Communi::IrcMessage *message);
|
||||
void handleClearChatMessage(Communi::IrcMessage *message);
|
||||
void handleClearMessageMessage(Communi::IrcMessage *message);
|
||||
void handleUserStateMessage(Communi::IrcMessage *message);
|
||||
|
||||
void handleWhisperMessage(Communi::IrcMessage *ircMessage);
|
||||
|
||||
void handleUserNoticeMessage(Communi::IrcMessage *message,
|
||||
ITwitchIrcServer &twitchServer);
|
||||
static void parseUserNoticeMessageInto(Communi::IrcMessage *message,
|
||||
MessageSink &sink,
|
||||
TwitchChannel *channel);
|
||||
|
||||
void handleNoticeMessage(Communi::IrcNoticeMessage *message);
|
||||
|
||||
void handleJoinMessage(Communi::IrcMessage *message);
|
||||
void handlePartMessage(Communi::IrcMessage *message);
|
||||
|
||||
static void addMessage(Communi::IrcMessage *message, MessageSink &sink,
|
||||
TwitchChannel *chan, const QString &originalContent,
|
||||
ITwitchIrcServer &twitch, bool isSub, bool isAction);
|
||||
void addMessage(Communi::IrcMessage *message, const ChannelPtr &chan,
|
||||
const QString &originalContent, ITwitchIrcServer &server,
|
||||
bool isSub, bool isAction);
|
||||
|
||||
private:
|
||||
static float similarity(const MessagePtr &msg,
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include "providers/twitch/pubsubmessages/AutoMod.hpp"
|
||||
|
||||
#include <QColor>
|
||||
#include <QDebug>
|
||||
#include <QJsonObject>
|
||||
|
@ -145,7 +143,6 @@ struct AutomodAction : PubSubAction {
|
|||
QString message;
|
||||
|
||||
QString reason;
|
||||
PubSubAutoModQueueMessage::Reason reasonCode;
|
||||
|
||||
QString msgID;
|
||||
};
|
||||
|
|
|
@ -349,6 +349,40 @@ PubSub::PubSub(const QString &host, std::chrono::seconds pingInterval)
|
|||
this->moderation.raidCanceled.invoke(action);
|
||||
};
|
||||
|
||||
/*
|
||||
// This handler is no longer required as we use the automod-queue topic now
|
||||
this->moderationActionHandlers["automod_rejected"] =
|
||||
[this](const auto &data, const auto &roomID) {
|
||||
AutomodAction action(data, roomID);
|
||||
|
||||
action.source.id = data.value("created_by_user_id").toString();
|
||||
action.source.login = data.value("created_by").toString();
|
||||
|
||||
action.target.id = data.value("target_user_id").toString();
|
||||
|
||||
const auto args = data.value("args").toArray();
|
||||
|
||||
if (args.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
action.msgID = data.value("msg_id").toString();
|
||||
|
||||
if (action.msgID.isEmpty())
|
||||
{
|
||||
// Missing required msg_id parameter
|
||||
return;
|
||||
}
|
||||
|
||||
action.target.login = args[0].toString();
|
||||
action.message = args[1].toString(); // May be omitted
|
||||
action.reason = args[2].toString(); // May be omitted
|
||||
|
||||
this->moderation.autoModMessageBlocked.invoke(action);
|
||||
};
|
||||
*/
|
||||
|
||||
this->moderationActionHandlers["automod_message_rejected"] =
|
||||
[this](const auto &data, const auto &roomID) {
|
||||
AutomodInfoAction action(data, roomID);
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include "common/network/NetworkResult.hpp"
|
||||
#include "common/Outcome.hpp"
|
||||
#include "common/QLogging.hpp"
|
||||
#include "messages/MessageBuilder.hpp"
|
||||
#include "providers/twitch/api/Helix.hpp"
|
||||
#include "providers/twitch/TwitchAccount.hpp"
|
||||
#include "providers/twitch/TwitchCommon.hpp"
|
||||
|
@ -412,28 +411,20 @@ void TwitchAccountManager::refreshAccounts(bool emitChanged)
|
|||
})
|
||||
.onError([this, account](const auto &res) {
|
||||
auto json = res.parseJson();
|
||||
QString message = u"Failed to refresh OAuth token for " %
|
||||
account->getUserName() % u" (" %
|
||||
res.formatError() % u" - " %
|
||||
json["message"_L1].toString(u"no message"_s) %
|
||||
u").";
|
||||
QString message =
|
||||
u"Failed to refresh OAuth token for " %
|
||||
account->getUserName() % u" error: " % res.formatError() %
|
||||
u" - " % json["message"_L1].toString(u"(no message)"_s);
|
||||
qCWarning(chatterinoTwitch) << message;
|
||||
|
||||
if (account == this->getCurrent())
|
||||
{
|
||||
if (res.status().value_or(0) == 400) // invalid token
|
||||
{
|
||||
auto msg =
|
||||
MessageBuilder::makeAccountExpiredMessage(message);
|
||||
getApp()->getTwitch()->forEachChannel(
|
||||
[msg](const auto &chan) {
|
||||
chan->addMessage(msg, MessageContext::Original);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
getApp()->getTwitch()->addGlobalSystemMessage(message);
|
||||
message +=
|
||||
QStringView(u". Consider re-adding your account.");
|
||||
}
|
||||
getApp()->getTwitch()->addGlobalSystemMessage(message);
|
||||
}
|
||||
})
|
||||
.finally(tryFlush)
|
||||
|
|
|
@ -291,7 +291,7 @@ void TwitchChannel::refreshTwitchChannelEmotesFor(
|
|||
};
|
||||
|
||||
getHelix()->getFollowedChannel(
|
||||
account->getUserId(), this->roomId(), nullptr,
|
||||
account->getUserId(), this->roomId(),
|
||||
[weak{this->weak_from_this()}, makeEmotes](const auto &chan) {
|
||||
auto self = std::dynamic_pointer_cast<TwitchChannel>(weak.lock());
|
||||
if (!self || !chan)
|
||||
|
@ -469,8 +469,8 @@ void TwitchChannel::addChannelPointReward(const ChannelPointReward &reward)
|
|||
if (reward.id == msg.rewardID)
|
||||
{
|
||||
IrcMessageHandler::instance().addMessage(
|
||||
msg.message.get(), *this, this, msg.originalContent,
|
||||
*server, false, false);
|
||||
msg.message.get(), shared_from_this(),
|
||||
msg.originalContent, *server, false, false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -1373,6 +1373,8 @@ void TwitchChannel::loadRecentMessages()
|
|||
{
|
||||
msgs.push_back(msg);
|
||||
}
|
||||
|
||||
tc->addRecentChatter(msg->displayName);
|
||||
}
|
||||
|
||||
getApp()->getTwitch()->getMentionsChannel()->fillInMissingMessages(
|
||||
|
|
|
@ -325,7 +325,7 @@ void TwitchIrcServer::initialize()
|
|||
postToThread([chan, action] {
|
||||
MessageBuilder msg(action);
|
||||
msg->flags.set(MessageFlag::PubSub);
|
||||
chan->addOrReplaceTimeout(msg.release(), QTime::currentTime());
|
||||
chan->addOrReplaceTimeout(msg.release());
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -507,7 +507,6 @@ void TwitchIrcServer::initialize()
|
|||
|
||||
action.msgID = msg.messageID;
|
||||
action.message = msg.messageText;
|
||||
action.reasonCode = msg.reason;
|
||||
|
||||
// this message also contains per-word automod data, which could be implemented
|
||||
|
||||
|
|
|
@ -3138,7 +3138,7 @@ void Helix::getUserEmotes(
|
|||
}
|
||||
|
||||
void Helix::getFollowedChannel(
|
||||
QString userID, QString broadcasterID, const QObject *caller,
|
||||
QString userID, QString broadcasterID,
|
||||
ResultCallback<std::optional<HelixFollowedChannel>> successCallback,
|
||||
FailureCallback<QString> failureCallback)
|
||||
{
|
||||
|
@ -3147,7 +3147,6 @@ void Helix::getFollowedChannel(
|
|||
{u"user_id"_s, userID},
|
||||
{u"broadcaster_id"_s, broadcasterID},
|
||||
})
|
||||
.caller(caller)
|
||||
.onSuccess([successCallback](auto result) {
|
||||
if (result.status() != 200)
|
||||
{
|
||||
|
|
|
@ -1143,7 +1143,7 @@ public:
|
|||
/// https://dev.twitch.tv/docs/api/reference/#get-followed-channels
|
||||
/// (non paginated)
|
||||
virtual void getFollowedChannel(
|
||||
QString userID, QString broadcasterID, const QObject *caller,
|
||||
QString userID, QString broadcasterID,
|
||||
ResultCallback<std::optional<HelixFollowedChannel>> successCallback,
|
||||
FailureCallback<QString> failureCallback) = 0;
|
||||
|
||||
|
@ -1486,7 +1486,7 @@ public:
|
|||
/// https://dev.twitch.tv/docs/api/reference/#get-followed-channels
|
||||
/// (non paginated)
|
||||
void getFollowedChannel(
|
||||
QString userID, QString broadcasterID, const QObject *caller,
|
||||
QString userID, QString broadcasterID,
|
||||
ResultCallback<std::optional<HelixFollowedChannel>> successCallback,
|
||||
FailureCallback<QString> failureCallback) final;
|
||||
|
||||
|
|
|
@ -15,10 +15,6 @@ PubSubAutoModQueueMessage::PubSubAutoModQueueMessage(const QJsonObject &root)
|
|||
this->type = oType.value();
|
||||
}
|
||||
|
||||
this->reason =
|
||||
qmagicenum::enumCast<Reason>(data.value("reason_code").toString())
|
||||
.value_or(Reason::INVALID);
|
||||
|
||||
auto contentClassification =
|
||||
data.value("content_classification").toObject();
|
||||
|
||||
|
|
|
@ -13,24 +13,15 @@ struct PubSubAutoModQueueMessage {
|
|||
|
||||
INVALID,
|
||||
};
|
||||
|
||||
enum class Reason {
|
||||
AutoMod,
|
||||
BlockedTerm,
|
||||
|
||||
INVALID,
|
||||
};
|
||||
|
||||
QString typeString;
|
||||
Type type = Type::INVALID;
|
||||
Reason reason = Reason::INVALID;
|
||||
|
||||
QJsonObject data;
|
||||
|
||||
QString status;
|
||||
|
||||
QString contentCategory;
|
||||
int contentLevel{};
|
||||
int contentLevel;
|
||||
|
||||
QString messageID;
|
||||
QString messageText;
|
||||
|
@ -60,20 +51,3 @@ constexpr magic_enum::customize::customize_t magic_enum::customize::enum_name<
|
|||
return default_tag;
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
constexpr magic_enum::customize::customize_t magic_enum::customize::enum_name<
|
||||
chatterino::PubSubAutoModQueueMessage::Reason>(
|
||||
chatterino::PubSubAutoModQueueMessage::Reason value) noexcept
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case chatterino::PubSubAutoModQueueMessage::Reason::AutoMod:
|
||||
return "AutoModCaughtMessageReason";
|
||||
case chatterino::PubSubAutoModQueueMessage::Reason::BlockedTerm:
|
||||
return "BlockedTermCaughtMessageReason";
|
||||
|
||||
default:
|
||||
return default_tag;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,13 +69,6 @@ enum class ChatSendProtocol : int {
|
|||
Helix = 2,
|
||||
};
|
||||
|
||||
enum class ShowModerationState : int {
|
||||
// Always show this moderation-related item
|
||||
Always = 0,
|
||||
// Never show this moderation-related item
|
||||
Never = 1,
|
||||
};
|
||||
|
||||
enum StreamerModeSetting {
|
||||
Disabled = 0,
|
||||
Enabled = 1,
|
||||
|
@ -352,10 +345,6 @@ public:
|
|||
IntSetting timeoutStackStyle = {
|
||||
"/moderation/timeoutStackStyle",
|
||||
static_cast<int>(TimeoutStackStyle::Default)};
|
||||
EnumStringSetting<ShowModerationState> showBlockedTermAutomodMessages = {
|
||||
"/moderation/showBlockedTermAutomodMessages",
|
||||
ShowModerationState::Always,
|
||||
};
|
||||
|
||||
/// Highlighting
|
||||
// BoolSetting enableHighlights = {"/highlighting/enabled", true};
|
||||
|
|
|
@ -140,8 +140,6 @@ WindowManager::WindowManager(const Paths &paths, Settings &settings,
|
|||
this->forceLayoutChannelViewsListener.add(settings.enableRedeemedHighlight);
|
||||
this->forceLayoutChannelViewsListener.add(settings.colorUsernames);
|
||||
this->forceLayoutChannelViewsListener.add(settings.boldUsernames);
|
||||
this->forceLayoutChannelViewsListener.add(
|
||||
settings.showBlockedTermAutomodMessages);
|
||||
|
||||
this->layoutChannelViewsListener.add(settings.timestampFormat);
|
||||
this->layoutChannelViewsListener.add(fonts.fontChanged);
|
||||
|
|
|
@ -1,86 +0,0 @@
|
|||
#include "util/VectorMessageSink.hpp"
|
||||
|
||||
#include "messages/MessageSimilarity.hpp"
|
||||
#include "util/ChannelHelpers.hpp"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
VectorMessageSink::VectorMessageSink(MessageSinkTraits traits,
|
||||
MessageFlags additionalFlags)
|
||||
: additionalFlags(additionalFlags)
|
||||
, traits(traits){};
|
||||
VectorMessageSink::~VectorMessageSink() = default;
|
||||
|
||||
void VectorMessageSink::addMessage(MessagePtr message, MessageContext ctx,
|
||||
std::optional<MessageFlags> overridingFlags)
|
||||
{
|
||||
assert(!overridingFlags.has_value());
|
||||
assert(ctx == MessageContext::Original);
|
||||
|
||||
message->flags.set(this->additionalFlags);
|
||||
this->messages_.emplace_back(std::move(message));
|
||||
}
|
||||
|
||||
void VectorMessageSink::addOrReplaceTimeout(MessagePtr clearchatMessage,
|
||||
QTime now)
|
||||
{
|
||||
addOrReplaceChannelTimeout(
|
||||
this->messages_, std::move(clearchatMessage), now,
|
||||
[&](auto idx, auto /*msg*/, auto &&replacement) {
|
||||
replacement->flags.set(this->additionalFlags);
|
||||
this->messages_[idx] = replacement;
|
||||
},
|
||||
[&](auto &&msg) {
|
||||
this->messages_.emplace_back(msg);
|
||||
},
|
||||
false);
|
||||
}
|
||||
|
||||
void VectorMessageSink::disableAllMessages()
|
||||
{
|
||||
if (this->additionalFlags.has(MessageFlag::RecentMessage))
|
||||
{
|
||||
return; // don't disable recent messages
|
||||
}
|
||||
|
||||
for (const auto &msg : this->messages_)
|
||||
{
|
||||
msg->flags.set(MessageFlag::Disabled);
|
||||
}
|
||||
}
|
||||
|
||||
void VectorMessageSink::applySimilarityFilters(const MessagePtr &message) const
|
||||
{
|
||||
setSimilarityFlags(message, this->messages_);
|
||||
}
|
||||
|
||||
MessagePtr VectorMessageSink::findMessageByID(QStringView id)
|
||||
{
|
||||
for (const auto &msg : this->messages_ | std::views::reverse)
|
||||
{
|
||||
if (msg->id == id)
|
||||
{
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
const std::vector<MessagePtr> &VectorMessageSink::messages() const
|
||||
{
|
||||
return this->messages_;
|
||||
}
|
||||
|
||||
std::vector<MessagePtr> VectorMessageSink::takeMessages() &&
|
||||
{
|
||||
return std::move(this->messages_);
|
||||
}
|
||||
|
||||
MessageSinkTraits VectorMessageSink::sinkTraits() const
|
||||
{
|
||||
return this->traits;
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
|
@ -1,36 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "messages/MessageSink.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class VectorMessageSink final : public MessageSink
|
||||
{
|
||||
public:
|
||||
VectorMessageSink(MessageSinkTraits traits = {},
|
||||
MessageFlags additionalFlags = {});
|
||||
~VectorMessageSink() override;
|
||||
|
||||
void addMessage(
|
||||
MessagePtr message, MessageContext ctx,
|
||||
std::optional<MessageFlags> overridingFlags = std::nullopt) override;
|
||||
void addOrReplaceTimeout(MessagePtr clearchatMessage, QTime now) override;
|
||||
|
||||
void disableAllMessages() override;
|
||||
|
||||
void applySimilarityFilters(const MessagePtr &message) const override;
|
||||
|
||||
MessagePtr findMessageByID(QStringView id) override;
|
||||
|
||||
MessageSinkTraits sinkTraits() const override;
|
||||
|
||||
const std::vector<MessagePtr> &messages() const;
|
||||
std::vector<MessagePtr> takeMessages() &&;
|
||||
|
||||
private:
|
||||
std::vector<MessagePtr> messages_;
|
||||
MessageFlags additionalFlags;
|
||||
MessageSinkTraits traits;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
|
@ -41,7 +41,6 @@ DraggablePopup::DraggablePopup(bool closeAutomatically, QWidget *parent)
|
|||
BaseWindow::ClearBuffersOnDpiChange,
|
||||
parent)
|
||||
, lifetimeHack_(std::make_shared<bool>(false))
|
||||
, closeAutomatically_(closeAutomatically)
|
||||
, dragTimer_(this)
|
||||
|
||||
{
|
||||
|
@ -129,14 +128,4 @@ Button *DraggablePopup::createPinButton()
|
|||
return this->pinButton_;
|
||||
}
|
||||
|
||||
bool DraggablePopup::ensurePinned()
|
||||
{
|
||||
if (this->closeAutomatically_ && !this->isPinned_)
|
||||
{
|
||||
this->togglePinned();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -38,18 +38,10 @@ protected:
|
|||
// button pixmap
|
||||
void togglePinned();
|
||||
|
||||
/// Ensures that this popup is pinned (if it's expected to close automatically)
|
||||
///
|
||||
/// @returns `true` if the popup was pinned as a result (i.e. if the popup
|
||||
/// was unpinned and said to automatically close before)
|
||||
bool ensurePinned();
|
||||
|
||||
private:
|
||||
// isMoving_ is set to true if the user is holding the left mouse button down and has moved the mouse a small amount away from the original click point (startPosDrag_)
|
||||
bool isMoving_ = false;
|
||||
|
||||
bool closeAutomatically_ = false;
|
||||
|
||||
// startPosDrag_ is the coordinates where the user originally pressed the mouse button down to start dragging
|
||||
QPoint startPosDrag_;
|
||||
|
||||
|
|
|
@ -204,7 +204,7 @@ void Notebook::duplicatePage(QWidget *page)
|
|||
{
|
||||
newTabPosition = tabPosition + 1;
|
||||
}
|
||||
|
||||
auto newTabHighlightState = item->tab->highlightState();
|
||||
QString newTabTitle = "";
|
||||
if (item->tab->hasCustomTitle())
|
||||
{
|
||||
|
@ -213,7 +213,7 @@ void Notebook::duplicatePage(QWidget *page)
|
|||
|
||||
auto *tab =
|
||||
this->addPageAt(newContainer, newTabPosition, newTabTitle, false);
|
||||
tab->copyHighlightStateAndSourcesFrom(item->tab);
|
||||
tab->setHighlightState(newTabHighlightState);
|
||||
|
||||
newContainer->setTab(tab);
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ bool logInWithImplicitGrantCredentials(QWidget *parent, const QString &userID,
|
|||
errors.append("Missing OAuth Token");
|
||||
}
|
||||
|
||||
if (!errors.empty())
|
||||
if (errors.length() > 0)
|
||||
{
|
||||
QMessageBox messageBox(parent);
|
||||
messageBox.setWindowTitle("Invalid account credentials");
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include "Application.hpp"
|
||||
#include "common/Channel.hpp"
|
||||
#include "common/Literals.hpp"
|
||||
#include "common/network/NetworkRequest.hpp"
|
||||
#include "common/QLogging.hpp"
|
||||
#include "controllers/accounts/AccountController.hpp"
|
||||
|
@ -38,8 +37,6 @@
|
|||
|
||||
#include <QCheckBox>
|
||||
#include <QDesktopServices>
|
||||
#include <QMessageBox>
|
||||
#include <QMetaEnum>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QPointer>
|
||||
|
@ -144,8 +141,6 @@ int calculateTimeoutDuration(TimeoutButton timeout)
|
|||
|
||||
namespace chatterino {
|
||||
|
||||
using namespace literals;
|
||||
|
||||
UserInfoPopup::UserInfoPopup(bool closeAutomatically, Split *split)
|
||||
: DraggablePopup(closeAutomatically, split)
|
||||
, split_(split)
|
||||
|
@ -628,72 +623,57 @@ void UserInfoPopup::installEvents()
|
|||
return;
|
||||
}
|
||||
|
||||
if (newState == Qt::Unchecked)
|
||||
switch (newState)
|
||||
{
|
||||
this->ui_.block->setEnabled(false);
|
||||
case Qt::CheckState::Unchecked: {
|
||||
this->ui_.block->setEnabled(false);
|
||||
|
||||
getApp()->getAccounts()->twitch.getCurrent()->unblockUser(
|
||||
this->userId_, this,
|
||||
[this, reenableBlockCheckbox, currentUser] {
|
||||
this->channel_->addSystemMessage(
|
||||
QString("You successfully unblocked user %1")
|
||||
.arg(this->userName_));
|
||||
reenableBlockCheckbox();
|
||||
},
|
||||
[this, reenableBlockCheckbox] {
|
||||
this->channel_->addSystemMessage(
|
||||
QString("User %1 couldn't be unblocked, an unknown "
|
||||
getApp()->getAccounts()->twitch.getCurrent()->unblockUser(
|
||||
this->userId_, this,
|
||||
[this, reenableBlockCheckbox, currentUser] {
|
||||
this->channel_->addSystemMessage(
|
||||
QString("You successfully unblocked user %1")
|
||||
.arg(this->userName_));
|
||||
reenableBlockCheckbox();
|
||||
},
|
||||
[this, reenableBlockCheckbox] {
|
||||
this->channel_->addSystemMessage(
|
||||
QString(
|
||||
"User %1 couldn't be unblocked, an unknown "
|
||||
"error occurred!")
|
||||
.arg(this->userName_));
|
||||
reenableBlockCheckbox();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (newState == Qt::Checked)
|
||||
{
|
||||
this->ui_.block->setEnabled(false);
|
||||
|
||||
bool wasPinned = this->ensurePinned();
|
||||
auto btn = QMessageBox::warning(
|
||||
this, u"Blocking " % this->userName_,
|
||||
u"Blocking %1 can cause unintended side-effects like unfollowing.\n\n"_s
|
||||
"Are you sure you want to block %1?".arg(this->userName_),
|
||||
QMessageBox::Yes | QMessageBox::Cancel,
|
||||
QMessageBox::Cancel);
|
||||
if (wasPinned)
|
||||
{
|
||||
this->togglePinned();
|
||||
.arg(this->userName_));
|
||||
reenableBlockCheckbox();
|
||||
});
|
||||
}
|
||||
if (btn != QMessageBox::Yes)
|
||||
{
|
||||
reenableBlockCheckbox();
|
||||
QSignalBlocker blocker(this->ui_.block);
|
||||
this->ui_.block->setCheckState(Qt::Unchecked);
|
||||
return;
|
||||
break;
|
||||
|
||||
case Qt::CheckState::PartiallyChecked: {
|
||||
// We deliberately ignore this state
|
||||
}
|
||||
break;
|
||||
|
||||
getApp()->getAccounts()->twitch.getCurrent()->blockUser(
|
||||
this->userId_, this,
|
||||
[this, reenableBlockCheckbox, currentUser] {
|
||||
this->channel_->addSystemMessage(
|
||||
QString("You successfully blocked user %1")
|
||||
.arg(this->userName_));
|
||||
reenableBlockCheckbox();
|
||||
},
|
||||
[this, reenableBlockCheckbox] {
|
||||
this->channel_->addSystemMessage(
|
||||
QString("User %1 couldn't be blocked, an "
|
||||
"unknown error occurred!")
|
||||
.arg(this->userName_));
|
||||
reenableBlockCheckbox();
|
||||
});
|
||||
return;
|
||||
case Qt::CheckState::Checked: {
|
||||
this->ui_.block->setEnabled(false);
|
||||
|
||||
getApp()->getAccounts()->twitch.getCurrent()->blockUser(
|
||||
this->userId_, this,
|
||||
[this, reenableBlockCheckbox, currentUser] {
|
||||
this->channel_->addSystemMessage(
|
||||
QString("You successfully blocked user %1")
|
||||
.arg(this->userName_));
|
||||
reenableBlockCheckbox();
|
||||
},
|
||||
[this, reenableBlockCheckbox] {
|
||||
this->channel_->addSystemMessage(
|
||||
QString(
|
||||
"User %1 couldn't be blocked, an unknown "
|
||||
"error occurred!")
|
||||
.arg(this->userName_));
|
||||
reenableBlockCheckbox();
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
qCWarning(chatterinoWidget)
|
||||
<< "Unexpected check-state when blocking" << this->userName_
|
||||
<< QMetaEnum::fromType<Qt::CheckState>().valueToKey(newState);
|
||||
});
|
||||
|
||||
// ignore highlights
|
||||
|
|
|
@ -141,7 +141,7 @@ void QuickSwitcherPopup::updateSuggestions(const QString &text)
|
|||
* Timeout interval 0 means the call will be delayed until all window events
|
||||
* have been processed (cf. https://doc.qt.io/qt-5/qtimer.html#interval-prop).
|
||||
*/
|
||||
QTimer::singleShot(0, this, [this] {
|
||||
QTimer::singleShot(0, [this] {
|
||||
this->adjustSize();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -967,10 +967,10 @@ void ChannelView::setChannel(const ChannelPtr &underlyingChannel)
|
|||
|
||||
this->channelConnections_.managedConnect(
|
||||
underlyingChannel->messageReplaced,
|
||||
[this](auto index, const auto &prev, const auto &replacement) {
|
||||
[this](auto index, const auto &replacement) {
|
||||
if (this->shouldIncludeMessage(replacement))
|
||||
{
|
||||
this->channel_->replaceMessage(index, prev, replacement);
|
||||
this->channel_->replaceMessage(index, replacement);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1051,9 +1051,8 @@ void ChannelView::setChannel(const ChannelPtr &underlyingChannel)
|
|||
// on message replaced
|
||||
this->channelConnections_.managedConnect(
|
||||
this->channel_->messageReplaced,
|
||||
[this](size_t index, const MessagePtr &prev,
|
||||
const MessagePtr &replacement) {
|
||||
this->messageReplaced(index, prev, replacement);
|
||||
[this](size_t index, MessagePtr replacement) {
|
||||
this->messageReplaced(index, replacement);
|
||||
});
|
||||
|
||||
// on messages filled in
|
||||
|
@ -1064,8 +1063,6 @@ void ChannelView::setChannel(const ChannelPtr &underlyingChannel)
|
|||
|
||||
this->underlyingChannel_ = underlyingChannel;
|
||||
|
||||
this->updateID();
|
||||
|
||||
this->performLayout();
|
||||
this->queueUpdate();
|
||||
|
||||
|
@ -1084,8 +1081,6 @@ void ChannelView::setChannel(const ChannelPtr &underlyingChannel)
|
|||
void ChannelView::setFilters(const QList<QUuid> &ids)
|
||||
{
|
||||
this->channelFilters_ = std::make_shared<FilterSet>(ids);
|
||||
|
||||
this->updateID();
|
||||
}
|
||||
|
||||
QList<QUuid> ChannelView::getFilterIds() const
|
||||
|
@ -1263,21 +1258,19 @@ void ChannelView::messageAddedAtStart(std::vector<MessagePtr> &messages)
|
|||
this->queueLayout();
|
||||
}
|
||||
|
||||
void ChannelView::messageReplaced(size_t hint, const MessagePtr &prev,
|
||||
const MessagePtr &replacement)
|
||||
void ChannelView::messageReplaced(size_t index, MessagePtr &replacement)
|
||||
{
|
||||
auto optItem = this->messages_.find(hint, [&](const auto &it) {
|
||||
return it->getMessagePtr() == prev;
|
||||
});
|
||||
if (!optItem)
|
||||
auto oMessage = this->messages_.get(index);
|
||||
if (!oMessage)
|
||||
{
|
||||
return;
|
||||
}
|
||||
const auto &[index, oldItem] = *optItem;
|
||||
|
||||
auto message = *oMessage;
|
||||
|
||||
auto newItem = std::make_shared<MessageLayout>(replacement);
|
||||
|
||||
if (oldItem->flags.has(MessageLayoutFlag::AlternateBackground))
|
||||
if (message->flags.has(MessageLayoutFlag::AlternateBackground))
|
||||
{
|
||||
newItem->flags.set(MessageLayoutFlag::AlternateBackground);
|
||||
}
|
||||
|
@ -1285,7 +1278,7 @@ void ChannelView::messageReplaced(size_t hint, const MessagePtr &prev,
|
|||
this->scrollBar_->replaceHighlight(index,
|
||||
replacement->getScrollBarHighlight());
|
||||
|
||||
this->messages_.replaceItem(index, newItem);
|
||||
this->messages_.replaceItem(message, newItem);
|
||||
this->queueLayout();
|
||||
}
|
||||
|
||||
|
@ -3247,27 +3240,4 @@ void ChannelView::pendingLinkInfoStateChanged()
|
|||
this->tooltipWidget_->applyLastBoundsCheck();
|
||||
}
|
||||
|
||||
void ChannelView::updateID()
|
||||
{
|
||||
if (!this->underlyingChannel_)
|
||||
{
|
||||
// cannot update
|
||||
return;
|
||||
}
|
||||
|
||||
std::size_t seed = 0;
|
||||
auto first = qHash(this->underlyingChannel_->getName());
|
||||
auto second = qHash(this->getFilterIds());
|
||||
|
||||
boost::hash_combine(seed, first);
|
||||
boost::hash_combine(seed, second);
|
||||
|
||||
this->id_ = seed;
|
||||
}
|
||||
|
||||
ChannelView::ChannelViewID ChannelView::getID() const
|
||||
{
|
||||
return this->id_;
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -212,14 +212,6 @@ public:
|
|||
|
||||
Scrollbar *scrollbar();
|
||||
|
||||
using ChannelViewID = std::size_t;
|
||||
///
|
||||
/// \brief Get the ID of this ChannelView
|
||||
///
|
||||
/// The ID is made of the underlying channel's name
|
||||
/// combined with the filter set IDs
|
||||
ChannelViewID getID() const;
|
||||
|
||||
pajlada::Signals::Signal<QMouseEvent *> mouseDown;
|
||||
pajlada::Signals::NoArgSignal selectionChanged;
|
||||
pajlada::Signals::Signal<HighlightState> tabHighlightRequested;
|
||||
|
@ -276,8 +268,7 @@ private:
|
|||
std::optional<MessageFlags> overridingFlags);
|
||||
void messageAddedAtStart(std::vector<MessagePtr> &messages);
|
||||
void messageRemoveFromStart(MessagePtr &message);
|
||||
void messageReplaced(size_t hint, const MessagePtr &prev,
|
||||
const MessagePtr &replacement);
|
||||
void messageReplaced(size_t index, MessagePtr &replacement);
|
||||
void messagesUpdated();
|
||||
|
||||
void performLayout(bool causedByScrollbar = false,
|
||||
|
@ -323,9 +314,6 @@ private:
|
|||
void showReplyThreadPopup(const MessagePtr &message);
|
||||
bool canReplyToMessages() const;
|
||||
|
||||
void updateID();
|
||||
ChannelViewID id_{};
|
||||
|
||||
bool layoutQueued_ = false;
|
||||
bool bufferInvalidationQueued_ = false;
|
||||
|
||||
|
@ -387,7 +375,7 @@ private:
|
|||
FilterSetPtr channelFilters_;
|
||||
|
||||
// Returns true if message should be included
|
||||
bool shouldIncludeMessage(const MessagePtr &message) const;
|
||||
bool shouldIncludeMessage(const MessagePtr &m) const;
|
||||
|
||||
// Returns whether the scrollbar should have highlights
|
||||
bool showScrollbarHighlights() const;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#include "widgets/helper/NotebookTab.hpp"
|
||||
|
||||
#include "Application.hpp"
|
||||
#include "common/Channel.hpp"
|
||||
#include "common/Common.hpp"
|
||||
#include "controllers/hotkeys/HotkeyCategory.hpp"
|
||||
#include "controllers/hotkeys/HotkeyController.hpp"
|
||||
|
@ -13,11 +12,9 @@
|
|||
#include "widgets/dialogs/SettingsDialog.hpp"
|
||||
#include "widgets/Notebook.hpp"
|
||||
#include "widgets/splits/DraggedSplit.hpp"
|
||||
#include "widgets/splits/Split.hpp"
|
||||
#include "widgets/splits/SplitContainer.hpp"
|
||||
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/container_hash/hash.hpp>
|
||||
#include <QAbstractAnimation>
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
|
@ -305,134 +302,10 @@ bool NotebookTab::isSelected() const
|
|||
return this->selected_;
|
||||
}
|
||||
|
||||
void NotebookTab::removeHighlightStateChangeSources(
|
||||
const HighlightSources &toRemove)
|
||||
{
|
||||
for (const auto &[source, _] : toRemove)
|
||||
{
|
||||
this->removeHighlightSource(source);
|
||||
}
|
||||
}
|
||||
|
||||
void NotebookTab::removeHighlightSource(
|
||||
const ChannelView::ChannelViewID &source)
|
||||
{
|
||||
this->highlightSources_.erase(source);
|
||||
}
|
||||
|
||||
void NotebookTab::newHighlightSourceAdded(const ChannelView &channelViewSource)
|
||||
{
|
||||
auto channelViewId = channelViewSource.getID();
|
||||
this->removeHighlightSource(channelViewId);
|
||||
this->updateHighlightStateDueSourcesChange();
|
||||
|
||||
auto *splitNotebook = dynamic_cast<SplitNotebook *>(this->notebook_);
|
||||
if (splitNotebook)
|
||||
{
|
||||
for (int i = 0; i < splitNotebook->getPageCount(); ++i)
|
||||
{
|
||||
auto *splitContainer =
|
||||
dynamic_cast<SplitContainer *>(splitNotebook->getPageAt(i));
|
||||
if (splitContainer)
|
||||
{
|
||||
auto *tab = splitContainer->getTab();
|
||||
if (tab && tab != this)
|
||||
{
|
||||
tab->removeHighlightSource(channelViewId);
|
||||
tab->updateHighlightStateDueSourcesChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NotebookTab::updateHighlightStateDueSourcesChange()
|
||||
{
|
||||
if (std::ranges::any_of(this->highlightSources_, [](const auto &keyval) {
|
||||
return keyval.second == HighlightState::Highlighted;
|
||||
}))
|
||||
{
|
||||
assert(this->highlightState_ == HighlightState::Highlighted);
|
||||
return;
|
||||
}
|
||||
|
||||
if (std::ranges::any_of(this->highlightSources_, [](const auto &keyval) {
|
||||
return keyval.second == HighlightState::NewMessage;
|
||||
}))
|
||||
{
|
||||
if (this->highlightState_ != HighlightState::NewMessage)
|
||||
{
|
||||
this->highlightState_ = HighlightState::NewMessage;
|
||||
this->update();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this->highlightState_ != HighlightState::None)
|
||||
{
|
||||
this->highlightState_ = HighlightState::None;
|
||||
this->update();
|
||||
}
|
||||
}
|
||||
|
||||
assert(this->highlightState_ != HighlightState::Highlighted);
|
||||
}
|
||||
|
||||
void NotebookTab::copyHighlightStateAndSourcesFrom(const NotebookTab *sourceTab)
|
||||
{
|
||||
if (this->isSelected())
|
||||
{
|
||||
assert(this->highlightSources_.empty());
|
||||
assert(this->highlightState_ == HighlightState::None);
|
||||
return;
|
||||
}
|
||||
|
||||
this->highlightSources_ = sourceTab->highlightSources_;
|
||||
|
||||
if (!this->highlightEnabled_ &&
|
||||
sourceTab->highlightState_ == HighlightState::NewMessage)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->highlightState_ == sourceTab->highlightState_ ||
|
||||
this->highlightState_ == HighlightState::Highlighted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this->highlightState_ = sourceTab->highlightState_;
|
||||
this->update();
|
||||
}
|
||||
|
||||
void NotebookTab::setSelected(bool value)
|
||||
{
|
||||
this->selected_ = value;
|
||||
|
||||
if (value)
|
||||
{
|
||||
auto *splitNotebook = dynamic_cast<SplitNotebook *>(this->notebook_);
|
||||
if (splitNotebook)
|
||||
{
|
||||
for (int i = 0; i < splitNotebook->getPageCount(); ++i)
|
||||
{
|
||||
auto *splitContainer =
|
||||
dynamic_cast<SplitContainer *>(splitNotebook->getPageAt(i));
|
||||
if (splitContainer)
|
||||
{
|
||||
auto *tab = splitContainer->getTab();
|
||||
if (tab && tab != this)
|
||||
{
|
||||
tab->removeHighlightStateChangeSources(
|
||||
this->highlightSources_);
|
||||
tab->updateHighlightStateDueSourcesChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this->highlightSources_.clear();
|
||||
this->highlightState_ = HighlightState::None;
|
||||
|
||||
this->update();
|
||||
|
@ -485,22 +358,13 @@ bool NotebookTab::isLive() const
|
|||
return this->isLive_;
|
||||
}
|
||||
|
||||
HighlightState NotebookTab::highlightState() const
|
||||
{
|
||||
return this->highlightState_;
|
||||
}
|
||||
|
||||
void NotebookTab::setHighlightState(HighlightState newHighlightStyle)
|
||||
{
|
||||
if (this->isSelected())
|
||||
{
|
||||
assert(this->highlightSources_.empty());
|
||||
assert(this->highlightState_ == HighlightState::None);
|
||||
return;
|
||||
}
|
||||
|
||||
this->highlightSources_.clear();
|
||||
|
||||
if (!this->highlightEnabled_ &&
|
||||
newHighlightStyle == HighlightState::NewMessage)
|
||||
{
|
||||
|
@ -517,79 +381,9 @@ void NotebookTab::setHighlightState(HighlightState newHighlightStyle)
|
|||
this->update();
|
||||
}
|
||||
|
||||
void NotebookTab::updateHighlightState(HighlightState newHighlightStyle,
|
||||
const ChannelView &channelViewSource)
|
||||
HighlightState NotebookTab::highlightState() const
|
||||
{
|
||||
if (this->isSelected())
|
||||
{
|
||||
assert(this->highlightSources_.empty());
|
||||
assert(this->highlightState_ == HighlightState::None);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this->shouldMessageHighlight(channelViewSource))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this->highlightEnabled_ &&
|
||||
newHighlightStyle == HighlightState::NewMessage)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// message is highlighting unvisible tab
|
||||
|
||||
auto channelViewId = channelViewSource.getID();
|
||||
|
||||
switch (newHighlightStyle)
|
||||
{
|
||||
case HighlightState::Highlighted:
|
||||
// override lower states
|
||||
this->highlightSources_.insert_or_assign(channelViewId,
|
||||
newHighlightStyle);
|
||||
case HighlightState::NewMessage: {
|
||||
// only insert if no state already there to avoid overriding
|
||||
if (!this->highlightSources_.contains(channelViewId))
|
||||
{
|
||||
this->highlightSources_.emplace(channelViewId,
|
||||
newHighlightStyle);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case HighlightState::None:
|
||||
break;
|
||||
}
|
||||
|
||||
if (this->highlightState_ == newHighlightStyle ||
|
||||
this->highlightState_ == HighlightState::Highlighted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this->highlightState_ = newHighlightStyle;
|
||||
this->update();
|
||||
}
|
||||
|
||||
bool NotebookTab::shouldMessageHighlight(
|
||||
const ChannelView &channelViewSource) const
|
||||
{
|
||||
auto *visibleSplitContainer =
|
||||
dynamic_cast<SplitContainer *>(this->notebook_->getSelectedPage());
|
||||
if (visibleSplitContainer != nullptr)
|
||||
{
|
||||
const auto &visibleSplits = visibleSplitContainer->getSplits();
|
||||
for (const auto &visibleSplit : visibleSplits)
|
||||
{
|
||||
if (channelViewSource.getID() ==
|
||||
visibleSplit->getChannelView().getID())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return this->highlightState_;
|
||||
}
|
||||
|
||||
void NotebookTab::setHighlightsEnabled(const bool &newVal)
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include "common/Common.hpp"
|
||||
#include "widgets/helper/Button.hpp"
|
||||
#include "widgets/helper/ChannelView.hpp"
|
||||
#include "widgets/Notebook.hpp"
|
||||
|
||||
#include <pajlada/settings/setting.hpp>
|
||||
|
@ -60,25 +59,12 @@ public:
|
|||
**/
|
||||
bool isLive() const;
|
||||
|
||||
/**
|
||||
* @brief Sets the highlight state of this tab clearing highlight sources
|
||||
*
|
||||
* Obeys the HighlightsEnabled setting and highlight states hierarchy
|
||||
*/
|
||||
void setHighlightState(HighlightState style);
|
||||
/**
|
||||
* @brief Updates the highlight state and highlight sources of this tab
|
||||
*
|
||||
* Obeys the HighlightsEnabled setting and the highlight state hierarchy and tracks the highlight state update sources
|
||||
*/
|
||||
void updateHighlightState(HighlightState style,
|
||||
const ChannelView &channelViewSource);
|
||||
void copyHighlightStateAndSourcesFrom(const NotebookTab *sourceTab);
|
||||
void setHighlightsEnabled(const bool &newVal);
|
||||
void newHighlightSourceAdded(const ChannelView &channelViewSource);
|
||||
bool hasHighlightsEnabled() const;
|
||||
HighlightState highlightState() const;
|
||||
|
||||
void setHighlightsEnabled(const bool &newVal);
|
||||
bool hasHighlightsEnabled() const;
|
||||
|
||||
void moveAnimated(QPoint targetPos, bool animated = true);
|
||||
|
||||
QRect getDesiredRect() const;
|
||||
|
@ -121,16 +107,6 @@ private:
|
|||
|
||||
int normalTabWidthForHeight(int height) const;
|
||||
|
||||
bool shouldMessageHighlight(const ChannelView &channelViewSource) const;
|
||||
|
||||
using HighlightSources =
|
||||
std::unordered_map<ChannelView::ChannelViewID, HighlightState>;
|
||||
HighlightSources highlightSources_;
|
||||
|
||||
void removeHighlightStateChangeSources(const HighlightSources &toRemove);
|
||||
void removeHighlightSource(const ChannelView::ChannelViewID &source);
|
||||
void updateHighlightStateDueSourcesChange();
|
||||
|
||||
QPropertyAnimation positionChangedAnimation_;
|
||||
QPoint positionAnimationDesiredPoint_;
|
||||
|
||||
|
|
|
@ -614,16 +614,12 @@ void GeneralPage::initLayout(GeneralPageView &layout)
|
|||
"Google",
|
||||
},
|
||||
s.emojiSet);
|
||||
layout.addCheckbox("Show BetterTTV global emotes",
|
||||
s.enableBTTVGlobalEmotes);
|
||||
layout.addCheckbox("Show BetterTTV channel emotes",
|
||||
s.enableBTTVChannelEmotes);
|
||||
layout.addCheckbox("Enable BetterTTV live emote updates (requires restart)",
|
||||
layout.addCheckbox("Show BTTV global emotes", s.enableBTTVGlobalEmotes);
|
||||
layout.addCheckbox("Show BTTV channel emotes", s.enableBTTVChannelEmotes);
|
||||
layout.addCheckbox("Enable BTTV live emote updates (requires restart)",
|
||||
s.enableBTTVLiveUpdates);
|
||||
layout.addCheckbox("Show FrankerFaceZ global emotes",
|
||||
s.enableFFZGlobalEmotes);
|
||||
layout.addCheckbox("Show FrankerFaceZ channel emotes",
|
||||
s.enableFFZChannelEmotes);
|
||||
layout.addCheckbox("Show FFZ global emotes", s.enableFFZGlobalEmotes);
|
||||
layout.addCheckbox("Show FFZ channel emotes", s.enableFFZChannelEmotes);
|
||||
layout.addCheckbox("Show 7TV global emotes", s.enableSevenTVGlobalEmotes);
|
||||
layout.addCheckbox("Show 7TV channel emotes", s.enableSevenTVChannelEmotes);
|
||||
layout.addCheckbox("Enable 7TV live emote updates (requires restart)",
|
||||
|
@ -1171,14 +1167,6 @@ void GeneralPage::initLayout(GeneralPageView &layout)
|
|||
layout.addIntInput("Usercard scrollback limit (requires restart)",
|
||||
s.scrollbackUsercardLimit, 100, 100000, 100);
|
||||
|
||||
layout.addDropdownEnumClass<ShowModerationState>(
|
||||
"Show blocked term automod messages",
|
||||
qmagicenum::enumNames<ShowModerationState>(),
|
||||
s.showBlockedTermAutomodMessages,
|
||||
"Show messages that are blocked by AutoMod for containing a public "
|
||||
"blocked term in the current channel.",
|
||||
{});
|
||||
|
||||
layout.addDropdown<int>(
|
||||
"Stack timeouts", {"Stack", "Stack until timeout", "Don't stack"},
|
||||
s.timeoutStackStyle,
|
||||
|
|
|
@ -214,21 +214,13 @@ void SplitContainer::addSplit(Split *split)
|
|||
auto &&conns = this->connectionsPerSplit_[split];
|
||||
|
||||
conns.managedConnect(split->getChannelView().tabHighlightRequested,
|
||||
[this, split](HighlightState state) {
|
||||
[this](HighlightState state) {
|
||||
if (this->tab_ != nullptr)
|
||||
{
|
||||
this->tab_->updateHighlightState(
|
||||
state, split->getChannelView());
|
||||
this->tab_->setHighlightState(state);
|
||||
}
|
||||
});
|
||||
|
||||
conns.managedConnect(split->channelChanged, [this, split] {
|
||||
if (this->tab_ != nullptr)
|
||||
{
|
||||
this->tab_->newHighlightSourceAdded(split->getChannelView());
|
||||
}
|
||||
});
|
||||
|
||||
conns.managedConnect(split->getChannelView().liveStatusChanged, [this]() {
|
||||
this->refreshTabLiveStatus();
|
||||
});
|
||||
|
|
|
@ -180,7 +180,6 @@
|
|||
}
|
||||
],
|
||||
"flags": "Collapsed|Subscription",
|
||||
"highlightColor": "#64c466ff",
|
||||
"id": "8c26e1ab-b50c-4d9d-bc11-3fd57a941d90",
|
||||
"localizedName": "",
|
||||
"loginName": "supinic",
|
||||
|
|
|
@ -38,9 +38,8 @@
|
|||
"type": "TimestampElement"
|
||||
},
|
||||
{
|
||||
"color": "Text",
|
||||
"fallbackColor": "System",
|
||||
"flags": "Text|Mention",
|
||||
"color": "System",
|
||||
"flags": "Text",
|
||||
"link": {
|
||||
"type": "None",
|
||||
"value": ""
|
||||
|
@ -48,9 +47,7 @@
|
|||
"style": "ChatMedium",
|
||||
"tooltip": "",
|
||||
"trailingSpace": true,
|
||||
"type": "MentionElement",
|
||||
"userColor": "#ffff4500",
|
||||
"userLoginName": "whoopiix",
|
||||
"type": "TextElement",
|
||||
"words": [
|
||||
"whoopiix"
|
||||
]
|
||||
|
|
|
@ -80,7 +80,7 @@
|
|||
"trailingSpace": true,
|
||||
"type": "SingleLineTextElement",
|
||||
"words": [
|
||||
"b"
|
||||
"a"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -169,7 +169,6 @@
|
|||
"localizedName": "",
|
||||
"loginName": "nerixyz",
|
||||
"messageText": "c",
|
||||
"replyParent": "474f19ab-a1b0-410a-877a-5b0e2ae8be6d",
|
||||
"replyThread": {
|
||||
"replies": [
|
||||
"474f19ab-a1b0-410a-877a-5b0e2ae8be6d",
|
||||
|
|
|
@ -256,7 +256,6 @@
|
|||
}
|
||||
],
|
||||
"flags": "Collapsed|Subscription|SharedMessage",
|
||||
"highlightColor": "#64c466ff",
|
||||
"id": "01cd601f-bc3f-49d5-ab4b-136fa9d6ec22",
|
||||
"localizedName": "",
|
||||
"loginName": "lahoooo",
|
||||
|
|
|
@ -38,9 +38,8 @@
|
|||
"type": "TimestampElement"
|
||||
},
|
||||
{
|
||||
"color": "Text",
|
||||
"fallbackColor": "System",
|
||||
"flags": "Text|Mention",
|
||||
"color": "System",
|
||||
"flags": "Text",
|
||||
"link": {
|
||||
"type": "None",
|
||||
"value": ""
|
||||
|
@ -48,9 +47,7 @@
|
|||
"style": "ChatMedium",
|
||||
"tooltip": "",
|
||||
"trailingSpace": true,
|
||||
"type": "MentionElement",
|
||||
"userColor": "#ff00ff7f",
|
||||
"userLoginName": "hyperbolicxd",
|
||||
"type": "TextElement",
|
||||
"words": [
|
||||
"hyperbolicxd"
|
||||
]
|
||||
|
@ -145,24 +142,6 @@
|
|||
"to"
|
||||
]
|
||||
},
|
||||
{
|
||||
"color": "Text",
|
||||
"fallbackColor": "System",
|
||||
"flags": "Text|Mention",
|
||||
"link": {
|
||||
"type": "None",
|
||||
"value": ""
|
||||
},
|
||||
"style": "ChatMedium",
|
||||
"tooltip": "",
|
||||
"trailingSpace": false,
|
||||
"type": "MentionElement",
|
||||
"userColor": "System",
|
||||
"userLoginName": "quote_if_nam",
|
||||
"words": [
|
||||
"quote_if_nam"
|
||||
]
|
||||
},
|
||||
{
|
||||
"color": "System",
|
||||
"flags": "Text",
|
||||
|
@ -175,7 +154,7 @@
|
|||
"trailingSpace": true,
|
||||
"type": "TextElement",
|
||||
"words": [
|
||||
"!"
|
||||
"quote_if_nam!"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
@ -38,9 +38,8 @@
|
|||
"type": "TimestampElement"
|
||||
},
|
||||
{
|
||||
"color": "Text",
|
||||
"fallbackColor": "System",
|
||||
"flags": "Text|Mention",
|
||||
"color": "System",
|
||||
"flags": "Text",
|
||||
"link": {
|
||||
"type": "None",
|
||||
"value": ""
|
||||
|
@ -48,9 +47,7 @@
|
|||
"style": "ChatMedium",
|
||||
"tooltip": "",
|
||||
"trailingSpace": true,
|
||||
"type": "MentionElement",
|
||||
"userColor": "#ff0000ff",
|
||||
"userLoginName": "byebyeheart",
|
||||
"type": "TextElement",
|
||||
"words": [
|
||||
"byebyeheart"
|
||||
]
|
||||
|
|
|
@ -38,9 +38,8 @@
|
|||
"type": "TimestampElement"
|
||||
},
|
||||
{
|
||||
"color": "Text",
|
||||
"fallbackColor": "System",
|
||||
"flags": "Text|Mention",
|
||||
"color": "System",
|
||||
"flags": "Text",
|
||||
"link": {
|
||||
"type": "None",
|
||||
"value": ""
|
||||
|
@ -48,9 +47,7 @@
|
|||
"style": "ChatMedium",
|
||||
"tooltip": "",
|
||||
"trailingSpace": true,
|
||||
"type": "MentionElement",
|
||||
"userColor": "#ff0000ff",
|
||||
"userLoginName": "tww2",
|
||||
"type": "TextElement",
|
||||
"words": [
|
||||
"TWW2"
|
||||
]
|
||||
|
@ -145,24 +142,6 @@
|
|||
"to"
|
||||
]
|
||||
},
|
||||
{
|
||||
"color": "Text",
|
||||
"fallbackColor": "System",
|
||||
"flags": "Text|Mention",
|
||||
"link": {
|
||||
"type": "None",
|
||||
"value": ""
|
||||
},
|
||||
"style": "ChatMedium",
|
||||
"tooltip": "",
|
||||
"trailingSpace": false,
|
||||
"type": "MentionElement",
|
||||
"userColor": "System",
|
||||
"userLoginName": "mr_woodchuck",
|
||||
"words": [
|
||||
"Mr_Woodchuck"
|
||||
]
|
||||
},
|
||||
{
|
||||
"color": "System",
|
||||
"flags": "Text",
|
||||
|
@ -175,7 +154,7 @@
|
|||
"trailingSpace": true,
|
||||
"type": "TextElement",
|
||||
"words": [
|
||||
"!"
|
||||
"Mr_Woodchuck!"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
|
|
@ -243,7 +243,6 @@
|
|||
}
|
||||
],
|
||||
"flags": "Collapsed|Subscription",
|
||||
"highlightColor": "#64c466ff",
|
||||
"id": "db25007f-7a18-43eb-9379-80131e44d633",
|
||||
"localizedName": "",
|
||||
"loginName": "ronni",
|
||||
|
@ -290,9 +289,8 @@
|
|||
"type": "TimestampElement"
|
||||
},
|
||||
{
|
||||
"color": "Text",
|
||||
"fallbackColor": "System",
|
||||
"flags": "Text|Mention",
|
||||
"color": "System",
|
||||
"flags": "Text",
|
||||
"link": {
|
||||
"type": "None",
|
||||
"value": ""
|
||||
|
@ -300,9 +298,7 @@
|
|||
"style": "ChatMedium",
|
||||
"tooltip": "",
|
||||
"trailingSpace": true,
|
||||
"type": "MentionElement",
|
||||
"userColor": "#ff008000",
|
||||
"userLoginName": "ronni",
|
||||
"type": "TextElement",
|
||||
"words": [
|
||||
"ronni"
|
||||
]
|
||||
|
|
|
@ -217,24 +217,6 @@
|
|||
"to"
|
||||
]
|
||||
},
|
||||
{
|
||||
"color": "Text",
|
||||
"fallbackColor": "System",
|
||||
"flags": "Text|Mention",
|
||||
"link": {
|
||||
"type": "None",
|
||||
"value": ""
|
||||
},
|
||||
"style": "ChatMedium",
|
||||
"tooltip": "",
|
||||
"trailingSpace": false,
|
||||
"type": "MentionElement",
|
||||
"userColor": "System",
|
||||
"userLoginName": "mohammadrezadh",
|
||||
"words": [
|
||||
"MohammadrezaDH"
|
||||
]
|
||||
},
|
||||
{
|
||||
"color": "System",
|
||||
"flags": "Text",
|
||||
|
@ -247,7 +229,7 @@
|
|||
"trailingSpace": true,
|
||||
"type": "TextElement",
|
||||
"words": [
|
||||
"!"
|
||||
"MohammadrezaDH!"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
|
|
@ -38,9 +38,8 @@
|
|||
"type": "TimestampElement"
|
||||
},
|
||||
{
|
||||
"color": "Text",
|
||||
"fallbackColor": "System",
|
||||
"flags": "Text|Mention",
|
||||
"color": "System",
|
||||
"flags": "Text",
|
||||
"link": {
|
||||
"type": "None",
|
||||
"value": ""
|
||||
|
@ -48,9 +47,7 @@
|
|||
"style": "ChatMedium",
|
||||
"tooltip": "",
|
||||
"trailingSpace": true,
|
||||
"type": "MentionElement",
|
||||
"userColor": "#ffff8ea3",
|
||||
"userLoginName": "inatsufn",
|
||||
"type": "TextElement",
|
||||
"words": [
|
||||
"iNatsuFN"
|
||||
]
|
||||
|
@ -190,24 +187,6 @@
|
|||
"to"
|
||||
]
|
||||
},
|
||||
{
|
||||
"color": "Text",
|
||||
"fallbackColor": "System",
|
||||
"flags": "Text|Mention",
|
||||
"link": {
|
||||
"type": "None",
|
||||
"value": ""
|
||||
},
|
||||
"style": "ChatMedium",
|
||||
"tooltip": "",
|
||||
"trailingSpace": false,
|
||||
"type": "MentionElement",
|
||||
"userColor": "System",
|
||||
"userLoginName": "kimmi_tm",
|
||||
"words": [
|
||||
"kimmi_tm"
|
||||
]
|
||||
},
|
||||
{
|
||||
"color": "System",
|
||||
"flags": "Text",
|
||||
|
@ -220,7 +199,7 @@
|
|||
"trailingSpace": true,
|
||||
"type": "TextElement",
|
||||
"words": [
|
||||
"!"
|
||||
"kimmi_tm!"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
@ -38,9 +38,8 @@
|
|||
"type": "TimestampElement"
|
||||
},
|
||||
{
|
||||
"color": "Text",
|
||||
"fallbackColor": "System",
|
||||
"flags": "Text|Mention",
|
||||
"color": "System",
|
||||
"flags": "Text",
|
||||
"link": {
|
||||
"type": "None",
|
||||
"value": ""
|
||||
|
@ -48,9 +47,7 @@
|
|||
"style": "ChatMedium",
|
||||
"tooltip": "",
|
||||
"trailingSpace": true,
|
||||
"type": "MentionElement",
|
||||
"userColor": "#ffeb078d",
|
||||
"userLoginName": "lucidfoxx",
|
||||
"type": "TextElement",
|
||||
"words": [
|
||||
"Lucidfoxx"
|
||||
]
|
||||
|
@ -190,24 +187,6 @@
|
|||
"to"
|
||||
]
|
||||
},
|
||||
{
|
||||
"color": "Text",
|
||||
"fallbackColor": "System",
|
||||
"flags": "Text|Mention",
|
||||
"link": {
|
||||
"type": "None",
|
||||
"value": ""
|
||||
},
|
||||
"style": "ChatMedium",
|
||||
"tooltip": "",
|
||||
"trailingSpace": false,
|
||||
"type": "MentionElement",
|
||||
"userColor": "System",
|
||||
"userLoginName": "ogprodigy",
|
||||
"words": [
|
||||
"OGprodigy"
|
||||
]
|
||||
},
|
||||
{
|
||||
"color": "System",
|
||||
"flags": "Text",
|
||||
|
@ -220,7 +199,7 @@
|
|||
"trailingSpace": true,
|
||||
"type": "TextElement",
|
||||
"words": [
|
||||
"!"
|
||||
"OGprodigy!"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
|
|
@ -38,9 +38,8 @@
|
|||
"type": "TimestampElement"
|
||||
},
|
||||
{
|
||||
"color": "Text",
|
||||
"fallbackColor": "System",
|
||||
"flags": "Text|Mention",
|
||||
"color": "System",
|
||||
"flags": "Text",
|
||||
"link": {
|
||||
"type": "None",
|
||||
"value": ""
|
||||
|
@ -48,9 +47,7 @@
|
|||
"style": "ChatMedium",
|
||||
"tooltip": "",
|
||||
"trailingSpace": true,
|
||||
"type": "MentionElement",
|
||||
"userColor": "#ff0000ff",
|
||||
"userLoginName": "calm__like_a_tom",
|
||||
"type": "TextElement",
|
||||
"words": [
|
||||
"calm__like_a_tom"
|
||||
]
|
||||
|
|
|
@ -38,9 +38,8 @@
|
|||
"type": "TimestampElement"
|
||||
},
|
||||
{
|
||||
"color": "Text",
|
||||
"fallbackColor": "System",
|
||||
"flags": "Text|Mention",
|
||||
"color": "System",
|
||||
"flags": "Text",
|
||||
"link": {
|
||||
"type": "None",
|
||||
"value": ""
|
||||
|
@ -48,9 +47,7 @@
|
|||
"style": "ChatMedium",
|
||||
"tooltip": "",
|
||||
"trailingSpace": true,
|
||||
"type": "MentionElement",
|
||||
"userColor": "System",
|
||||
"userLoginName": "foly__",
|
||||
"type": "TextElement",
|
||||
"words": [
|
||||
"foly__"
|
||||
]
|
||||
|
|
|
@ -38,9 +38,8 @@
|
|||
"type": "TimestampElement"
|
||||
},
|
||||
{
|
||||
"color": "Text",
|
||||
"fallbackColor": "System",
|
||||
"flags": "Text|Mention",
|
||||
"color": "System",
|
||||
"flags": "Text",
|
||||
"link": {
|
||||
"type": "None",
|
||||
"value": ""
|
||||
|
@ -48,9 +47,7 @@
|
|||
"style": "ChatMedium",
|
||||
"tooltip": "",
|
||||
"trailingSpace": true,
|
||||
"type": "MentionElement",
|
||||
"userColor": "#ffcc00c2",
|
||||
"userLoginName": "cspice",
|
||||
"type": "TextElement",
|
||||
"words": [
|
||||
"cspice"
|
||||
]
|
||||
|
@ -161,9 +158,8 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"color": "Text",
|
||||
"fallbackColor": "System",
|
||||
"flags": "Text|Mention",
|
||||
"color": "System",
|
||||
"flags": "Text",
|
||||
"link": {
|
||||
"type": "None",
|
||||
"value": ""
|
||||
|
@ -171,9 +167,7 @@
|
|||
"style": "ChatMedium",
|
||||
"tooltip": "",
|
||||
"trailingSpace": true,
|
||||
"type": "MentionElement",
|
||||
"userColor": "#ffcc00c2",
|
||||
"userLoginName": "cspice",
|
||||
"type": "TextElement",
|
||||
"words": [
|
||||
"cspice"
|
||||
]
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include "singletons/Emotes.hpp"
|
||||
#include "Test.hpp"
|
||||
#include "util/IrcHelpers.hpp"
|
||||
#include "util/VectorMessageSink.hpp"
|
||||
|
||||
#include <IrcConnection>
|
||||
#include <QDebug>
|
||||
|
@ -573,14 +572,19 @@ TEST_P(TestIrcMessageHandlerP, Run)
|
|||
{
|
||||
auto channel = makeMockTwitchChannel(u"pajlada"_s, *snapshot);
|
||||
|
||||
VectorMessageSink sink;
|
||||
std::vector<MessagePtr> prevMessages;
|
||||
|
||||
for (auto prevInput : snapshot->param("prevMessages").toArray())
|
||||
{
|
||||
auto *ircMessage = Communi::IrcMessage::fromData(
|
||||
prevInput.toString().toUtf8(), nullptr);
|
||||
ASSERT_NE(ircMessage, nullptr);
|
||||
IrcMessageHandler::parseMessageInto(ircMessage, sink, channel.get());
|
||||
auto builtMessages = IrcMessageHandler::parseMessageWithReply(
|
||||
channel.get(), ircMessage, prevMessages);
|
||||
for (const auto &builtMessage : builtMessages)
|
||||
{
|
||||
prevMessages.emplace_back(builtMessage);
|
||||
}
|
||||
delete ircMessage;
|
||||
}
|
||||
|
||||
|
@ -588,13 +592,13 @@ TEST_P(TestIrcMessageHandlerP, Run)
|
|||
Communi::IrcMessage::fromData(snapshot->inputUtf8(), nullptr);
|
||||
ASSERT_NE(ircMessage, nullptr);
|
||||
|
||||
auto firstAddedMsg = sink.messages().size();
|
||||
IrcMessageHandler::parseMessageInto(ircMessage, sink, channel.get());
|
||||
auto builtMessages = IrcMessageHandler::parseMessageWithReply(
|
||||
channel.get(), ircMessage, prevMessages);
|
||||
|
||||
QJsonArray got;
|
||||
for (auto i = firstAddedMsg; i < sink.messages().size(); i++)
|
||||
for (const auto &msg : builtMessages)
|
||||
{
|
||||
got.append(sink.messages()[i]->toJson());
|
||||
got.append(msg->toJson());
|
||||
}
|
||||
|
||||
delete ircMessage;
|
||||
|
|
|
@ -114,153 +114,20 @@ TEST(LimitedQueue, PushFront)
|
|||
|
||||
TEST(LimitedQueue, ReplaceItem)
|
||||
{
|
||||
LimitedQueue<int> queue(10);
|
||||
LimitedQueue<int> queue(5);
|
||||
queue.pushBack(1);
|
||||
queue.pushBack(2);
|
||||
queue.pushBack(3);
|
||||
queue.pushBack(4);
|
||||
queue.pushBack(5);
|
||||
queue.pushBack(6);
|
||||
|
||||
int idex = queue.replaceItem(2, 10);
|
||||
EXPECT_EQ(idex, 1);
|
||||
idex = queue.replaceItem(7, 11);
|
||||
idex = queue.replaceItem(5, 11);
|
||||
EXPECT_EQ(idex, -1);
|
||||
|
||||
int prev = -1;
|
||||
bool res = queue.replaceItem(std::size_t(0), 9, &prev);
|
||||
bool res = queue.replaceItem(std::size_t(0), 9);
|
||||
EXPECT_TRUE(res);
|
||||
EXPECT_EQ(prev, 1);
|
||||
res = queue.replaceItem(std::size_t(6), 4);
|
||||
res = queue.replaceItem(std::size_t(5), 4);
|
||||
EXPECT_FALSE(res);
|
||||
|
||||
// correct hint
|
||||
EXPECT_EQ(queue.replaceItem(3, 4, 11), 3);
|
||||
// incorrect hints
|
||||
EXPECT_EQ(queue.replaceItem(5, 11, 12), 3);
|
||||
EXPECT_EQ(queue.replaceItem(0, 12, 13), 3);
|
||||
// oob hint
|
||||
EXPECT_EQ(queue.replaceItem(42, 13, 14), 3);
|
||||
// bad needle
|
||||
EXPECT_EQ(queue.replaceItem(0, 15, 16), -1);
|
||||
|
||||
SNAPSHOT_EQUALS(queue.getSnapshot(), {9, 10, 3, 14, 5, 6},
|
||||
"first snapshot");
|
||||
}
|
||||
|
||||
TEST(LimitedQueue, Find)
|
||||
{
|
||||
LimitedQueue<int> queue(10);
|
||||
queue.pushBack(1);
|
||||
queue.pushBack(2);
|
||||
queue.pushBack(3);
|
||||
queue.pushBack(4);
|
||||
queue.pushBack(5);
|
||||
queue.pushBack(6);
|
||||
|
||||
// without hint
|
||||
EXPECT_FALSE(queue
|
||||
.find([](int i) {
|
||||
return i == 0;
|
||||
})
|
||||
.has_value());
|
||||
EXPECT_EQ(queue
|
||||
.find([](int i) {
|
||||
return i == 1;
|
||||
})
|
||||
.value(),
|
||||
1);
|
||||
EXPECT_EQ(queue
|
||||
.find([](int i) {
|
||||
return i == 2;
|
||||
})
|
||||
.value(),
|
||||
2);
|
||||
EXPECT_EQ(queue
|
||||
.find([](int i) {
|
||||
return i == 6;
|
||||
})
|
||||
.value(),
|
||||
6);
|
||||
EXPECT_FALSE(queue
|
||||
.find([](int i) {
|
||||
return i == 7;
|
||||
})
|
||||
.has_value());
|
||||
EXPECT_FALSE(queue
|
||||
.find([](int i) {
|
||||
return i > 6;
|
||||
})
|
||||
.has_value());
|
||||
EXPECT_FALSE(queue
|
||||
.find([](int i) {
|
||||
return i <= 0;
|
||||
})
|
||||
.has_value());
|
||||
|
||||
using Pair = std::pair<size_t, int>;
|
||||
// with hint
|
||||
EXPECT_FALSE(queue
|
||||
.find(0,
|
||||
[](int i) {
|
||||
return i == 0;
|
||||
})
|
||||
.has_value());
|
||||
// correct hint
|
||||
EXPECT_EQ(queue
|
||||
.find(0,
|
||||
[](int i) {
|
||||
return i == 1;
|
||||
})
|
||||
.value(),
|
||||
(Pair{0, 1}));
|
||||
EXPECT_EQ(queue
|
||||
.find(1,
|
||||
[](int i) {
|
||||
return i == 2;
|
||||
})
|
||||
.value(),
|
||||
(Pair{1, 2}));
|
||||
// incorrect hint
|
||||
EXPECT_EQ(queue
|
||||
.find(1,
|
||||
[](int i) {
|
||||
return i == 1;
|
||||
})
|
||||
.value(),
|
||||
(Pair{0, 1}));
|
||||
EXPECT_EQ(queue
|
||||
.find(5,
|
||||
[](int i) {
|
||||
return i == 6;
|
||||
})
|
||||
.value(),
|
||||
(Pair{5, 6}));
|
||||
// oob hint
|
||||
EXPECT_EQ(queue
|
||||
.find(6,
|
||||
[](int i) {
|
||||
return i == 3;
|
||||
})
|
||||
.value(),
|
||||
(Pair{2, 3}));
|
||||
// non-existent items
|
||||
EXPECT_FALSE(queue
|
||||
.find(42,
|
||||
[](int i) {
|
||||
return i == 7;
|
||||
})
|
||||
.has_value());
|
||||
EXPECT_FALSE(queue
|
||||
.find(0,
|
||||
[](int i) {
|
||||
return i > 6;
|
||||
})
|
||||
.has_value());
|
||||
EXPECT_FALSE(queue
|
||||
.find(0,
|
||||
[](int i) {
|
||||
return i <= 0;
|
||||
})
|
||||
.has_value());
|
||||
SNAPSHOT_EQUALS(queue.getSnapshot(), {9, 10, 3}, "first snapshot");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue