Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into chatterino7
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerixyz committed Nov 2, 2024
2 parents a787590 + db8047e commit 7c3f930
Show file tree
Hide file tree
Showing 33 changed files with 1,219 additions and 862 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
- Minor: Indicate when subscriptions and resubscriptions are for multiple months. (#5642)
- Minor: Proxy URL information is now included in the `/debug-env` command. (#5648)
- Minor: Make raid entry message usernames clickable. (#5651)
- Minor: Tabs unhighlight when their content is read in other tabs. (#5649)
- Bugfix: Fixed tab move animation occasionally failing to start after closing a tab. (#5426, #5612)
- Bugfix: If a network request errors with 200 OK, Qt's error code is now reported instead of the HTTP status. (#5378)
- Bugfix: Fixed restricted users usernames not being clickable. (#5405)
Expand All @@ -63,6 +64,7 @@
- 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)
- 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)
Expand All @@ -75,7 +77,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)
- Dev: All Lua globals now show in the `c2` global in the LuaLS metadata. (#5385, #5682)
- 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)
Expand Down Expand Up @@ -110,11 +112,12 @@
- 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)
- Dev: Move plugins to Sol2. (#5622, #5682)
- 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)

## 2.5.1

Expand Down
115 changes: 61 additions & 54 deletions docs/plugin-meta.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
-- Add the folder this file is in to "Lua.workspace.library".

c2 = {}
---@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 = {}
---@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
}

-- Begin src/controllers/plugins/api/EventType.hpp

---@alias c2.EventType.CompletionRequested "c2.EventType.CompletionRequested"
---@alias c2.EventType c2.EventType.CompletionRequested
---@type { CompletionRequested: c2.EventType.CompletionRequested }
c2.EventType = {}
---@enum c2.EventType
c2.EventType = {
CompletionRequested = {}, ---@type c2.EventType.CompletionRequested
}

-- End src/controllers/plugins/api/EventType.hpp

Expand All @@ -38,19 +38,19 @@ c2.EventType = {}

-- Begin src/common/Channel.hpp

---@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 = {}
---@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
}

-- End src/common/Channel.hpp

Expand Down Expand Up @@ -174,90 +174,97 @@ function c2.Channel.by_twitch_id(id) end

-- Begin src/controllers/plugins/api/HTTPResponse.hpp

---@class HTTPResponse
HTTPResponse = {}
---@class c2.HTTPResponse
c2.HTTPResponse = {}

--- Returns the data. This is not guaranteed to be encoded using any
--- particular encoding scheme. It's just the bytes the server returned.
---
function HTTPResponse:data() end
---@return string
---@nodiscard
function c2.HTTPResponse:data() end

--- Returns the status code.
---
function HTTPResponse:status() end
---@return number|nil
---@nodiscard
function c2.HTTPResponse:status() end

--- A somewhat human readable description of an error if such happened
---
function HTTPResponse:error() end
---@return string
---@nodiscard
function c2.HTTPResponse:error() end

---@return string
function HTTPResponse:__tostring() end
---@nodiscard
function c2.HTTPResponse:__tostring() end

-- End src/controllers/plugins/api/HTTPResponse.hpp

-- Begin src/controllers/plugins/api/HTTPRequest.hpp

---@alias HTTPCallback fun(result: HTTPResponse): nil
---@class HTTPRequest
HTTPRequest = {}
---@alias c2.HTTPCallback fun(result: c2.HTTPResponse): nil
---@class c2.HTTPRequest
c2.HTTPRequest = {}

--- Sets the success callback
---
---@param callback HTTPCallback Function to call when the HTTP request succeeds
function HTTPRequest:on_success(callback) end
---@param callback c2.HTTPCallback Function to call when the HTTP request succeeds
function c2.HTTPRequest:on_success(callback) end

--- Sets the failure callback
---
---@param callback HTTPCallback Function to call when the HTTP request fails or returns a non-ok status
function HTTPRequest:on_error(callback) end
---@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

--- Sets the finally callback
---
---@param callback fun(): nil Function to call when the HTTP request finishes
function HTTPRequest:finally(callback) end
function c2.HTTPRequest:finally(callback) end

