Improve notice message handling

This should stop most duplicate notice messages from showing up

Fix #272
This commit is contained in:
Rasmus Karlsson 2018-06-24 15:33:22 +00:00
parent 8bb3ad1bf5
commit a105b47a6b
2 changed files with 28 additions and 8 deletions

View file

@ -15,6 +15,8 @@
#include <IrcMessage>
#include <unordered_set>
using namespace chatterino::singletons;
using namespace chatterino::messages;
@ -324,17 +326,34 @@ void IrcMessageHandler::handleNoticeMessage(Communi::IrcNoticeMessage *message)
void IrcMessageHandler::handleWriteConnectionNoticeMessage(Communi::IrcNoticeMessage *message)
{
static std::unordered_set<std::string> readConnectionOnlyIDs{
"host_on",
"host_off",
"host_target_went_offline",
"emote_only_on",
"emote_only_off",
"slow_on",
"slow_off",
"subs_on",
"subs_off",
"r9k_on",
"r9k_off",
// Display for user who times someone out. This implies you're a moderator, at which point
// you will be connected to PubSub and receive a better message from there
"timeout_success",
"ban_success",
};
QVariant v = message->tag("msg-id");
if (!v.isValid()) {
if (v.isValid()) {
std::string msgID = v.toString().toStdString();
if (readConnectionOnlyIDs.find(msgID) != readConnectionOnlyIDs.end()) {
return;
}
QString msg_id = v.toString();
static QList<QString> idsToSkip = {"timeout_success", "ban_success"};
if (idsToSkip.contains(msg_id)) {
// Already handled in the read-connection
return;
debug::Log("Showing notice message from write connection with message id '{}'", msgID);
}
this->handleNoticeMessage(message);

View file

@ -10,6 +10,7 @@
#include "util/posttothread.hpp"
#include <IrcCommand>
#include <cassert>
// using namespace Communi;