diff --git a/CHANGELOG.md b/CHANGELOG.md index 82b987d4723..0bf685b706f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Major: Add 7TV emotes from Chatterino7 (Mm2PL/Dankerino#79) - Minor: Move Dankerino settings to a separate tab (Mm2PL/Dankerino#84) +- Minor: Add advanced IRC tag related settings (Mm2PL/Dankerino#86) - Minor: Allow for adjusting rate limit settings. ### Chatterino diff --git a/src/providers/twitch/TwitchMessageBuilder.cpp b/src/providers/twitch/TwitchMessageBuilder.cpp index 25a5c81de34..7dfd51773da 100644 --- a/src/providers/twitch/TwitchMessageBuilder.cpp +++ b/src/providers/twitch/TwitchMessageBuilder.cpp @@ -43,6 +43,23 @@ const QSet zeroWidthEmotes{ "ReinDeer", "CandyCane", "cvMask", "cvHazmat", }; +bool isAbnormalNonce(const QString &nonce) +{ + // matches /[0-9a-f]{32}/ + if (nonce.size() != 32) + { + return true; + } + for (const auto letter : nonce) + { + if (('0' > letter || letter > '9') && ('a' > letter || letter > 'f')) + { + return true; + } + } + return false; +} + } // namespace namespace chatterino { @@ -211,6 +228,28 @@ MessagePtr TwitchMessageBuilder::build() this->appendChannelPointRewardMessage(reward.get(), this); } } + if (this->tags.contains("client-nonce")) + { + auto isAbnormal = + isAbnormalNonce(this->tags["client-nonce"].toString()); + if (isAbnormal && getSettings()->abnormalNonceDetection) + { + this->emplace(); + this->emplace( + "Abnormal nonce:", MessageElementFlag::ChannelPointReward, + MessageColor::System); + this->emplace(this->tags["client-nonce"].toString(), + MessageElementFlag::ChannelPointReward, + MessageColor::Text); + this->emplace( + MessageElementFlag::ChannelPointReward); + } + else if (!isAbnormal && getSettings()->normalNonceDetection) + { + this->emplace("*", MessageElementFlag::Text, + MessageColor(QColor(255, 163, 11))); + } + } this->appendChannelName(); diff --git a/src/singletons/Settings.hpp b/src/singletons/Settings.hpp index 92855bd31f0..a6e6affa23f 100644 --- a/src/singletons/Settings.hpp +++ b/src/singletons/Settings.hpp @@ -428,6 +428,9 @@ class Settings : public ABSettings, public ConcurrentSettings "/misc/twitch/lowRateLimitDelay", 1100, }; + BoolSetting abnormalNonceDetection = {"/misc/abnormalNonceDetection", + false}; + BoolSetting normalNonceDetection = {"/misc/normalNonceDetection", false}; BoolSetting dankerinoThreeLetterApiEasterEgg = { "/misc/dankerinoThreeLetterApiEasterEgg", false}; diff --git a/src/widgets/settingspages/DankerinoPage.cpp b/src/widgets/settingspages/DankerinoPage.cpp index 7ac6049eb9f..b96833d5291 100644 --- a/src/widgets/settingspages/DankerinoPage.cpp +++ b/src/widgets/settingspages/DankerinoPage.cpp @@ -60,9 +60,17 @@ void DankerinoPage::initLayout(GeneralPageView &layout) if (s.dankerinoThreeLetterApiEasterEgg) { + layout.addCheckbox("Click to disable GraphQL easter egg and " + "advanced settings " + "(requires restart)", + s.dankerinoThreeLetterApiEasterEgg); + layout.addTitle("Random 'hacks'"); + layout.addCheckbox("Abnormal nonce detection", + s.abnormalNonceDetection); layout.addCheckbox( - "Click to disable GraphQL easter egg (requires restart)", - s.dankerinoThreeLetterApiEasterEgg); + "Webchat detection. Adds a little orange asterisk before the " + "message timestamp if it was sent from webchat.", + s.normalNonceDetection); } layout.addStretch(); // invisible element for width