diff --git a/src/providers/twitch/twitchaccountmanager.cpp b/src/providers/twitch/twitchaccountmanager.cpp index 1b8b24e8a..1fad27931 100644 --- a/src/providers/twitch/twitchaccountmanager.cpp +++ b/src/providers/twitch/twitchaccountmanager.cpp @@ -137,6 +137,17 @@ void TwitchAccountManager::load() }); } +bool TwitchAccountManager::isLoggedIn() const +{ + if (!this->currentUser) { + return false; + } + + // Once `TwitchAccount` class has a way to check, we should also return false if the credentials + // are incorrect + return !this->currentUser->isAnon(); +} + bool TwitchAccountManager::removeUser(TwitchAccount *account) { const auto &accs = this->accounts.getVector(); diff --git a/src/providers/twitch/twitchaccountmanager.hpp b/src/providers/twitch/twitchaccountmanager.hpp index b7fe99f0e..ea0a5c859 100644 --- a/src/providers/twitch/twitchaccountmanager.hpp +++ b/src/providers/twitch/twitchaccountmanager.hpp @@ -47,6 +47,8 @@ public: void reloadUsers(); void load(); + bool isLoggedIn() const; + pajlada::Settings::Setting currentUsername = {"/accounts/current", ""}; pajlada::Signals::NoArgSignal currentUserChanged; pajlada::Signals::NoArgSignal userListUpdated; diff --git a/src/providers/twitch/twitchchannel.cpp b/src/providers/twitch/twitchchannel.cpp index d5ffd3e80..fb7a17d6f 100644 --- a/src/providers/twitch/twitchchannel.cpp +++ b/src/providers/twitch/twitchchannel.cpp @@ -142,6 +142,15 @@ void TwitchChannel::sendMessage(const QString &message) { auto app = getApp(); + if (!app->accounts->twitch.isLoggedIn()) { + // XXX: It would be nice if we could add a link here somehow that opened the "account + // manager" dialog + this->addMessage( + messages::Message::createSystemMessage("You need to log in to send messages. You can " + "link your Twitch account in the settings.")); + return; + } + debug::Log("[TwitchChannel:{}] Send message: {}", this->name, message); // Do last message processing