mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Refactored TwitchChannel
This commit is contained in:
parent
111853c574
commit
1614b11e42
11 changed files with 268 additions and 247 deletions
|
@ -232,8 +232,7 @@ SOURCES += \
|
||||||
src/widgets/dialogs/UpdateDialog.cpp \
|
src/widgets/dialogs/UpdateDialog.cpp \
|
||||||
src/widgets/settingspages/IgnoresPage.cpp \
|
src/widgets/settingspages/IgnoresPage.cpp \
|
||||||
src/providers/twitch/PubsubClient.cpp \
|
src/providers/twitch/PubsubClient.cpp \
|
||||||
src/providers/twitch/TwitchApi.cpp \
|
src/providers/twitch/TwitchApi.cpp
|
||||||
src/common/uniqueaccess.cpp
|
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
src/Application.hpp \
|
src/Application.hpp \
|
||||||
|
@ -416,7 +415,7 @@ HEADERS += \
|
||||||
src/widgets/settingspages/IgnoresPage.hpp \
|
src/widgets/settingspages/IgnoresPage.hpp \
|
||||||
src/providers/twitch/PubsubClient.hpp \
|
src/providers/twitch/PubsubClient.hpp \
|
||||||
src/providers/twitch/TwitchApi.hpp \
|
src/providers/twitch/TwitchApi.hpp \
|
||||||
src/common/uniqueaccess.hpp
|
src/common/UniqueAccess.hpp
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
resources/resources.qrc \
|
resources/resources.qrc \
|
||||||
|
|
|
@ -21,16 +21,31 @@ public:
|
||||||
this->mutex_.unlock();
|
this->mutex_.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
T *operator->() const
|
const T *operator->() const
|
||||||
{
|
{
|
||||||
return &this->element_;
|
return &this->element_;
|
||||||
}
|
}
|
||||||
|
|
||||||
T &operator*() const
|
T *operator->()
|
||||||
|
{
|
||||||
|
return &this->element_;
|
||||||
|
}
|
||||||
|
|
||||||
|
const T &operator*() const
|
||||||
{
|
{
|
||||||
return this->element_;
|
return this->element_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
T &operator*()
|
||||||
|
{
|
||||||
|
return this->element_;
|
||||||
|
}
|
||||||
|
|
||||||
|
T clone() const
|
||||||
|
{
|
||||||
|
return T(this->element_);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
T &element_;
|
T &element_;
|
||||||
std::mutex &mutex_;
|
std::mutex &mutex_;
|
||||||
|
@ -40,7 +55,7 @@ template <typename T>
|
||||||
class UniqueAccess
|
class UniqueAccess
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
template <typename std::enable_if<std::is_default_constructible<T>::value>::type * = 0>
|
template <typename X = decltype(T())>
|
||||||
UniqueAccess()
|
UniqueAccess()
|
||||||
: element_(T())
|
: element_(T())
|
||||||
{
|
{
|
||||||
|
@ -73,9 +88,14 @@ public:
|
||||||
return AccessGuard<T>(this->element_, this->mutex_);
|
return AccessGuard<T>(this->element_, this->mutex_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const AccessGuard<T> access() const
|
||||||
|
{
|
||||||
|
return AccessGuard<T>(this->element_, this->mutex_);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
T element_;
|
mutable T element_;
|
||||||
std::mutex mutex_;
|
mutable std::mutex mutex_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
|
@ -1 +0,0 @@
|
||||||
#include "uniqueaccess.hpp"
|
|
|
@ -142,7 +142,7 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
|
||||||
|
|
||||||
app->twitch.server->getWriteConnection()->sendRaw("PRIVMSG #jtv :" + text + "\r\n");
|
app->twitch.server->getWriteConnection()->sendRaw("PRIVMSG #jtv :" + text + "\r\n");
|
||||||
|
|
||||||
if (app->settings->inlineWhispers) {
|
if (getSettings()->inlineWhispers) {
|
||||||
app->twitch.server->forEachChannel(
|
app->twitch.server->forEachChannel(
|
||||||
[&b](ChannelPtr _channel) { _channel->addMessage(b.getMessage()); });
|
[&b](ChannelPtr _channel) { _channel->addMessage(b.getMessage()); });
|
||||||
}
|
}
|
||||||
|
@ -163,10 +163,10 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
} else if (commandName == "/uptime") {
|
} else if (commandName == "/uptime") {
|
||||||
const auto &streamStatus = twitchChannel->getStreamStatus();
|
const auto &streamStatus = twitchChannel->accessStreamStatus();
|
||||||
|
|
||||||
QString messageText =
|
QString messageText =
|
||||||
streamStatus.live ? streamStatus.uptime : "Channel is not live.";
|
streamStatus->live ? streamStatus->uptime : "Channel is not live.";
|
||||||
|
|
||||||
channel->addMessage(Message::createSystemMessage(messageText));
|
channel->addMessage(Message::createSystemMessage(messageText));
|
||||||
|
|
||||||
|
|
|
@ -93,31 +93,33 @@ void IrcMessageHandler::handleRoomStateMessage(Communi::IrcMessage *message)
|
||||||
if ((it = tags.find("room-id")) != tags.end()) {
|
if ((it = tags.find("room-id")) != tags.end()) {
|
||||||
auto roomId = it.value().toString();
|
auto roomId = it.value().toString();
|
||||||
|
|
||||||
twitchChannel->setRoomID(roomId);
|
twitchChannel->setRoomId(roomId);
|
||||||
|
|
||||||
app->resources->loadChannelData(roomId);
|
app->resources->loadChannelData(roomId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Room modes
|
// Room modes
|
||||||
TwitchChannel::RoomModes roomModes = twitchChannel->getRoomModes();
|
{
|
||||||
|
auto roomModes = twitchChannel->accessRoomModes();
|
||||||
|
|
||||||
if ((it = tags.find("emote-only")) != tags.end()) {
|
if ((it = tags.find("emote-only")) != tags.end()) {
|
||||||
roomModes.emoteOnly = it.value() == "1";
|
roomModes->emoteOnly = it.value() == "1";
|
||||||
}
|
}
|
||||||
if ((it = tags.find("subs-only")) != tags.end()) {
|
if ((it = tags.find("subs-only")) != tags.end()) {
|
||||||
roomModes.submode = it.value() == "1";
|
roomModes->submode = it.value() == "1";
|
||||||
}
|
}
|
||||||
if ((it = tags.find("slow")) != tags.end()) {
|
if ((it = tags.find("slow")) != tags.end()) {
|
||||||
roomModes.slowMode = it.value().toInt();
|
roomModes->slowMode = it.value().toInt();
|
||||||
}
|
}
|
||||||
if ((it = tags.find("r9k")) != tags.end()) {
|
if ((it = tags.find("r9k")) != tags.end()) {
|
||||||
roomModes.r9k = it.value() == "1";
|
roomModes->r9k = it.value() == "1";
|
||||||
}
|
}
|
||||||
if ((it = tags.find("broadcaster-lang")) != tags.end()) {
|
if ((it = tags.find("broadcaster-lang")) != tags.end()) {
|
||||||
roomModes.broadcasterLang = it.value().toString();
|
roomModes->broadcasterLang = it.value().toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
twitchChannel->setRoomModes(roomModes);
|
twitchChannel->roomModesChanged.invoke();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,31 +21,31 @@ namespace chatterino {
|
||||||
|
|
||||||
TwitchChannel::TwitchChannel(const QString &channelName, Communi::IrcConnection *readConnection)
|
TwitchChannel::TwitchChannel(const QString &channelName, Communi::IrcConnection *readConnection)
|
||||||
: Channel(channelName, Channel::Type::Twitch)
|
: Channel(channelName, Channel::Type::Twitch)
|
||||||
, bttvChannelEmotes(new EmoteMap)
|
, bttvEmotes_(new EmoteMap)
|
||||||
, ffzChannelEmotes(new EmoteMap)
|
, ffzEmotes_(new EmoteMap)
|
||||||
, subscriptionURL("https://www.twitch.tv/subs/" + name)
|
, subscriptionUrl_("https://www.twitch.tv/subs/" + name)
|
||||||
, channelURL("https://twitch.tv/" + name)
|
, channelUrl_("https://twitch.tv/" + name)
|
||||||
, popoutPlayerURL("https://player.twitch.tv/?channel=" + name)
|
, popoutPlayerUrl_("https://player.twitch.tv/?channel=" + name)
|
||||||
, mod_(false)
|
, mod_(false)
|
||||||
, readConnection_(readConnection)
|
, readConnection_(readConnection)
|
||||||
{
|
{
|
||||||
Log("[TwitchChannel:{}] Opened", this->name);
|
Log("[TwitchChannel:{}] Opened", this->name);
|
||||||
|
|
||||||
this->refreshChannelEmotes();
|
this->refreshChannelEmotes();
|
||||||
this->refreshViewerList();
|
// this->refreshViewerList();
|
||||||
|
|
||||||
this->managedConnect(getApp()->accounts->twitch.currentUserChanged,
|
this->managedConnect(getApp()->accounts->twitch.currentUserChanged,
|
||||||
[=] { this->setMod(false); });
|
[=] { this->setMod(false); });
|
||||||
|
|
||||||
// pubsub
|
// pubsub
|
||||||
this->userStateChanged.connect([=] { this->refreshPubsub(); });
|
this->userStateChanged.connect([=] { this->refreshPubsub(); });
|
||||||
this->roomIDChanged.connect([=] { this->refreshPubsub(); });
|
this->roomIdChanged.connect([=] { this->refreshPubsub(); });
|
||||||
this->managedConnect(getApp()->accounts->twitch.currentUserChanged,
|
this->managedConnect(getApp()->accounts->twitch.currentUserChanged,
|
||||||
[=] { this->refreshPubsub(); });
|
[=] { this->refreshPubsub(); });
|
||||||
this->refreshPubsub();
|
this->refreshPubsub();
|
||||||
|
|
||||||
// room id loaded -> refresh live status
|
// room id loaded -> refresh live status
|
||||||
this->roomIDChanged.connect([this]() { this->refreshLiveStatus(); });
|
this->roomIdChanged.connect([this]() { this->refreshLiveStatus(); });
|
||||||
|
|
||||||
// timers
|
// timers
|
||||||
QObject::connect(&this->chattersListTimer_, &QTimer::timeout,
|
QObject::connect(&this->chattersListTimer_, &QTimer::timeout,
|
||||||
|
@ -83,8 +83,8 @@ void TwitchChannel::refreshChannelEmotes()
|
||||||
|
|
||||||
Log("[TwitchChannel:{}] Reloading channel emotes", this->name);
|
Log("[TwitchChannel:{}] Reloading channel emotes", this->name);
|
||||||
|
|
||||||
app->emotes->bttv.loadChannelEmotes(this->name, this->bttvChannelEmotes);
|
app->emotes->bttv.loadChannelEmotes(this->name, this->bttvEmotes_);
|
||||||
app->emotes->ffz.loadChannelEmotes(this->name, this->ffzChannelEmotes);
|
app->emotes->ffz.loadChannelEmotes(this->name, this->ffzEmotes_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwitchChannel::sendMessage(const QString &message)
|
void TwitchChannel::sendMessage(const QString &message)
|
||||||
|
@ -112,7 +112,7 @@ void TwitchChannel::sendMessage(const QString &message)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this->hasModRights()) {
|
if (!this->hasModRights()) {
|
||||||
if (app->settings->allowDuplicateMessages) {
|
if (getSettings()->allowDuplicateMessages) {
|
||||||
if (parsedMessage == this->lastSentMessage_) {
|
if (parsedMessage == this->lastSentMessage_) {
|
||||||
parsedMessage.append(this->messageSuffix_);
|
parsedMessage.append(this->messageSuffix_);
|
||||||
}
|
}
|
||||||
|
@ -153,36 +153,30 @@ void TwitchChannel::addRecentChatter(const std::shared_ptr<Message> &message)
|
||||||
{
|
{
|
||||||
assert(!message->loginName.isEmpty());
|
assert(!message->loginName.isEmpty());
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(this->recentChattersMutex_);
|
|
||||||
|
|
||||||
this->recentChatters_[message->loginName] = {message->displayName, message->localizedName};
|
|
||||||
|
|
||||||
this->completionModel.addUser(message->displayName);
|
this->completionModel.addUser(message->displayName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwitchChannel::addJoinedUser(const QString &user)
|
void TwitchChannel::addJoinedUser(const QString &user)
|
||||||
{
|
{
|
||||||
auto *app = getApp();
|
auto app = getApp();
|
||||||
if (user == app->accounts->twitch.getCurrent()->getUserName() ||
|
if (user == app->accounts->twitch.getCurrent()->getUserName() ||
|
||||||
!app->settings->showJoins.getValue()) {
|
!getSettings()->showJoins.getValue()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::lock_guard<std::mutex> guard(this->joinedUserMutex_);
|
auto joinedUsers = this->joinedUsers_.access();
|
||||||
|
joinedUsers->append(user);
|
||||||
joinedUsers_ << user;
|
|
||||||
|
|
||||||
if (!this->joinedUsersMergeQueued_) {
|
if (!this->joinedUsersMergeQueued_) {
|
||||||
this->joinedUsersMergeQueued_ = true;
|
this->joinedUsersMergeQueued_ = true;
|
||||||
|
|
||||||
QTimer::singleShot(500, &this->object_, [this] {
|
QTimer::singleShot(500, &this->lifetimeGuard_, [this] {
|
||||||
std::lock_guard<std::mutex> guard(this->joinedUserMutex_);
|
auto joinedUsers = this->joinedUsers_.access();
|
||||||
|
|
||||||
auto message =
|
auto message = Message::createSystemMessage("Users joined: " + joinedUsers->join(", "));
|
||||||
Message::createSystemMessage("Users joined: " + this->joinedUsers_.join(", "));
|
|
||||||
message->flags |= Message::Collapsed;
|
message->flags |= Message::Collapsed;
|
||||||
|
joinedUsers->clear();
|
||||||
this->addMessage(message);
|
this->addMessage(message);
|
||||||
this->joinedUsers_.clear();
|
|
||||||
this->joinedUsersMergeQueued_ = false;
|
this->joinedUsersMergeQueued_ = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -197,76 +191,92 @@ void TwitchChannel::addPartedUser(const QString &user)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::lock_guard<std::mutex> guard(this->partedUserMutex_);
|
auto partedUsers = this->partedUsers_.access();
|
||||||
|
partedUsers->append(user);
|
||||||
this->partedUsers_ << user;
|
|
||||||
|
|
||||||
if (!this->partedUsersMergeQueued_) {
|
if (!this->partedUsersMergeQueued_) {
|
||||||
this->partedUsersMergeQueued_ = true;
|
this->partedUsersMergeQueued_ = true;
|
||||||
|
|
||||||
QTimer::singleShot(500, &this->object_, [this] {
|
QTimer::singleShot(500, &this->lifetimeGuard_, [this] {
|
||||||
std::lock_guard<std::mutex> guard(this->partedUserMutex_);
|
auto partedUsers = this->partedUsers_.access();
|
||||||
|
|
||||||
auto message =
|
auto message = Message::createSystemMessage("Users parted: " + partedUsers->join(", "));
|
||||||
Message::createSystemMessage("Users parted: " + this->partedUsers_.join(", "));
|
|
||||||
message->flags |= Message::Collapsed;
|
message->flags |= Message::Collapsed;
|
||||||
this->addMessage(message);
|
this->addMessage(message);
|
||||||
this->partedUsers_.clear();
|
partedUsers->clear();
|
||||||
|
|
||||||
this->partedUsersMergeQueued_ = false;
|
this->partedUsersMergeQueued_ = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TwitchChannel::getRoomID() const
|
QString TwitchChannel::getRoomId() const
|
||||||
{
|
{
|
||||||
return this->roomID_.get();
|
return this->roomID_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwitchChannel::setRoomID(const QString &id)
|
void TwitchChannel::setRoomId(const QString &id)
|
||||||
{
|
{
|
||||||
this->roomID_.set(id);
|
this->roomID_.set(id);
|
||||||
this->roomIDChanged.invoke();
|
this->roomIdChanged.invoke();
|
||||||
this->loadRecentMessages();
|
this->loadRecentMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
TwitchChannel::RoomModes TwitchChannel::getRoomModes()
|
const AccessGuard<TwitchChannel::RoomModes> TwitchChannel::accessRoomModes() const
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(this->roomModeMutex_);
|
return this->roomModes_.access();
|
||||||
|
|
||||||
return this->roomModes_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwitchChannel::setRoomModes(const RoomModes &_roomModes)
|
void TwitchChannel::setRoomModes(const RoomModes &_roomModes)
|
||||||
{
|
{
|
||||||
{
|
this->roomModes_ = _roomModes;
|
||||||
std::lock_guard<std::mutex> lock(this->roomModeMutex_);
|
|
||||||
this->roomModes_ = _roomModes;
|
|
||||||
}
|
|
||||||
|
|
||||||
this->roomModesChanged.invoke();
|
this->roomModesChanged.invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TwitchChannel::isLive() const
|
bool TwitchChannel::isLive() const
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(this->streamStatusMutex_);
|
return this->streamStatus_.access()->live;
|
||||||
return this->streamStatus_.live;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TwitchChannel::StreamStatus TwitchChannel::getStreamStatus() const
|
const AccessGuard<TwitchChannel::StreamStatus> TwitchChannel::accessStreamStatus() const
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(this->streamStatusMutex_);
|
return this->streamStatus_.access();
|
||||||
return this->streamStatus_;
|
}
|
||||||
|
|
||||||
|
const EmoteMap &TwitchChannel::getFfzEmotes() const
|
||||||
|
{
|
||||||
|
return *this->ffzEmotes_;
|
||||||
|
}
|
||||||
|
|
||||||
|
const EmoteMap &TwitchChannel::getBttvEmotes() const
|
||||||
|
{
|
||||||
|
return *this->bttvEmotes_;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString &TwitchChannel::getSubscriptionUrl()
|
||||||
|
{
|
||||||
|
return this->subscriptionUrl_;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString &TwitchChannel::getChannelUrl()
|
||||||
|
{
|
||||||
|
return this->channelUrl_;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString &TwitchChannel::getPopoutPlayerUrl()
|
||||||
|
{
|
||||||
|
return this->popoutPlayerUrl_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwitchChannel::setLive(bool newLiveStatus)
|
void TwitchChannel::setLive(bool newLiveStatus)
|
||||||
{
|
{
|
||||||
bool gotNewLiveStatus = false;
|
bool gotNewLiveStatus = false;
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(this->streamStatusMutex_);
|
auto guard = this->streamStatus_.access();
|
||||||
if (this->streamStatus_.live != newLiveStatus) {
|
if (guard->live != newLiveStatus) {
|
||||||
gotNewLiveStatus = true;
|
gotNewLiveStatus = true;
|
||||||
this->streamStatus_.live = newLiveStatus;
|
guard->live = newLiveStatus;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,7 +287,7 @@ void TwitchChannel::setLive(bool newLiveStatus)
|
||||||
|
|
||||||
void TwitchChannel::refreshLiveStatus()
|
void TwitchChannel::refreshLiveStatus()
|
||||||
{
|
{
|
||||||
auto roomID = this->getRoomID();
|
auto roomID = this->getRoomId();
|
||||||
|
|
||||||
if (roomID.isEmpty()) {
|
if (roomID.isEmpty()) {
|
||||||
Log("[TwitchChannel:{}] Refreshing live status (Missing ID)", this->name);
|
Log("[TwitchChannel:{}] Refreshing live status (Missing ID)", this->name);
|
||||||
|
@ -291,92 +301,86 @@ void TwitchChannel::refreshLiveStatus()
|
||||||
|
|
||||||
auto request = makeGetStreamRequest(roomID, QThread::currentThread());
|
auto request = makeGetStreamRequest(roomID, QThread::currentThread());
|
||||||
|
|
||||||
request.onSuccess([weak = this->weak_from_this()](auto result) {
|
request.onSuccess([this, weak = this->weak_from_this()](auto result) {
|
||||||
auto d = result.parseRapidJson();
|
|
||||||
ChannelPtr shared = weak.lock();
|
ChannelPtr shared = weak.lock();
|
||||||
|
if (!shared) return false;
|
||||||
|
|
||||||
if (!shared) {
|
return this->parseLiveStatus(result.parseRapidJson());
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
TwitchChannel *channel = dynamic_cast<TwitchChannel *>(shared.get());
|
|
||||||
|
|
||||||
if (!d.IsObject()) {
|
|
||||||
Log("[TwitchChannel:refreshLiveStatus] root is not an object");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!d.HasMember("stream")) {
|
|
||||||
Log("[TwitchChannel:refreshLiveStatus] Missing stream in root");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto &stream = d["stream"];
|
|
||||||
|
|
||||||
if (!stream.IsObject()) {
|
|
||||||
// Stream is offline (stream is most likely null)
|
|
||||||
channel->setLive(false);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!stream.HasMember("viewers") || !stream.HasMember("game") ||
|
|
||||||
!stream.HasMember("channel") || !stream.HasMember("created_at")) {
|
|
||||||
Log("[TwitchChannel:refreshLiveStatus] Missing members in stream");
|
|
||||||
channel->setLive(false);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const rapidjson::Value &streamChannel = stream["channel"];
|
|
||||||
|
|
||||||
if (!streamChannel.IsObject() || !streamChannel.HasMember("status")) {
|
|
||||||
Log("[TwitchChannel:refreshLiveStatus] Missing member \"status\" in channel");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stream is live
|
|
||||||
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(channel->streamStatusMutex_);
|
|
||||||
StreamStatus status;
|
|
||||||
channel->streamStatus_.live = true;
|
|
||||||
channel->streamStatus_.viewerCount = stream["viewers"].GetUint();
|
|
||||||
channel->streamStatus_.game = stream["game"].GetString();
|
|
||||||
channel->streamStatus_.title = streamChannel["status"].GetString();
|
|
||||||
QDateTime since = QDateTime::fromString(stream["created_at"].GetString(), Qt::ISODate);
|
|
||||||
auto diff = since.secsTo(QDateTime::currentDateTime());
|
|
||||||
channel->streamStatus_.uptime =
|
|
||||||
QString::number(diff / 3600) + "h " + QString::number(diff % 3600 / 60) + "m";
|
|
||||||
|
|
||||||
channel->streamStatus_.rerun = false;
|
|
||||||
if (stream.HasMember("stream_type")) {
|
|
||||||
channel->streamStatus_.streamType = stream["stream_type"].GetString();
|
|
||||||
} else {
|
|
||||||
channel->streamStatus_.streamType = QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stream.HasMember("broadcast_platform")) {
|
|
||||||
const auto &broadcastPlatformValue = stream["broadcast_platform"];
|
|
||||||
|
|
||||||
if (broadcastPlatformValue.IsString()) {
|
|
||||||
const char *broadcastPlatform = stream["broadcast_platform"].GetString();
|
|
||||||
if (strcmp(broadcastPlatform, "rerun") == 0) {
|
|
||||||
channel->streamStatus_.rerun = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Signal all listeners that the stream status has been updated
|
|
||||||
channel->liveStatusChanged.invoke();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
request.execute();
|
request.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwitchChannel::initializeLiveStatusTimer(int intervalMS)
|
bool TwitchChannel::parseLiveStatus(const rapidjson::Document &document)
|
||||||
{
|
{
|
||||||
|
if (!document.IsObject()) {
|
||||||
|
Log("[TwitchChannel:refreshLiveStatus] root is not an object");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!document.HasMember("stream")) {
|
||||||
|
Log("[TwitchChannel:refreshLiveStatus] Missing stream in root");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto &stream = document["stream"];
|
||||||
|
|
||||||
|
if (!stream.IsObject()) {
|
||||||
|
// Stream is offline (stream is most likely null)
|
||||||
|
this->setLive(false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!stream.HasMember("viewers") || !stream.HasMember("game") || !stream.HasMember("channel") ||
|
||||||
|
!stream.HasMember("created_at")) {
|
||||||
|
Log("[TwitchChannel:refreshLiveStatus] Missing members in stream");
|
||||||
|
this->setLive(false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const rapidjson::Value &streamChannel = stream["channel"];
|
||||||
|
|
||||||
|
if (!streamChannel.IsObject() || !streamChannel.HasMember("status")) {
|
||||||
|
Log("[TwitchChannel:refreshLiveStatus] Missing member \"status\" in channel");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stream is live
|
||||||
|
|
||||||
|
{
|
||||||
|
auto status = this->streamStatus_.access();
|
||||||
|
status->live = true;
|
||||||
|
status->viewerCount = stream["viewers"].GetUint();
|
||||||
|
status->game = stream["game"].GetString();
|
||||||
|
status->title = streamChannel["status"].GetString();
|
||||||
|
QDateTime since = QDateTime::fromString(stream["created_at"].GetString(), Qt::ISODate);
|
||||||
|
auto diff = since.secsTo(QDateTime::currentDateTime());
|
||||||
|
status->uptime =
|
||||||
|
QString::number(diff / 3600) + "h " + QString::number(diff % 3600 / 60) + "m";
|
||||||
|
|
||||||
|
status->rerun = false;
|
||||||
|
if (stream.HasMember("stream_type")) {
|
||||||
|
status->streamType = stream["stream_type"].GetString();
|
||||||
|
} else {
|
||||||
|
status->streamType = QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stream.HasMember("broadcast_platform")) {
|
||||||
|
const auto &broadcastPlatformValue = stream["broadcast_platform"];
|
||||||
|
|
||||||
|
if (broadcastPlatformValue.IsString()) {
|
||||||
|
const char *broadcastPlatform = stream["broadcast_platform"].GetString();
|
||||||
|
if (strcmp(broadcastPlatform, "rerun") == 0) {
|
||||||
|
status->rerun = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Signal all listeners that the stream status has been updated
|
||||||
|
this->liveStatusChanged.invoke();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwitchChannel::loadRecentMessages()
|
void TwitchChannel::loadRecentMessages()
|
||||||
|
@ -384,7 +388,7 @@ void TwitchChannel::loadRecentMessages()
|
||||||
static QString genericURL =
|
static QString genericURL =
|
||||||
"https://tmi.twitch.tv/api/rooms/%1/recent_messages?client_id=" + getDefaultClientID();
|
"https://tmi.twitch.tv/api/rooms/%1/recent_messages?client_id=" + getDefaultClientID();
|
||||||
|
|
||||||
NetworkRequest request(genericURL.arg(this->getRoomID()));
|
NetworkRequest request(genericURL.arg(this->getRoomId()));
|
||||||
request.makeAuthorizedV5(getDefaultClientID());
|
request.makeAuthorizedV5(getDefaultClientID());
|
||||||
request.setCaller(QThread::currentThread());
|
request.setCaller(QThread::currentThread());
|
||||||
|
|
||||||
|
@ -431,7 +435,7 @@ void TwitchChannel::refreshPubsub()
|
||||||
{
|
{
|
||||||
// listen to moderation actions
|
// listen to moderation actions
|
||||||
if (!this->hasModRights()) return;
|
if (!this->hasModRights()) return;
|
||||||
auto roomId = this->getRoomID();
|
auto roomId = this->getRoomId();
|
||||||
if (roomId.isEmpty()) return;
|
if (roomId.isEmpty()) return;
|
||||||
|
|
||||||
auto account = getApp()->accounts->twitch.getCurrent();
|
auto account = getApp()->accounts->twitch.getCurrent();
|
||||||
|
@ -441,10 +445,10 @@ void TwitchChannel::refreshPubsub()
|
||||||
void TwitchChannel::refreshViewerList()
|
void TwitchChannel::refreshViewerList()
|
||||||
{
|
{
|
||||||
// setting?
|
// setting?
|
||||||
const auto streamStatus = this->getStreamStatus();
|
const auto streamStatus = this->accessStreamStatus();
|
||||||
|
|
||||||
if (getSettings()->onlyFetchChattersForSmallerStreamers) {
|
if (getSettings()->onlyFetchChattersForSmallerStreamers) {
|
||||||
if (streamStatus.live && streamStatus.viewerCount > getSettings()->smallStreamerLimit) {
|
if (streamStatus->live && streamStatus->viewerCount > getSettings()->smallStreamerLimit) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "common/Channel.hpp"
|
#include "common/Channel.hpp"
|
||||||
#include "common/Common.hpp"
|
#include "common/Common.hpp"
|
||||||
#include "common/MutexValue.hpp"
|
#include "common/MutexValue.hpp"
|
||||||
|
#include "common/UniqueAccess.hpp"
|
||||||
#include "singletons/Emotes.hpp"
|
#include "singletons/Emotes.hpp"
|
||||||
#include "util/ConcurrentMap.hpp"
|
#include "util/ConcurrentMap.hpp"
|
||||||
|
|
||||||
|
@ -43,50 +44,53 @@ public:
|
||||||
QString broadcasterLang;
|
QString broadcasterLang;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool isEmpty() const override;
|
void refreshChannelEmotes();
|
||||||
bool canSendMessage() const override;
|
|
||||||
void sendMessage(const QString &message) override;
|
|
||||||
|
|
||||||
|
// Channel methods
|
||||||
|
virtual bool isEmpty() const override;
|
||||||
|
virtual bool canSendMessage() const override;
|
||||||
|
virtual void sendMessage(const QString &message) override;
|
||||||
|
|
||||||
|
// Auto completion
|
||||||
|
void addRecentChatter(const std::shared_ptr<Message> &message) final;
|
||||||
|
void addJoinedUser(const QString &user);
|
||||||
|
void addPartedUser(const QString &user);
|
||||||
|
|
||||||
|
// Twitch data
|
||||||
bool isLive() const;
|
bool isLive() const;
|
||||||
virtual bool isMod() const override;
|
virtual bool isMod() const override;
|
||||||
void setMod(bool value);
|
void setMod(bool value);
|
||||||
virtual bool isBroadcaster() const override;
|
virtual bool isBroadcaster() const override;
|
||||||
|
|
||||||
QString getRoomID() const;
|
QString getRoomId() const;
|
||||||
void setRoomID(const QString &id);
|
void setRoomId(const QString &id);
|
||||||
RoomModes getRoomModes();
|
const AccessGuard<RoomModes> accessRoomModes() const;
|
||||||
void setRoomModes(const RoomModes &roomModes_);
|
void setRoomModes(const RoomModes &roomModes_);
|
||||||
StreamStatus getStreamStatus() const;
|
const AccessGuard<StreamStatus> accessStreamStatus() const;
|
||||||
|
|
||||||
void addRecentChatter(const std::shared_ptr<Message> &message) final;
|
const EmoteMap &getFfzEmotes() const;
|
||||||
void addJoinedUser(const QString &user);
|
const EmoteMap &getBttvEmotes() const;
|
||||||
void addPartedUser(const QString &user);
|
const QString &getSubscriptionUrl();
|
||||||
|
const QString &getChannelUrl();
|
||||||
|
const QString &getPopoutPlayerUrl();
|
||||||
|
|
||||||
|
// Signals
|
||||||
|
pajlada::Signals::NoArgSignal roomIdChanged;
|
||||||
|
pajlada::Signals::NoArgSignal liveStatusChanged;
|
||||||
|
pajlada::Signals::NoArgSignal userStateChanged;
|
||||||
|
pajlada::Signals::NoArgSignal roomModesChanged;
|
||||||
|
|
||||||
|
private:
|
||||||
struct NameOptions {
|
struct NameOptions {
|
||||||
QString displayName;
|
QString displayName;
|
||||||
QString localizedName;
|
QString localizedName;
|
||||||
};
|
};
|
||||||
|
|
||||||
void refreshChannelEmotes();
|
|
||||||
|
|
||||||
const std::shared_ptr<EmoteMap> bttvChannelEmotes;
|
|
||||||
const std::shared_ptr<EmoteMap> ffzChannelEmotes;
|
|
||||||
|
|
||||||
const QString subscriptionURL;
|
|
||||||
const QString channelURL;
|
|
||||||
const QString popoutPlayerURL;
|
|
||||||
|
|
||||||
pajlada::Signals::NoArgSignal roomIDChanged;
|
|
||||||
pajlada::Signals::NoArgSignal liveStatusChanged;
|
|
||||||
|
|
||||||
pajlada::Signals::NoArgSignal userStateChanged;
|
|
||||||
pajlada::Signals::NoArgSignal roomModesChanged;
|
|
||||||
|
|
||||||
private:
|
|
||||||
explicit TwitchChannel(const QString &channelName, Communi::IrcConnection *readConnection);
|
explicit TwitchChannel(const QString &channelName, Communi::IrcConnection *readConnection);
|
||||||
|
|
||||||
void initializeLiveStatusTimer(int intervalMS);
|
// Methods
|
||||||
void refreshLiveStatus();
|
void refreshLiveStatus();
|
||||||
|
bool parseLiveStatus(const rapidjson::Document &document);
|
||||||
void refreshPubsub();
|
void refreshPubsub();
|
||||||
void refreshViewerList();
|
void refreshViewerList();
|
||||||
bool parseViewerList(const QJsonObject &jsonRoot);
|
bool parseViewerList(const QJsonObject &jsonRoot);
|
||||||
|
@ -95,35 +99,32 @@ private:
|
||||||
|
|
||||||
void setLive(bool newLiveStatus);
|
void setLive(bool newLiveStatus);
|
||||||
|
|
||||||
mutable std::mutex streamStatusMutex_;
|
// Twitch data
|
||||||
StreamStatus streamStatus_;
|
UniqueAccess<StreamStatus> streamStatus_;
|
||||||
|
UniqueAccess<UserState> userState_;
|
||||||
|
UniqueAccess<RoomModes> roomModes_;
|
||||||
|
|
||||||
mutable std::mutex userStateMutex_;
|
const std::shared_ptr<EmoteMap> bttvEmotes_;
|
||||||
UserState userState_;
|
const std::shared_ptr<EmoteMap> ffzEmotes_;
|
||||||
|
const QString subscriptionUrl_;
|
||||||
|
const QString channelUrl_;
|
||||||
|
const QString popoutPlayerUrl_;
|
||||||
|
|
||||||
bool mod_ = false;
|
bool mod_ = false;
|
||||||
QByteArray messageSuffix_;
|
|
||||||
QString lastSentMessage_;
|
|
||||||
RoomModes roomModes_;
|
|
||||||
std::mutex roomModeMutex_;
|
|
||||||
MutexValue<QString> roomID_;
|
MutexValue<QString> roomID_;
|
||||||
|
|
||||||
QObject object_;
|
UniqueAccess<QStringList> joinedUsers_;
|
||||||
std::mutex joinedUserMutex_;
|
|
||||||
QStringList joinedUsers_;
|
|
||||||
bool joinedUsersMergeQueued_ = false;
|
bool joinedUsersMergeQueued_ = false;
|
||||||
std::mutex partedUserMutex_;
|
UniqueAccess<QStringList> partedUsers_;
|
||||||
QStringList partedUsers_;
|
|
||||||
bool partedUsersMergeQueued_ = false;
|
bool partedUsersMergeQueued_ = false;
|
||||||
|
|
||||||
Communi::IrcConnection *readConnection_ = nullptr;
|
// --
|
||||||
|
QByteArray messageSuffix_;
|
||||||
// Key = login name
|
QString lastSentMessage_;
|
||||||
std::map<QString, NameOptions> recentChatters_;
|
QObject lifetimeGuard_;
|
||||||
std::mutex recentChattersMutex_;
|
|
||||||
|
|
||||||
QTimer liveStatusTimer_;
|
QTimer liveStatusTimer_;
|
||||||
QTimer chattersListTimer_;
|
QTimer chattersListTimer_;
|
||||||
|
Communi::IrcConnection *readConnection_ = nullptr;
|
||||||
|
|
||||||
friend class TwitchServer;
|
friend class TwitchServer;
|
||||||
};
|
};
|
||||||
|
|
|
@ -298,8 +298,8 @@ void TwitchMessageBuilder::parseRoomID()
|
||||||
if (iterator != std::end(this->tags)) {
|
if (iterator != std::end(this->tags)) {
|
||||||
this->roomID_ = iterator.value().toString();
|
this->roomID_ = iterator.value().toString();
|
||||||
|
|
||||||
if (this->twitchChannel->getRoomID().isEmpty()) {
|
if (this->twitchChannel->getRoomId().isEmpty()) {
|
||||||
this->twitchChannel->setRoomID(this->roomID_);
|
this->twitchChannel->setRoomId(this->roomID_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -588,14 +588,14 @@ bool TwitchMessageBuilder::tryAppendEmote(QString &emoteString)
|
||||||
// BTTV Global Emote
|
// BTTV Global Emote
|
||||||
return appendEmote(MessageElement::BttvEmote);
|
return appendEmote(MessageElement::BttvEmote);
|
||||||
} else if (this->twitchChannel != nullptr &&
|
} else if (this->twitchChannel != nullptr &&
|
||||||
this->twitchChannel->bttvChannelEmotes->tryGet(emoteString, emoteData)) {
|
this->twitchChannel->getBttvEmotes().tryGet(emoteString, emoteData)) {
|
||||||
// BTTV Channel Emote
|
// BTTV Channel Emote
|
||||||
return appendEmote(MessageElement::BttvEmote);
|
return appendEmote(MessageElement::BttvEmote);
|
||||||
} else if (app->emotes->ffz.globalEmotes.tryGet(emoteString, emoteData)) {
|
} else if (app->emotes->ffz.globalEmotes.tryGet(emoteString, emoteData)) {
|
||||||
// FFZ Global Emote
|
// FFZ Global Emote
|
||||||
return appendEmote(MessageElement::FfzEmote);
|
return appendEmote(MessageElement::FfzEmote);
|
||||||
} else if (this->twitchChannel != nullptr &&
|
} else if (this->twitchChannel != nullptr &&
|
||||||
this->twitchChannel->ffzChannelEmotes->tryGet(emoteString, emoteData)) {
|
this->twitchChannel->getFfzEmotes().tryGet(emoteString, emoteData)) {
|
||||||
// FFZ Channel Emote
|
// FFZ Channel Emote
|
||||||
return appendEmote(MessageElement::FfzEmote);
|
return appendEmote(MessageElement::FfzEmote);
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,7 +155,7 @@ void TwitchServer::forEachChannelAndSpecialChannels(std::function<void(ChannelPt
|
||||||
func(this->mentionsChannel);
|
func(this->mentionsChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Channel> TwitchServer::getChannelOrEmptyByID(const QString &channelID)
|
std::shared_ptr<Channel> TwitchServer::getChannelOrEmptyByID(const QString &channelId)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(this->channelMutex);
|
std::lock_guard<std::mutex> lock(this->channelMutex);
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ std::shared_ptr<Channel> TwitchServer::getChannelOrEmptyByID(const QString &chan
|
||||||
auto twitchChannel = std::dynamic_pointer_cast<TwitchChannel>(channel);
|
auto twitchChannel = std::dynamic_pointer_cast<TwitchChannel>(channel);
|
||||||
if (!twitchChannel) continue;
|
if (!twitchChannel) continue;
|
||||||
|
|
||||||
if (twitchChannel->getRoomID() == channelID) {
|
if (twitchChannel->getRoomId() == channelId) {
|
||||||
return twitchChannel;
|
return twitchChannel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ void EmotePopup::loadChannel(ChannelPtr _channel)
|
||||||
|
|
||||||
ChannelPtr emoteChannel(new Channel("", Channel::Type::None));
|
ChannelPtr emoteChannel(new Channel("", Channel::Type::None));
|
||||||
|
|
||||||
auto addEmotes = [&](EmoteMap &map, const QString &title, const QString &emoteDesc) {
|
auto addEmotes = [&](const EmoteMap &map, const QString &title, const QString &emoteDesc) {
|
||||||
// TITLE
|
// TITLE
|
||||||
MessageBuilder builder1;
|
MessageBuilder builder1;
|
||||||
|
|
||||||
|
@ -120,12 +120,10 @@ void EmotePopup::loadChannel(ChannelPtr _channel)
|
||||||
}
|
}
|
||||||
|
|
||||||
addEmotes(app->emotes->bttv.globalEmotes, "BetterTTV Global Emotes", "BetterTTV Global Emote");
|
addEmotes(app->emotes->bttv.globalEmotes, "BetterTTV Global Emotes", "BetterTTV Global Emote");
|
||||||
addEmotes(*channel->bttvChannelEmotes.get(), "BetterTTV Channel Emotes",
|
addEmotes(channel->getBttvEmotes(), "BetterTTV Channel Emotes", "BetterTTV Channel Emote");
|
||||||
"BetterTTV Channel Emote");
|
|
||||||
addEmotes(app->emotes->ffz.globalEmotes, "FrankerFaceZ Global Emotes",
|
addEmotes(app->emotes->ffz.globalEmotes, "FrankerFaceZ Global Emotes",
|
||||||
"FrankerFaceZ Global Emote");
|
"FrankerFaceZ Global Emote");
|
||||||
addEmotes(*channel->ffzChannelEmotes.get(), "FrankerFaceZ Channel Emotes",
|
addEmotes(channel->getFfzEmotes(), "FrankerFaceZ Channel Emotes", "FrankerFaceZ Channel Emote");
|
||||||
"FrankerFaceZ Channel Emote");
|
|
||||||
|
|
||||||
this->viewEmotes_->setChannel(emoteChannel);
|
this->viewEmotes_->setChannel(emoteChannel);
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,9 +80,7 @@ SplitHeader::SplitHeader(Split *_split)
|
||||||
// dropdown->setScaleIndependantSize(23, 23);
|
// dropdown->setScaleIndependantSize(23, 23);
|
||||||
this->addDropdownItems(dropdown.getElement());
|
this->addDropdownItems(dropdown.getElement());
|
||||||
QObject::connect(dropdown.getElement(), &RippleEffectButton::leftMousePress, this, [this] {
|
QObject::connect(dropdown.getElement(), &RippleEffectButton::leftMousePress, this, [this] {
|
||||||
QTimer::singleShot(80, [&, this] {
|
QTimer::singleShot(80, [&, this] { this->dropdownMenu_.popup(QCursor::pos()); });
|
||||||
this->dropdownMenu_.popup(QCursor::pos());
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,17 +166,17 @@ void SplitHeader::setupModeLabel(RippleEffectLabel &label)
|
||||||
label.setEnable(twitchChannel->hasModRights());
|
label.setEnable(twitchChannel->hasModRights());
|
||||||
|
|
||||||
// set the label text
|
// set the label text
|
||||||
auto roomModes = twitchChannel->getRoomModes();
|
|
||||||
QString text;
|
QString text;
|
||||||
|
|
||||||
if (roomModes.r9k)
|
{
|
||||||
text += "r9k, ";
|
auto roomModes = twitchChannel->accessRoomModes();
|
||||||
if (roomModes.slowMode)
|
|
||||||
text += QString("slow(%1), ").arg(QString::number(roomModes.slowMode));
|
if (roomModes->r9k) text += "r9k, ";
|
||||||
if (roomModes.emoteOnly)
|
if (roomModes->slowMode)
|
||||||
text += "emote, ";
|
text += QString("slow(%1), ").arg(QString::number(roomModes->slowMode));
|
||||||
if (roomModes.submode)
|
if (roomModes->emoteOnly) text += "emote, ";
|
||||||
text += "sub, ";
|
if (roomModes->submode) text += "sub, ";
|
||||||
|
}
|
||||||
|
|
||||||
if (text.length() > 2) {
|
if (text.length() > 2) {
|
||||||
text = text.mid(0, text.size() - 2);
|
text = text.mid(0, text.size() - 2);
|
||||||
|
@ -229,12 +227,12 @@ void SplitHeader::addModeActions(QMenu &menu)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto roomModes = twitchChannel->getRoomModes();
|
auto roomModes = twitchChannel->accessRoomModes();
|
||||||
|
|
||||||
setR9k->setChecked(roomModes.r9k);
|
setR9k->setChecked(roomModes->r9k);
|
||||||
setSlow->setChecked(roomModes.slowMode);
|
setSlow->setChecked(roomModes->slowMode);
|
||||||
setEmote->setChecked(roomModes.emoteOnly);
|
setEmote->setChecked(roomModes->emoteOnly);
|
||||||
setSub->setChecked(roomModes.submode);
|
setSub->setChecked(roomModes->submode);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
auto toggle = [this](const QString &_command, QAction *action) mutable {
|
auto toggle = [this](const QString &_command, QAction *action) mutable {
|
||||||
|
@ -315,22 +313,22 @@ void SplitHeader::updateChannelText()
|
||||||
TwitchChannel *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get());
|
TwitchChannel *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get());
|
||||||
|
|
||||||
if (twitchChannel != nullptr) {
|
if (twitchChannel != nullptr) {
|
||||||
const auto streamStatus = twitchChannel->getStreamStatus();
|
const auto streamStatus = twitchChannel->accessStreamStatus();
|
||||||
|
|
||||||
if (streamStatus.live) {
|
if (streamStatus->live) {
|
||||||
this->isLive_ = true;
|
this->isLive_ = true;
|
||||||
this->tooltip_ = "<style>.center { text-align: center; }</style>"
|
this->tooltip_ = "<style>.center { text-align: center; }</style>"
|
||||||
"<p class = \"center\">" +
|
"<p class = \"center\">" +
|
||||||
streamStatus.title + "<br><br>" + streamStatus.game + "<br>" +
|
streamStatus->title + "<br><br>" + streamStatus->game + "<br>" +
|
||||||
(streamStatus.rerun ? "Vod-casting" : "Live") + " for " +
|
(streamStatus->rerun ? "Vod-casting" : "Live") + " for " +
|
||||||
streamStatus.uptime + " with " +
|
streamStatus->uptime + " with " +
|
||||||
QString::number(streamStatus.viewerCount) +
|
QString::number(streamStatus->viewerCount) +
|
||||||
" viewers"
|
" viewers"
|
||||||
"</p>";
|
"</p>";
|
||||||
if (streamStatus.rerun) {
|
if (streamStatus->rerun) {
|
||||||
title += " (rerun)";
|
title += " (rerun)";
|
||||||
} else if (streamStatus.streamType.isEmpty()) {
|
} else if (streamStatus->streamType.isEmpty()) {
|
||||||
title += " (" + streamStatus.streamType + ")";
|
title += " (" + streamStatus->streamType + ")";
|
||||||
} else {
|
} else {
|
||||||
title += " (live)";
|
title += " (live)";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue