From 7d259fe7e6d2dcc3dc97dc43d47f5c35f6f861b4 Mon Sep 17 00:00:00 2001 From: Rasmus Karlsson Date: Thu, 28 Dec 2017 18:37:39 +0100 Subject: [PATCH] An error should now be printed if you connect with bad credentials. This fix relies on #163 being closed, so for now #132 will be left open. --- src/ircmanager.cpp | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/src/ircmanager.cpp b/src/ircmanager.cpp index ab2e6d11a..4ed684741 100644 --- a/src/ircmanager.cpp +++ b/src/ircmanager.cpp @@ -449,7 +449,16 @@ void IrcManager::handleNoticeMessage(Communi::IrcNoticeMessage *message) { auto rawChannelName = message->target(); - assert(rawChannelName.length() >= 2); + bool broadcast = rawChannelName.length() < 2; + std::shared_ptr msg(Message::createSystemMessage(message->content())); + + if (broadcast) { + this->channelManager.doOnAll([msg](const auto &c) { + c->addMessage(msg); // + }); + + return; + } auto trimmedChannelName = rawChannelName.mid(1); @@ -461,27 +470,11 @@ void IrcManager::handleNoticeMessage(Communi::IrcNoticeMessage *message) return; } - std::shared_ptr msg(Message::createSystemMessage(message->content())); - c->addMessage(msg); } void IrcManager::handleWriteConnectionNoticeMessage(Communi::IrcNoticeMessage *message) { - auto rawChannelName = message->target(); - - assert(rawChannelName.length() >= 2); - - auto trimmedChannelName = rawChannelName.mid(1); - - auto c = this->channelManager.getTwitchChannel(trimmedChannelName); - - if (!c) { - debug::Log("[IrcManager:handleNoticeMessage] Channel {} not found in channel manager", - trimmedChannelName); - return; - } - QVariant v = message->tag("msg-id"); if (!v.isValid()) { return; @@ -495,9 +488,7 @@ void IrcManager::handleWriteConnectionNoticeMessage(Communi::IrcNoticeMessage *m return; } - std::shared_ptr msg(Message::createSystemMessage(message->content())); - - c->addMessage(msg); + this->handleNoticeMessage(message); } void IrcManager::onConnected()