Hide similar messages by any user (#2716)

Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
Marko 2021-08-14 12:28:08 +00:00 committed by GitHub
parent d5ecba3d30
commit 113a7795f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 9 deletions

View file

@ -5,6 +5,7 @@
- Minor: Remove TwitchEmotes.com attribution and the open/copy options when right-clicking a Twitch Emote. (#2214, #3136) - Minor: Remove TwitchEmotes.com attribution and the open/copy options when right-clicking a Twitch Emote. (#2214, #3136)
- Minor: Strip leading @ and trailing , from username in /user and /usercard commands. (#3143) - Minor: Strip leading @ and trailing , from username in /user and /usercard commands. (#3143)
- Minor: Display a system message when reloading subscription emotes to match BTTV/FFZ behavior (#3135) - Minor: Display a system message when reloading subscription emotes to match BTTV/FFZ behavior (#3135)
- Minor: Added a setting to hide similar messages by any user. (#2716)
- Bugfix: Notifications for moderators about other moderators deleting messages can now be disabled. (#3121) - Bugfix: Notifications for moderators about other moderators deleting messages can now be disabled. (#3121)
- Bugfix: Moderation mode and active filters are now preserved when opening a split as a popup. (#3113, #3130) - Bugfix: Moderation mode and active filters are now preserved when opening a split as a popup. (#3113, #3130)
- Bugfix: Fixed a bug that caused all badge highlights to use the same color. (#3132, #3134) - Bugfix: Fixed a bug that caused all badge highlights to use the same color. (#3132, #3134)

View file

@ -112,11 +112,10 @@ float IrcMessageHandler::similarity(
MessagePtr msg, const LimitedQueueSnapshot<MessagePtr> &messages) MessagePtr msg, const LimitedQueueSnapshot<MessagePtr> &messages)
{ {
float similarityPercent = 0.0f; float similarityPercent = 0.0f;
int bySameUser = 0; int checked = 0;
for (int i = 1; bySameUser < getSettings()->hideSimilarMaxMessagesToCheck; for (int i = 1; i <= messages.size(); ++i)
++i)
{ {
if (messages.size() < i) if (checked >= getSettings()->hideSimilarMaxMessagesToCheck)
{ {
break; break;
} }
@ -126,11 +125,12 @@ float IrcMessageHandler::similarity(
{ {
break; break;
} }
if (msg->loginName != prevMsg->loginName) if (getSettings()->hideSimilarBySameUser &&
msg->loginName != prevMsg->loginName)
{ {
continue; continue;
} }
++bySameUser; ++checked;
similarityPercent = std::max( similarityPercent = std::max(
similarityPercent, similarityPercent,
relativeSimilarity(msg->messageText, prevMsg->messageText)); relativeSimilarity(msg->messageText, prevMsg->messageText));

View file

@ -392,6 +392,8 @@ public:
BoolSetting colorSimilarDisabled = {"/similarity/colorSimilarDisabled", BoolSetting colorSimilarDisabled = {"/similarity/colorSimilarDisabled",
true}; true};
BoolSetting hideSimilar = {"/similarity/hideSimilar", false}; BoolSetting hideSimilar = {"/similarity/hideSimilar", false};
BoolSetting hideSimilarBySameUser = {"/similarity/hideSimilarBySameUser",
true};
BoolSetting hideSimilarMyself = {"/similarity/hideSimilarMyself", false}; BoolSetting hideSimilarMyself = {"/similarity/hideSimilarMyself", false};
BoolSetting shownSimilarTriggerHighlights = { BoolSetting shownSimilarTriggerHighlights = {
"/similarity/shownSimilarTriggerHighlights", false}; "/similarity/shownSimilarTriggerHighlights", false};

View file

@ -520,11 +520,11 @@ void GeneralPage::initLayout(GeneralPageView &layout)
layout.addCheckbox("Title", s.headerStreamTitle); layout.addCheckbox("Title", s.headerStreamTitle);
layout.addSubtitle("R9K"); layout.addSubtitle("R9K");
layout.addDescription( layout.addDescription("Hide similar messages. Toggle hidden "
"Hide similar messages by the same user. Toggle hidden " "messages by pressing Ctrl+H.");
"messages by pressing Ctrl+H.");
layout.addCheckbox("Hide similar messages", s.similarityEnabled); layout.addCheckbox("Hide similar messages", s.similarityEnabled);
//layout.addCheckbox("Gray out matches", s.colorSimilarDisabled); //layout.addCheckbox("Gray out matches", s.colorSimilarDisabled);
layout.addCheckbox("By the same user", s.hideSimilarBySameUser);
layout.addCheckbox("Hide my own messages", s.hideSimilarMyself); layout.addCheckbox("Hide my own messages", s.hideSimilarMyself);
layout.addCheckbox("Receive notification sounds from hidden messages", layout.addCheckbox("Receive notification sounds from hidden messages",
s.shownSimilarTriggerHighlights); s.shownSimilarTriggerHighlights);