We now handle irc NOTICE messages

This commit is contained in:
Rasmus Karlsson 2017-12-16 19:20:57 +01:00
parent 6d56148ed2
commit d905e88671
2 changed files with 24 additions and 0 deletions

View file

@ -242,6 +242,8 @@ void IrcManager::messageReceived(Communi::IrcMessage *message)
this->handleUserNoticeMessage(message); this->handleUserNoticeMessage(message);
} else if (command == "MODE") { } else if (command == "MODE") {
this->handleModeMessage(message); this->handleModeMessage(message);
} else if (command == "NOTICE") {
this->handleNoticeMessage(static_cast<Communi::IrcNoticeMessage *>(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<Message> msg(Message::createSystemMessage(message->content()));
c->addMessage(msg);
}
void IrcManager::onConnected() void IrcManager::onConnected()
{ {
std::shared_ptr<Message> msg(Message::createSystemMessage("connected to chat")); std::shared_ptr<Message> msg(Message::createSystemMessage("connected to chat"));

View file

@ -85,6 +85,7 @@ private:
void handleWhisperMessage(Communi::IrcMessage *message); void handleWhisperMessage(Communi::IrcMessage *message);
void handleUserNoticeMessage(Communi::IrcMessage *message); void handleUserNoticeMessage(Communi::IrcMessage *message);
void handleModeMessage(Communi::IrcMessage *message); void handleModeMessage(Communi::IrcMessage *message);
void handleNoticeMessage(Communi::IrcNoticeMessage *message);
void onConnected(); void onConnected();
void onDisconnected(); void onDisconnected();