mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Compare commits
3 commits
e537fca186
...
eccdd63280
Author | SHA1 | Date | |
---|---|---|---|
|
eccdd63280 | ||
|
b267d615e3 | ||
|
d91719b31e |
5 changed files with 27 additions and 24 deletions
|
@ -98,7 +98,8 @@ public:
|
||||||
/// Removes all messages from this channel and invokes #messagesCleared
|
/// Removes all messages from this channel and invokes #messagesCleared
|
||||||
void clearMessages();
|
void clearMessages();
|
||||||
|
|
||||||
MessagePtr findMessage(QString messageID);
|
[[deprecated("Use findMessageByID instead")]] MessagePtr findMessage(
|
||||||
|
QString messageID);
|
||||||
MessagePtr findMessageByID(QStringView messageID) final;
|
MessagePtr findMessageByID(QStringView messageID) final;
|
||||||
|
|
||||||
bool hasMessages() const;
|
bool hasMessages() const;
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "messages/MessageFlag.hpp"
|
#include "messages/MessageFlag.hpp"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
class QStringView;
|
class QStringView;
|
||||||
class QTime;
|
class QTime;
|
||||||
|
|
|
@ -369,8 +369,8 @@ void IrcMessageHandler::parsePrivMessageInto(
|
||||||
}
|
}
|
||||||
|
|
||||||
addMessage(message, sink, channel,
|
addMessage(message, sink, channel,
|
||||||
unescapeZeroWidthJoiner(message->content()), false,
|
unescapeZeroWidthJoiner(message->content()),
|
||||||
message->isAction());
|
*getApp()->getTwitch(), false, message->isAction());
|
||||||
|
|
||||||
if (message->tags().contains(u"pinned-chat-paid-amount"_s))
|
if (message->tags().contains(u"pinned-chat-paid-amount"_s))
|
||||||
{
|
{
|
||||||
|
@ -675,7 +675,8 @@ void IrcMessageHandler::parseUserNoticeMessageInto(Communi::IrcMessage *message,
|
||||||
// Messages are not required, so they might be empty
|
// Messages are not required, so they might be empty
|
||||||
if (!content.isEmpty())
|
if (!content.isEmpty())
|
||||||
{
|
{
|
||||||
addMessage(message, sink, channel, content, true, false);
|
addMessage(message, sink, channel, content, *getApp()->getTwitch(),
|
||||||
|
true, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -955,11 +956,12 @@ void IrcMessageHandler::handlePartMessage(Communi::IrcMessage *message)
|
||||||
}
|
}
|
||||||
|
|
||||||
void IrcMessageHandler::addMessage(Communi::IrcMessage *message,
|
void IrcMessageHandler::addMessage(Communi::IrcMessage *message,
|
||||||
MessageSink &sink, TwitchChannel *channel,
|
MessageSink &sink, TwitchChannel *chan,
|
||||||
const QString &originalContent, bool isSub,
|
const QString &originalContent,
|
||||||
|
ITwitchIrcServer &twitch, bool isSub,
|
||||||
bool isAction)
|
bool isAction)
|
||||||
{
|
{
|
||||||
assert(channel);
|
assert(chan);
|
||||||
|
|
||||||
MessageParseArgs args;
|
MessageParseArgs args;
|
||||||
if (isSub)
|
if (isSub)
|
||||||
|
@ -968,7 +970,7 @@ void IrcMessageHandler::addMessage(Communi::IrcMessage *message,
|
||||||
args.trimSubscriberUsername = true;
|
args.trimSubscriberUsername = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (channel->isBroadcaster())
|
if (chan->isBroadcaster())
|
||||||
{
|
{
|
||||||
args.isStaffOrBroadcaster = true;
|
args.isStaffOrBroadcaster = true;
|
||||||
}
|
}
|
||||||
|
@ -992,13 +994,13 @@ void IrcMessageHandler::addMessage(Communi::IrcMessage *message,
|
||||||
if (!rewardId.isEmpty() &&
|
if (!rewardId.isEmpty() &&
|
||||||
sink.sinkTraits().has(
|
sink.sinkTraits().has(
|
||||||
MessageSinkTrait::RequiresKnownChannelPointReward) &&
|
MessageSinkTrait::RequiresKnownChannelPointReward) &&
|
||||||
!channel->isChannelPointRewardKnown(rewardId))
|
!chan->isChannelPointRewardKnown(rewardId))
|
||||||
{
|
{
|
||||||
// Need to wait for pubsub reward notification
|
// Need to wait for pubsub reward notification
|
||||||
qCDebug(chatterinoTwitch) << "TwitchChannel reward added ADD "
|
qCDebug(chatterinoTwitch) << "TwitchChannel reward added ADD "
|
||||||
"callback since reward is not known:"
|
"callback since reward is not known:"
|
||||||
<< rewardId;
|
<< rewardId;
|
||||||
channel->addQueuedRedemption(rewardId, originalContent, message);
|
chan->addQueuedRedemption(rewardId, originalContent, message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
args.channelPointRewardId = rewardId;
|
args.channelPointRewardId = rewardId;
|
||||||
|
@ -1012,9 +1014,9 @@ void IrcMessageHandler::addMessage(Communi::IrcMessage *message,
|
||||||
it != tags.end())
|
it != tags.end())
|
||||||
{
|
{
|
||||||
const QString replyID = it.value().toString();
|
const QString replyID = it.value().toString();
|
||||||
auto threadIt = channel->threads().find(replyID);
|
auto threadIt = chan->threads().find(replyID);
|
||||||
std::shared_ptr<MessageThread> rootThread;
|
std::shared_ptr<MessageThread> rootThread;
|
||||||
if (threadIt != channel->threads().end() && !threadIt->second.expired())
|
if (threadIt != chan->threads().end() && !threadIt->second.expired())
|
||||||
{
|
{
|
||||||
// Thread already exists (has a reply)
|
// Thread already exists (has a reply)
|
||||||
auto thread = threadIt->second.lock();
|
auto thread = threadIt->second.lock();
|
||||||
|
@ -1035,7 +1037,7 @@ void IrcMessageHandler::addMessage(Communi::IrcMessage *message,
|
||||||
replyCtx.thread = newThread;
|
replyCtx.thread = newThread;
|
||||||
rootThread = newThread;
|
rootThread = newThread;
|
||||||
// Store weak reference to thread in channel
|
// Store weak reference to thread in channel
|
||||||
channel->addReplyThread(newThread);
|
chan->addReplyThread(newThread);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1052,8 +1054,8 @@ void IrcMessageHandler::addMessage(Communi::IrcMessage *message,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto parentThreadIt = channel->threads().find(parentID);
|
auto parentThreadIt = chan->threads().find(parentID);
|
||||||
if (parentThreadIt != channel->threads().end())
|
if (parentThreadIt != chan->threads().end())
|
||||||
{
|
{
|
||||||
auto thread = parentThreadIt->second.lock();
|
auto thread = parentThreadIt->second.lock();
|
||||||
if (thread)
|
if (thread)
|
||||||
|
@ -1075,7 +1077,7 @@ void IrcMessageHandler::addMessage(Communi::IrcMessage *message,
|
||||||
|
|
||||||
args.allowIgnore = !isSub;
|
args.allowIgnore = !isSub;
|
||||||
auto [msg, alert] = MessageBuilder::makeIrcMessage(
|
auto [msg, alert] = MessageBuilder::makeIrcMessage(
|
||||||
channel, message, args, content, messageOffset, replyCtx.thread,
|
chan, message, args, content, messageOffset, replyCtx.thread,
|
||||||
replyCtx.parent);
|
replyCtx.parent);
|
||||||
|
|
||||||
if (msg)
|
if (msg)
|
||||||
|
@ -1092,7 +1094,7 @@ void IrcMessageHandler::addMessage(Communi::IrcMessage *message,
|
||||||
(!getSettings()->hideSimilar &&
|
(!getSettings()->hideSimilar &&
|
||||||
getSettings()->shownSimilarTriggerHighlights))
|
getSettings()->shownSimilarTriggerHighlights))
|
||||||
{
|
{
|
||||||
MessageBuilder::triggerHighlights(channel, alert);
|
MessageBuilder::triggerHighlights(chan, alert);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto highlighted = msg->flags.has(MessageFlag::Highlighted);
|
const auto highlighted = msg->flags.has(MessageFlag::Highlighted);
|
||||||
|
@ -1101,12 +1103,12 @@ void IrcMessageHandler::addMessage(Communi::IrcMessage *message,
|
||||||
if (highlighted && showInMentions &&
|
if (highlighted && showInMentions &&
|
||||||
sink.sinkTraits().has(MessageSinkTrait::AddMentionsToGlobalChannel))
|
sink.sinkTraits().has(MessageSinkTrait::AddMentionsToGlobalChannel))
|
||||||
{
|
{
|
||||||
getApp()->getTwitch()->getMentionsChannel()->addMessage(
|
twitch.getMentionsChannel()->addMessage(msg,
|
||||||
msg, MessageContext::Original);
|
MessageContext::Original);
|
||||||
}
|
}
|
||||||
|
|
||||||
sink.addMessage(msg, MessageContext::Original);
|
sink.addMessage(msg, MessageContext::Original);
|
||||||
channel->addRecentChatter(msg->displayName);
|
chan->addRecentChatter(msg->displayName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,9 +60,8 @@ public:
|
||||||
void handlePartMessage(Communi::IrcMessage *message);
|
void handlePartMessage(Communi::IrcMessage *message);
|
||||||
|
|
||||||
static void addMessage(Communi::IrcMessage *message, MessageSink &sink,
|
static void addMessage(Communi::IrcMessage *message, MessageSink &sink,
|
||||||
TwitchChannel *channel,
|
TwitchChannel *chan, const QString &originalContent,
|
||||||
const QString &originalContent, bool isSub,
|
ITwitchIrcServer &twitch, bool isSub, bool isAction);
|
||||||
bool isAction);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static float similarity(const MessagePtr &msg,
|
static float similarity(const MessagePtr &msg,
|
||||||
|
|
|
@ -453,7 +453,7 @@ void TwitchChannel::addChannelPointReward(const ChannelPointReward &reward)
|
||||||
{
|
{
|
||||||
IrcMessageHandler::instance().addMessage(
|
IrcMessageHandler::instance().addMessage(
|
||||||
msg.message.get(), *this, this, msg.originalContent,
|
msg.message.get(), *this, this, msg.originalContent,
|
||||||
false, false);
|
*server, false, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue