mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
refactor: IrcMessageHandler (#4927)
This commit is contained in:
parent
7efe58cca9
commit
f4726ed7a8
4 changed files with 608 additions and 577 deletions
|
@ -46,6 +46,7 @@
|
|||
- Dev: Refactor `DebugCount` and add copy button to debug popup. (#4921)
|
||||
- Dev: Changed lifetime of context menus. (#4924)
|
||||
- Dev: Refactor `ChannelView`, removing a bunch of clang-tidy warnings. (#4926)
|
||||
- Dev: Refactor `IrcMessageHandler`, removing a bunch of clang-tidy warnings & changing its public API. (#4927)
|
||||
|
||||
## 2.4.6
|
||||
|
||||
|
|
|
@ -54,7 +54,6 @@ std::vector<Communi::IrcMessage *> parseRecentMessages(
|
|||
std::vector<MessagePtr> buildRecentMessages(
|
||||
std::vector<Communi::IrcMessage *> &messages, Channel *channel)
|
||||
{
|
||||
auto &handler = IrcMessageHandler::instance();
|
||||
std::vector<MessagePtr> allBuiltMessages;
|
||||
|
||||
for (auto *message : messages)
|
||||
|
@ -78,8 +77,8 @@ std::vector<MessagePtr> buildRecentMessages(
|
|||
}
|
||||
}
|
||||
|
||||
auto builtMessages =
|
||||
handler.parseMessageWithReply(channel, message, allBuiltMessages);
|
||||
auto builtMessages = IrcMessageHandler::parseMessageWithReply(
|
||||
channel, message, allBuiltMessages);
|
||||
|
||||
for (const auto &builtMessage : builtMessages)
|
||||
{
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -29,59 +29,41 @@ class IrcMessageHandler
|
|||
public:
|
||||
static IrcMessageHandler &instance();
|
||||
|
||||
// parseMessage parses a single IRC message into 0+ Chatterino messages
|
||||
std::vector<MessagePtr> parseMessage(Channel *channel,
|
||||
Communi::IrcMessage *message);
|
||||
|
||||
std::vector<MessagePtr> parseMessageWithReply(
|
||||
/**
|
||||
* 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);
|
||||
|
||||
// parsePrivMessage arses a single IRC PRIVMSG into 0-1 Chatterino messages
|
||||
std::vector<MessagePtr> parsePrivMessage(
|
||||
Channel *channel, Communi::IrcPrivateMessage *message);
|
||||
void handlePrivMessage(Communi::IrcPrivateMessage *message,
|
||||
TwitchIrcServer &server);
|
||||
|
||||
void handleRoomStateMessage(Communi::IrcMessage *message);
|
||||
std::optional<ClearChatMessage> parseClearChatMessage(
|
||||
Communi::IrcMessage *message);
|
||||
void handleClearChatMessage(Communi::IrcMessage *message);
|
||||
void handleClearMessageMessage(Communi::IrcMessage *message);
|
||||
void handleUserStateMessage(Communi::IrcMessage *message);
|
||||
void handleGlobalUserStateMessage(Communi::IrcMessage *message);
|
||||
void handleWhisperMessage(Communi::IrcMessage *message);
|
||||
void handleWhisperMessage(Communi::IrcMessage *ircMessage);
|
||||
|
||||
// parseUserNoticeMessage parses a single IRC USERNOTICE message into 0+
|
||||
// Chatterino messages
|
||||
std::vector<MessagePtr> parseUserNoticeMessage(
|
||||
Channel *channel, Communi::IrcMessage *message);
|
||||
void handleUserNoticeMessage(Communi::IrcMessage *message,
|
||||
TwitchIrcServer &server);
|
||||
|
||||
void handleModeMessage(Communi::IrcMessage *message);
|
||||
|
||||
// parseNoticeMessage parses a single IRC NOTICE message into 0+ chatterino
|
||||
// messages
|
||||
std::vector<MessagePtr> parseNoticeMessage(
|
||||
Communi::IrcNoticeMessage *message);
|
||||
void handleNoticeMessage(Communi::IrcNoticeMessage *message);
|
||||
|
||||
void handleJoinMessage(Communi::IrcMessage *message);
|
||||
void handlePartMessage(Communi::IrcMessage *message);
|
||||
|
||||
static float similarity(MessagePtr msg,
|
||||
const LimitedQueueSnapshot<MessagePtr> &messages);
|
||||
static void setSimilarityFlags(MessagePtr message, ChannelPtr channel);
|
||||
|
||||
private:
|
||||
void addMessage(Communi::IrcMessage *message, const QString &target,
|
||||
const QString &content, TwitchIrcServer &server,
|
||||
bool isResub, bool isAction);
|
||||
static float similarity(const MessagePtr &msg,
|
||||
const LimitedQueueSnapshot<MessagePtr> &messages);
|
||||
static void setSimilarityFlags(const MessagePtr &message,
|
||||
const ChannelPtr &channel);
|
||||
|
||||
void populateReply(TwitchChannel *channel, Communi::IrcMessage *message,
|
||||
const std::vector<MessagePtr> &otherLoaded,
|
||||
TwitchMessageBuilder &builder);
|
||||
void addMessage(Communi::IrcMessage *message, const QString &target,
|
||||
const QString &originalContent, TwitchIrcServer &server,
|
||||
bool isSub, bool isAction);
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
Loading…
Reference in a new issue