refactor: deduplicate IRC parsing (#5678)

This commit is contained in:
nerix
2024-11-02 13:54:31 +01:00
committed by GitHub
parent 5f76f5b755
commit 101a45fd3a
20 changed files with 590 additions and 739 deletions
File diff suppressed because it is too large Load Diff
+12 -7
View File
@@ -16,6 +16,7 @@ struct Message;
using MessagePtr = std::shared_ptr<const Message>;
class TwitchChannel;
class TwitchMessageBuilder;
class MessageSink;
struct ClearChatMessage {
MessagePtr message;
@@ -33,30 +34,34 @@ public:
* Parse an IRC message into 0 or more Chatterino messages
* Takes previously loaded messages into consideration to add reply contexts
**/
static std::vector<MessagePtr> parseMessageWithReply(
Channel *channel, Communi::IrcMessage *message,
std::vector<MessagePtr> &otherLoaded);
static void parseMessageInto(Communi::IrcMessage *message,
MessageSink &sink, TwitchChannel *channel);
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 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);
void addMessage(Communi::IrcMessage *message, const ChannelPtr &chan,
const QString &originalContent, ITwitchIrcServer &server,
bool isSub, bool isAction);
static void addMessage(Communi::IrcMessage *message, MessageSink &sink,
TwitchChannel *chan, const QString &originalContent,
ITwitchIrcServer &twitch, bool isSub, bool isAction);
private:
static float similarity(const MessagePtr &msg,
+2 -4
View File
@@ -452,8 +452,8 @@ void TwitchChannel::addChannelPointReward(const ChannelPointReward &reward)
if (reward.id == msg.rewardID)
{
IrcMessageHandler::instance().addMessage(
msg.message.get(), shared_from_this(),
msg.originalContent, *server, false, false);
msg.message.get(), *this, this, msg.originalContent,
*server, false, false);
return true;
}
return false;
@@ -1356,8 +1356,6 @@ void TwitchChannel::loadRecentMessages()
{
msgs.push_back(msg);
}
tc->addRecentChatter(msg->displayName);
}
getApp()->getTwitch()->getMentionsChannel()->fillInMissingMessages(
+1 -1
View File
@@ -312,7 +312,7 @@ void TwitchIrcServer::initialize()
postToThread([chan, action] {
MessageBuilder msg(action);
msg->flags.set(MessageFlag::PubSub);
chan->addOrReplaceTimeout(msg.release());
chan->addOrReplaceTimeout(msg.release(), QTime::currentTime());
});
});