diff --git a/src/ircmanager.cpp b/src/ircmanager.cpp index 8723ea82e..30d53e628 100644 --- a/src/ircmanager.cpp +++ b/src/ircmanager.cpp @@ -242,6 +242,8 @@ void IrcManager::messageReceived(Communi::IrcMessage *message) this->handleUserNoticeMessage(message); } else if (command == "MODE") { this->handleModeMessage(message); + } else if (command == "NOTICE") { + this->handleNoticeMessage(static_cast(message)); } } @@ -417,6 +419,27 @@ void IrcManager::removeIgnoredUser(QString const &username) } } +void IrcManager::handleNoticeMessage(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; + } + + std::shared_ptr msg(Message::createSystemMessage(message->content())); + + c->addMessage(msg); +} + void IrcManager::onConnected() { std::shared_ptr msg(Message::createSystemMessage("connected to chat")); diff --git a/src/ircmanager.hpp b/src/ircmanager.hpp index c64c98a4d..ca247c9fd 100644 --- a/src/ircmanager.hpp +++ b/src/ircmanager.hpp @@ -85,6 +85,7 @@ private: void handleWhisperMessage(Communi::IrcMessage *message); void handleUserNoticeMessage(Communi::IrcMessage *message); void handleModeMessage(Communi::IrcMessage *message); + void handleNoticeMessage(Communi::IrcNoticeMessage *message); void onConnected(); void onDisconnected();