mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
changes and fix displayname of 'is live' message
This commit is contained in:
parent
ec6b26cd23
commit
3c01af9805
6 changed files with 43 additions and 7 deletions
|
@ -43,6 +43,11 @@ const QString &Channel::getName() const
|
||||||
return this->name_;
|
return this->name_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QString &Channel::getDisplayName() const
|
||||||
|
{
|
||||||
|
return this->getName();
|
||||||
|
}
|
||||||
|
|
||||||
bool Channel::isTwitchChannel() const
|
bool Channel::isTwitchChannel() const
|
||||||
{
|
{
|
||||||
return this->type_ >= Type::Twitch && this->type_ < Type::TwitchEnd;
|
return this->type_ >= Type::Twitch && this->type_ < Type::TwitchEnd;
|
||||||
|
|
|
@ -47,6 +47,7 @@ public:
|
||||||
|
|
||||||
Type getType() const;
|
Type getType() const;
|
||||||
const QString &getName() const;
|
const QString &getName() const;
|
||||||
|
virtual const QString &getDisplayName() const;
|
||||||
bool isTwitchChannel() const;
|
bool isTwitchChannel() const;
|
||||||
virtual bool isEmpty() const;
|
virtual bool isEmpty() const;
|
||||||
LimitedQueueSnapshot<MessagePtr> getMessageSnapshot();
|
LimitedQueueSnapshot<MessagePtr> getMessageSnapshot();
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "TwitchApi.hpp"
|
#include "TwitchApi.hpp"
|
||||||
#include "common/Common.hpp"
|
#include "common/Common.hpp"
|
||||||
#include "messages\Emote.hpp"
|
#include "messages/Emote.hpp"
|
||||||
#include "providers/bttv/BttvEmotes.hpp"
|
#include "providers/bttv/BttvEmotes.hpp"
|
||||||
#include "providers/bttv/LoadBttvChannelEmote.hpp"
|
#include "providers/bttv/LoadBttvChannelEmote.hpp"
|
||||||
#include "singletons/Emotes.hpp"
|
#include "singletons/Emotes.hpp"
|
||||||
|
@ -15,19 +15,22 @@ ChatroomChannel::ChatroomChannel(const QString &channelName,
|
||||||
BttvEmotes &globalBttv, FfzEmotes &globalFfz)
|
BttvEmotes &globalBttv, FfzEmotes &globalFfz)
|
||||||
: TwitchChannel(channelName, globalTwitchBadges, globalBttv, globalFfz)
|
: TwitchChannel(channelName, globalTwitchBadges, globalBttv, globalFfz)
|
||||||
{
|
{
|
||||||
auto list = channelName.split(":");
|
auto listRef = channelName.splitRef(":");
|
||||||
if (list.size() > 2)
|
if (listRef.size() > 2)
|
||||||
{
|
{
|
||||||
this->chatroomOwnerId = list[1];
|
this->chatroomOwnerId = listRef[1].toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatroomChannel::refreshChannelEmotes()
|
void ChatroomChannel::refreshChannelEmotes()
|
||||||
{
|
{
|
||||||
|
if (this->chatroomOwnerId.isEmpty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
TwitchApi::findUserName(
|
TwitchApi::findUserName(
|
||||||
this->chatroomOwnerId,
|
this->chatroomOwnerId,
|
||||||
[this, weak = weakOf<Channel>(this)](QString username) {
|
[this, weak = weakOf<Channel>(this)](QString username) {
|
||||||
qDebug() << username;
|
|
||||||
BttvEmotes::loadChannel(username, [this, weak](auto &&emoteMap) {
|
BttvEmotes::loadChannel(username, [this, weak](auto &&emoteMap) {
|
||||||
if (auto shared = weak.lock())
|
if (auto shared = weak.lock())
|
||||||
this->bttvEmotes_.set(
|
this->bttvEmotes_.set(
|
||||||
|
@ -38,7 +41,16 @@ void ChatroomChannel::refreshChannelEmotes()
|
||||||
this->ffzEmotes_.set(
|
this->ffzEmotes_.set(
|
||||||
std::make_shared<EmoteMap>(std::move(emoteMap)));
|
std::make_shared<EmoteMap>(std::move(emoteMap)));
|
||||||
});
|
});
|
||||||
|
if (auto shared = weak.lock())
|
||||||
|
{
|
||||||
|
this->chatroomOwnerName = username;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QString &ChatroomChannel::getDisplayName() const
|
||||||
|
{
|
||||||
|
return this->chatroomOwnerName;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -14,8 +14,10 @@ protected:
|
||||||
TwitchBadges &globalTwitchBadges,
|
TwitchBadges &globalTwitchBadges,
|
||||||
BttvEmotes &globalBttv, FfzEmotes &globalFfz);
|
BttvEmotes &globalBttv, FfzEmotes &globalFfz);
|
||||||
virtual void refreshChannelEmotes() override;
|
virtual void refreshChannelEmotes() override;
|
||||||
|
virtual const QString &getDisplayName() const override;
|
||||||
|
|
||||||
QString chatroomOwnerId;
|
QString chatroomOwnerId;
|
||||||
|
QString chatroomOwnerName;
|
||||||
|
|
||||||
friend class TwitchServer;
|
friend class TwitchServer;
|
||||||
friend class TwitchMessageBuilder;
|
friend class TwitchMessageBuilder;
|
||||||
|
|
|
@ -438,7 +438,8 @@ void TwitchChannel::setLive(bool newLiveStatus)
|
||||||
getApp()->windows->sendAlert();
|
getApp()->windows->sendAlert();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto live = makeSystemMessage(this->getName() + " is live");
|
auto live =
|
||||||
|
makeSystemMessage(this->getDisplayName() + " is live");
|
||||||
this->addMessage(live);
|
this->addMessage(live);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -23,6 +23,21 @@ using namespace std::chrono_literals;
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
bool isChatroom(const QString &channel)
|
||||||
|
{
|
||||||
|
if (channel.left(10) == "chatrooms:")
|
||||||
|
{
|
||||||
|
auto reflist = channel.splitRef(':');
|
||||||
|
if (reflist.size() == 3)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
TwitchServer::TwitchServer()
|
TwitchServer::TwitchServer()
|
||||||
: whispersChannel(new Channel("/whispers", Channel::Type::TwitchWhispers))
|
: whispersChannel(new Channel("/whispers", Channel::Type::TwitchWhispers))
|
||||||
, mentionsChannel(new Channel("/mentions", Channel::Type::TwitchMentions))
|
, mentionsChannel(new Channel("/mentions", Channel::Type::TwitchMentions))
|
||||||
|
@ -94,7 +109,7 @@ void TwitchServer::initializeConnection(IrcConnection *connection, bool isRead,
|
||||||
std::shared_ptr<Channel> TwitchServer::createChannel(const QString &channelName)
|
std::shared_ptr<Channel> TwitchServer::createChannel(const QString &channelName)
|
||||||
{
|
{
|
||||||
std::shared_ptr<TwitchChannel> channel;
|
std::shared_ptr<TwitchChannel> channel;
|
||||||
if (channelName.left(10).toLower() == "chatrooms:")
|
if (isChatroom(channelName))
|
||||||
{
|
{
|
||||||
channel = std::static_pointer_cast<TwitchChannel>(
|
channel = std::static_pointer_cast<TwitchChannel>(
|
||||||
std::shared_ptr<ChatroomChannel>(new ChatroomChannel(
|
std::shared_ptr<ChatroomChannel>(new ChatroomChannel(
|
||||||
|
|
Loading…
Reference in a new issue