-
-
Notifications
You must be signed in to change notification settings - Fork 457
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check for ignored phrases/users in channel point redemptions (#3102)
- Loading branch information
Showing
9 changed files
with
108 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#include "controllers/ignores/IgnoreController.hpp" | ||
|
||
#include "common/QLogging.hpp" | ||
#include "controllers/ignores/IgnorePhrase.hpp" | ||
#include "singletons/Settings.hpp" | ||
|
||
namespace chatterino { | ||
|
||
bool isIgnoredMessage(IgnoredMessageParameters &¶ms) | ||
{ | ||
if (!params.message.isEmpty()) | ||
{ | ||
// TODO(pajlada): Do we need to check if the phrase is valid first? | ||
auto phrases = getCSettings().ignoredMessages.readOnly(); | ||
for (const auto &phrase : *phrases) | ||
{ | ||
if (phrase.isBlock() && phrase.isMatch(params.message)) | ||
{ | ||
qCDebug(chatterinoMessage) | ||
<< "Blocking message because it contains ignored phrase" | ||
<< phrase.getPattern(); | ||
return true; | ||
} | ||
} | ||
} | ||
|
||
if (!params.twitchUserID.isEmpty() && | ||
getSettings()->enableTwitchBlockedUsers) | ||
{ | ||
auto sourceUserID = params.twitchUserID; | ||
|
||
auto blocks = | ||
getApp()->accounts->twitch.getCurrent()->accessBlockedUserIds(); | ||
|
||
if (auto it = blocks->find(sourceUserID); it != blocks->end()) | ||
{ | ||
switch (static_cast<ShowIgnoredUsersMessages>( | ||
getSettings()->showBlockedUsersMessages.getValue())) | ||
{ | ||
case ShowIgnoredUsersMessages::IfModerator: | ||
if (params.isMod || params.isBroadcaster) | ||
{ | ||
return false; | ||
} | ||
break; | ||
case ShowIgnoredUsersMessages::IfBroadcaster: | ||
if (params.isBroadcaster) | ||
{ | ||
return false; | ||
} | ||
break; | ||
case ShowIgnoredUsersMessages::Never: | ||
break; | ||
} | ||
|
||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
|
||
} // namespace chatterino |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,19 @@ | ||
#pragma once | ||
|
||
#include <QString> | ||
|
||
namespace chatterino { | ||
|
||
enum class ShowIgnoredUsersMessages { Never, IfModerator, IfBroadcaster }; | ||
|
||
struct IgnoredMessageParameters { | ||
QString message; | ||
|
||
QString twitchUserID; | ||
bool isMod; | ||
bool isBroadcaster; | ||
}; | ||
|
||
bool isIgnoredMessage(IgnoredMessageParameters &¶ms); | ||
|
||
} // namespace chatterino |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters