2019-02-26 21:00:57 +01:00
|
|
|
#include "ChatroomChannel.hpp"
|
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
#include "TwitchApi.hpp"
|
|
|
|
#include "common/Common.hpp"
|
2019-03-01 21:18:32 +01:00
|
|
|
#include "messages/Emote.hpp"
|
2019-02-26 21:00:57 +01:00
|
|
|
#include "providers/bttv/BttvEmotes.hpp"
|
|
|
|
#include "providers/bttv/LoadBttvChannelEmote.hpp"
|
|
|
|
#include "singletons/Emotes.hpp"
|
|
|
|
|
|
|
|
namespace chatterino {
|
|
|
|
|
|
|
|
ChatroomChannel::ChatroomChannel(const QString &channelName,
|
|
|
|
TwitchBadges &globalTwitchBadges,
|
|
|
|
BttvEmotes &globalBttv, FfzEmotes &globalFfz)
|
|
|
|
: TwitchChannel(channelName, globalTwitchBadges, globalBttv, globalFfz)
|
|
|
|
{
|
2019-03-01 21:18:32 +01:00
|
|
|
auto listRef = channelName.splitRef(":");
|
|
|
|
if (listRef.size() > 2)
|
2019-02-26 21:00:57 +01:00
|
|
|
{
|
2019-03-01 21:18:32 +01:00
|
|
|
this->chatroomOwnerId = listRef[1].toString();
|
2019-02-26 21:00:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChatroomChannel::refreshChannelEmotes()
|
|
|
|
{
|
2019-03-01 21:18:32 +01:00
|
|
|
if (this->chatroomOwnerId.isEmpty())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2019-02-26 21:00:57 +01:00
|
|
|
TwitchApi::findUserName(
|
|
|
|
this->chatroomOwnerId,
|
|
|
|
[this, weak = weakOf<Channel>(this)](QString username) {
|
|
|
|
BttvEmotes::loadChannel(username, [this, weak](auto &&emoteMap) {
|
|
|
|
if (auto shared = weak.lock())
|
|
|
|
this->bttvEmotes_.set(
|
|
|
|
std::make_shared<EmoteMap>(std::move(emoteMap)));
|
|
|
|
});
|
|
|
|
FfzEmotes::loadChannel(username, [this, weak](auto &&emoteMap) {
|
|
|
|
if (auto shared = weak.lock())
|
|
|
|
this->ffzEmotes_.set(
|
|
|
|
std::make_shared<EmoteMap>(std::move(emoteMap)));
|
|
|
|
});
|
2019-03-01 21:18:32 +01:00
|
|
|
if (auto shared = weak.lock())
|
|
|
|
{
|
|
|
|
this->chatroomOwnerName = username;
|
|
|
|
}
|
2019-02-26 21:00:57 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-03-01 21:18:32 +01:00
|
|
|
const QString &ChatroomChannel::getDisplayName() const
|
|
|
|
{
|
|
|
|
return this->chatroomOwnerName;
|
|
|
|
}
|
|
|
|
|
2019-02-26 21:00:57 +01:00
|
|
|
} // namespace chatterino
|