Add system messages upon connecting/disconnecting

This commit is contained in:
Rasmus Karlsson
2017-12-16 18:11:36 +01:00
parent 3cc19bd4ce
commit 87203c1120
6 changed files with 70 additions and 0 deletions
+25
View File
@@ -53,6 +53,11 @@ IrcManager::IrcManager(ChannelManager &_channelManager, Resources &_resources,
&IrcManager::messageReceived);
QObject::connect(this->readConnection.get(), &Communi::IrcConnection::privateMessageReceived,
this, &IrcManager::privateMessageReceived);
QObject::connect(this->readConnection.get(), &Communi::IrcConnection::connected, this,
&IrcManager::onConnected);
QObject::connect(this->readConnection.get(), &Communi::IrcConnection::disconnected, this,
&IrcManager::onDisconnected);
}
void IrcManager::setUser(std::shared_ptr<twitch::TwitchUser> newAccount)
@@ -370,4 +375,24 @@ void IrcManager::removeIgnoredUser(QString const &username)
}
}
void IrcManager::onConnected()
{
std::shared_ptr<Message> msg(Message::createSystemMessage("connected to chat"));
this->channelManager.doOnAll([msg](std::shared_ptr<twitch::TwitchChannel> channel) {
assert(channel);
channel->addMessage(msg);
});
}
void IrcManager::onDisconnected()
{
std::shared_ptr<Message> msg(Message::createSystemMessage("disconnected from chat"));
this->channelManager.doOnAll([msg](std::shared_ptr<twitch::TwitchChannel> channel) {
assert(channel);
channel->addMessage(msg);
});
}
} // namespace chatterino