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: Refactor `DebugCount` and add copy button to debug popup. (#4921)
|
||||||
- Dev: Changed lifetime of context menus. (#4924)
|
- Dev: Changed lifetime of context menus. (#4924)
|
||||||
- Dev: Refactor `ChannelView`, removing a bunch of clang-tidy warnings. (#4926)
|
- 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
|
## 2.4.6
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,6 @@ std::vector<Communi::IrcMessage *> parseRecentMessages(
|
||||||
std::vector<MessagePtr> buildRecentMessages(
|
std::vector<MessagePtr> buildRecentMessages(
|
||||||
std::vector<Communi::IrcMessage *> &messages, Channel *channel)
|
std::vector<Communi::IrcMessage *> &messages, Channel *channel)
|
||||||
{
|
{
|
||||||
auto &handler = IrcMessageHandler::instance();
|
|
||||||
std::vector<MessagePtr> allBuiltMessages;
|
std::vector<MessagePtr> allBuiltMessages;
|
||||||
|
|
||||||
for (auto *message : messages)
|
for (auto *message : messages)
|
||||||
|
@ -78,8 +77,8 @@ std::vector<MessagePtr> buildRecentMessages(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto builtMessages =
|
auto builtMessages = IrcMessageHandler::parseMessageWithReply(
|
||||||
handler.parseMessageWithReply(channel, message, allBuiltMessages);
|
channel, message, allBuiltMessages);
|
||||||
|
|
||||||
for (const auto &builtMessage : builtMessages)
|
for (const auto &builtMessage : builtMessages)
|
||||||
{
|
{
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -29,59 +29,41 @@ class IrcMessageHandler
|
||||||
public:
|
public:
|
||||||
static IrcMessageHandler &instance();
|
static IrcMessageHandler &instance();
|
||||||
|
|
||||||
// parseMessage parses a single IRC message into 0+ Chatterino messages
|
/**
|
||||||
std::vector<MessagePtr> parseMessage(Channel *channel,
|
* Parse an IRC message into 0 or more Chatterino messages
|
||||||
Communi::IrcMessage *message);
|
* Takes previously loaded messages into consideration to add reply contexts
|
||||||
|
**/
|
||||||
std::vector<MessagePtr> parseMessageWithReply(
|
static std::vector<MessagePtr> parseMessageWithReply(
|
||||||
Channel *channel, Communi::IrcMessage *message,
|
Channel *channel, Communi::IrcMessage *message,
|
||||||
std::vector<MessagePtr> &otherLoaded);
|
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,
|
void handlePrivMessage(Communi::IrcPrivateMessage *message,
|
||||||
TwitchIrcServer &server);
|
TwitchIrcServer &server);
|
||||||
|
|
||||||
void handleRoomStateMessage(Communi::IrcMessage *message);
|
void handleRoomStateMessage(Communi::IrcMessage *message);
|
||||||
std::optional<ClearChatMessage> parseClearChatMessage(
|
|
||||||
Communi::IrcMessage *message);
|
|
||||||
void handleClearChatMessage(Communi::IrcMessage *message);
|
void handleClearChatMessage(Communi::IrcMessage *message);
|
||||||
void handleClearMessageMessage(Communi::IrcMessage *message);
|
void handleClearMessageMessage(Communi::IrcMessage *message);
|
||||||
void handleUserStateMessage(Communi::IrcMessage *message);
|
void handleUserStateMessage(Communi::IrcMessage *message);
|
||||||
void handleGlobalUserStateMessage(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,
|
void handleUserNoticeMessage(Communi::IrcMessage *message,
|
||||||
TwitchIrcServer &server);
|
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 handleNoticeMessage(Communi::IrcNoticeMessage *message);
|
||||||
|
|
||||||
void handleJoinMessage(Communi::IrcMessage *message);
|
void handleJoinMessage(Communi::IrcMessage *message);
|
||||||
void handlePartMessage(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:
|
private:
|
||||||
void addMessage(Communi::IrcMessage *message, const QString &target,
|
static float similarity(const MessagePtr &msg,
|
||||||
const QString &content, TwitchIrcServer &server,
|
const LimitedQueueSnapshot<MessagePtr> &messages);
|
||||||
bool isResub, bool isAction);
|
static void setSimilarityFlags(const MessagePtr &message,
|
||||||
|
const ChannelPtr &channel);
|
||||||
|
|
||||||
void populateReply(TwitchChannel *channel, Communi::IrcMessage *message,
|
void addMessage(Communi::IrcMessage *message, const QString &target,
|
||||||
const std::vector<MessagePtr> &otherLoaded,
|
const QString &originalContent, TwitchIrcServer &server,
|
||||||
TwitchMessageBuilder &builder);
|
bool isSub, bool isAction);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
Loading…
Reference in a new issue