diff --git a/src/channel.cpp b/src/channel.cpp index b17555c9a..4000662b9 100644 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -150,6 +150,20 @@ void Channel::addOrReplaceTimeout(messages::MessagePtr message) // WindowManager::getInstance().repaintVisibleChatWidgets(this); } +void Channel::disableAllMessages() +{ + LimitedQueueSnapshot snapshot = this->getMessageSnapshot(); + int snapshotLength = snapshot.getLength(); + for (int i = 0; i < snapshotLength; i++) { + auto &s = snapshot[i]; + if (s->flags & Message::System || s->flags & Message::Timeout) { + continue; + } + + s->flags.EnableFlag(Message::Disabled); + } +} + void Channel::addMessagesAtStart(std::vector &_messages) { std::vector addedMessages = this->messages.pushFront(_messages); diff --git a/src/channel.hpp b/src/channel.hpp index 5a46c8f1a..2c8e57f61 100644 --- a/src/channel.hpp +++ b/src/channel.hpp @@ -51,6 +51,7 @@ public: void addMessage(messages::MessagePtr message); void addMessagesAtStart(std::vector &messages); void addOrReplaceTimeout(messages::MessagePtr message); + void disableAllMessages(); void replaceMessage(messages::MessagePtr message, messages::MessagePtr replacement); virtual void addRecentChatter(const std::shared_ptr &message); diff --git a/src/providers/twitch/ircmessagehandler.cpp b/src/providers/twitch/ircmessagehandler.cpp index eaecb74b5..7afa1a642 100644 --- a/src/providers/twitch/ircmessagehandler.cpp +++ b/src/providers/twitch/ircmessagehandler.cpp @@ -150,6 +150,7 @@ void IrcMessageHandler::handleClearChatMessage(Communi::IrcMessage *message) // check if the chat has been cleared by a moderator if (message->parameters().length() == 1) { + chan->disableAllMessages(); chan->addMessage(Message::createSystemMessage("Chat has been cleared by a moderator.")); return;