--- Sets the timeout
---
---@param timeout integer How long in milliseconds until the times out
function HTTPRequest:set_timeout(timeout) end
function c2.HTTPRequest:set_timeout(timeout) end

--- Sets the request payload
---
---@param data string
function HTTPRequest:set_payload(data) end
function c2.HTTPRequest:set_payload(data) end

--- Sets a header in the request
---
---@param name string
---@param value string
function HTTPRequest:set_header(name, value) end
function c2.HTTPRequest:set_header(name, value) end

--- Executes the HTTP request
---
function HTTPRequest:execute() end
function c2.HTTPRequest:execute() end

---@return string
function HTTPRequest:__tostring() end
function c2.HTTPRequest:__tostring() end

--- Creates a new HTTPRequest
---
---@param method HTTPMethod Method to use
---@param method c2.HTTPMethod Method to use
---@param url string Where to send the request to
---@return HTTPRequest
function HTTPRequest.create(method, url) end
---@return c2.HTTPRequest
function c2.HTTPRequest.create(method, url) end

-- End src/controllers/plugins/api/HTTPRequest.hpp

-- Begin src/common/network/NetworkCommon.hpp

---@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 = {}
---@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
}

-- End src/common/network/NetworkCommon.hpp

Expand Down
23 changes: 9 additions & 14 deletions scripts/make_luals_meta.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env python3
"""
This script generates docs/plugin-meta.lua. It accepts no arguments
Expand Down Expand Up @@ -242,25 +243,19 @@ 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("---@type { ")
out.write(f"---@enum {name}\n")
out.write(f"{name} = {{\n")
out.write(
", ".join(
[f"{variant}: {typ}" for variant, typ in zip(variants,vtypes)]
"\n".join(
[
f" {variant} = {{}}, ---@type {name}.{variant}"
for variant in reader.read_enum_variants()
]
)
)
out.write(" }\n")
out.write(f"{name} = {{}}\n\n")
out.write("\n}\n\n")
continue

# class
Expand Down
6 changes: 6 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ set(SOURCE_FILES
common/WindowDescriptors.cpp
common/WindowDescriptors.hpp

common/enums/MessageContext.hpp
common/enums/MessageOverflow.hpp

common/network/NetworkCommon.cpp
Expand Down Expand Up @@ -282,6 +283,9 @@ 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

Expand Down Expand Up @@ -546,6 +550,8 @@ 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
Expand Down
48 changes: 40 additions & 8 deletions src/common/Channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
#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"
Expand Down Expand Up @@ -121,10 +123,10 @@ void Channel::addSystemMessage(const QString &contents)
this->addMessage(msg, MessageContext::Original);
}

void Channel::addOrReplaceTimeout(MessagePtr message)
void Channel::addOrReplaceTimeout(MessagePtr message, QTime now)
{
addOrReplaceChannelTimeout(
this->getMessageSnapshot(), std::move(message), QTime::currentTime(),
this->getMessageSnapshot(), std::move(message), now,
[this](auto /*idx*/, auto msg, auto replacement) {
this->replaceMessage(msg, replacement);
},
Expand Down Expand Up @@ -253,21 +255,33 @@ void Channel::fillInMissingMessages(const std::vector<MessagePtr> &messages)
}
}

void Channel::replaceMessage(MessagePtr message, MessagePtr replacement)
void Channel::replaceMessage(const MessagePtr &message,
const MessagePtr &replacement)
{
int index = this->messages_.replaceItem(message, replacement);

if (index >= 0)
{
this->messageReplaced.invoke((size_t)index, replacement);
this->messageReplaced.invoke((size_t)index, message, replacement);
}
}

void Channel::replaceMessage(size_t index, MessagePtr replacement)
void Channel::replaceMessage(size_t index, const MessagePtr &replacement)
{
if (this->messages_.replaceItem(index, replacement))
MessagePtr prev;
if (this->messages_.replaceItem(index, replacement, &prev))
{
this->messageReplaced.invoke(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);
}
}

Expand All @@ -287,10 +301,15 @@ 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)
Expand All @@ -301,6 +320,19 @@ MessagePtr Channel::findMessage(QString 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;
Expand Down
Loading

0 comments on commit 7c3f930

Please sign in to comment.