diff --git a/src/channel.cpp b/src/channel.cpp index 90359bf52..b17555c9a 100644 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -187,6 +187,11 @@ bool Channel::isMod() const return false; } +bool Channel::isBroadcaster() const +{ + return false; +} + std::shared_ptr Channel::getEmpty() { static std::shared_ptr channel(new Channel("", None)); diff --git a/src/channel.hpp b/src/channel.hpp index 784eb2b4b..5a46c8f1a 100644 --- a/src/channel.hpp +++ b/src/channel.hpp @@ -60,6 +60,7 @@ public: virtual bool canSendMessage() const; virtual void sendMessage(const QString &message); virtual bool isMod() const; + virtual bool isBroadcaster() const; static std::shared_ptr getEmpty(); diff --git a/src/messages/messageparseargs.hpp b/src/messages/messageparseargs.hpp index 4196f6552..8ededccfc 100644 --- a/src/messages/messageparseargs.hpp +++ b/src/messages/messageparseargs.hpp @@ -8,6 +8,7 @@ struct MessageParseArgs { bool isReceivedWhisper = false; bool isSentWhisper = false; bool trimSubscriberUsername = false; + bool isStaffOrBroadcaster = false; }; } // namespace messages diff --git a/src/providers/twitch/ircmessagehandler.cpp b/src/providers/twitch/ircmessagehandler.cpp index def8a9e8e..eaecb74b5 100644 --- a/src/providers/twitch/ircmessagehandler.cpp +++ b/src/providers/twitch/ircmessagehandler.cpp @@ -54,6 +54,10 @@ void IrcMessageHandler::addMessage(Communi::IrcMessage *_message, const QString args.trimSubscriberUsername = true; } + if (chan->isBroadcaster()) { + args.isStaffOrBroadcaster = true; + } + TwitchMessageBuilder builder(chan.get(), _message, args, content, isAction); if (isSub || !builder.isIgnored()) { diff --git a/src/providers/twitch/twitchchannel.cpp b/src/providers/twitch/twitchchannel.cpp index ccf0b8eb3..d5ffd3e80 100644 --- a/src/providers/twitch/twitchchannel.cpp +++ b/src/providers/twitch/twitchchannel.cpp @@ -182,7 +182,7 @@ void TwitchChannel::setMod(bool value) } } -bool TwitchChannel::isBroadcaster() +bool TwitchChannel::isBroadcaster() const { auto app = getApp(); diff --git a/src/providers/twitch/twitchchannel.hpp b/src/providers/twitch/twitchchannel.hpp index 3811cc3ec..7cd502f43 100644 --- a/src/providers/twitch/twitchchannel.hpp +++ b/src/providers/twitch/twitchchannel.hpp @@ -59,7 +59,7 @@ public: bool isMod() const override; void setMod(bool value); - bool isBroadcaster(); + bool isBroadcaster() const override; bool hasModRights(); void addRecentChatter(const std::shared_ptr &message) final; diff --git a/src/providers/twitch/twitchmessagebuilder.cpp b/src/providers/twitch/twitchmessagebuilder.cpp index f36095e59..13a6cba80 100644 --- a/src/providers/twitch/twitchmessagebuilder.cpp +++ b/src/providers/twitch/twitchmessagebuilder.cpp @@ -99,6 +99,10 @@ MessagePtr TwitchMessageBuilder::build() // PARSING this->parseUsername(); + if (this->userName == this->channel->name) { + this->senderIsBroadcaster = true; + } + //#ifdef XD // if (this->originalMessage.length() > 100) { // this->message->flags |= Message::Collapsed; @@ -126,7 +130,25 @@ MessagePtr TwitchMessageBuilder::build() this->emplace(); } - this->emplace(); + bool addModerationElement = true; + if (this->senderIsBroadcaster) { + addModerationElement = false; + } else { + bool hasUserType = this->tags.contains("user-type"); + if (hasUserType) { + QString userType = this->tags.value("user-type").toString(); + + if (userType == "mod") { + if (!args.isStaffOrBroadcaster) { + addModerationElement = false; + } + } + } + } + + if (addModerationElement) { + this->emplace(); + } this->appendTwitchBadges(); diff --git a/src/providers/twitch/twitchmessagebuilder.hpp b/src/providers/twitch/twitchmessagebuilder.hpp index a14a6028c..048736790 100644 --- a/src/providers/twitch/twitchmessagebuilder.hpp +++ b/src/providers/twitch/twitchmessagebuilder.hpp @@ -50,6 +50,7 @@ private: QColor usernameColor; const QString originalMessage; + bool senderIsBroadcaster{}; const bool action = false;